My goal is to create a bootable backup of my system without restarting, I will use qemu-img to convert a raw dd image to vhdx and run it in Hyper-V.
If I boot into a liveCD and run:
dd if=/dev/sda of=/nfs/sda.raw conv=noerror,sync,notrunc
I can convert that to a vhdx and run it directly in Hyper-V without much effort.
fdisk -l output:
Disk /dev/sda: 238.5 GiB, 256060514304 bytes, 500118192 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: gpt Disk identifier: 7555D04B-D6DC-4ABB-8863-529E874BADAD Device Start End Sectors Size Type /dev/sda1 2048 2000895 1998848 976M EFI System /dev/sda2 2000896 500117503 498116608 237.5G Linux filesystem
However you can't use that command while the system is online, so I am using the dattobd driver to copy my entire ext4 filesystem like this:
dd if=/dev/datto0 of=/nfs/sda2.raw bs=1M
This effectively copies all the data on
/dev/sda2 correctly, I've verified that because the hash is the same if I where to use the liveCD and dd the
/dev/sda2 partition. Now I can boot into a liveCD and copy
/dev/sda1, that's the EFI partition so it doesn't change very often unless I update grub or something Linux kernel related, I'm fine with restarting just to backup that partition once in a while, but if someone knows a way to do that online please tell me.
Now I have
/dev/sda2 in two separate files, my question is how can I assemble these two into a single file that would essentially give the same ouput as running
dd if=/dev/sda of=/nfs/sda.raw conv=noerror,sync,notrunc on a liveCD? Would you just need to align the bytes perfectly? I've search for this everywhere and no luck. Any help is very much appreciated!