Assemble zero-copy disk image on Linux
If you backup using cow-raw image files on Linux (using btrfs or ZFS) you can assemble disk images without making copies of them. Those disk images can then be directly used as KVM or Xen disk or exported via iSCSI. UrBackup backs up volume images and not disk images. That is why this assemble step is required.
Create (writeable) snapshots of the volumes involved with btrfs or ZFS
E.g. with btrfs:
btrfs subvol snap 170302-2131_Image_SYSVOL 170302-2131_Image_SYSVOL_rw btrfs subvol snap 170302-2132_Image_C 170302-2132_Image_C_rw
Create a boot sector image
Create a file somewhere in which the boot sector is stored. Links to the urbackuprestoreclient are in How to restore via command line.
truncate -s 16M /tmp/mbr.img losetup /dev/loop0 /tmp/mbr.img ./urbackuprestoreclient --restore-mbr /media/backup2/urbackup/win2012server/170302-2132_Image_C_rw/Image_C_170302-2132.raw.mbr -o /dev/loop0
Inspect the partition layout using e.g. parted (ignore errors about the partitions ending beyond the block device). Use the "unit s" command to display the positions as sectors (512 byte blocks):
> unit s > p Model: Loopback device (loopback) Disk /dev/loop0: 32768s Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 2048s 718847s 716800s primary boot 2 718848s 188741631s 188022784s primary
Resize the volume files to (at least) the partition sizes
UrBackup backs up only the parts actually used by the file systems, so the image files may be smaller than the partition sizes. We can easily make sure the sizes are correct by extending the files a bit:
ls -l /media/backup2/urbackup/win2012server/170302-2132_Image_C_rw/Image_C_170302-2132.raw -rwxr-x--- 1 urbackup urbackup 96268189184 Mar 2 21:45 /media/backup2/urbackup/win2012server/170302-2132_Image_C_rw/Image_C_170302-2132.ra
So image size is 188022783s (96268189184/512-1024 – volumes start at a 512kB offset into the file) but needs to be at least 188022784s. So we need to add at least one sector:
truncate -s +512 /media/backup2/urbackup/win2012server/170302-2132_Image_C_rw/Image_C_170302-2132.raw
ls -l /media/backup2/urbackup/win2012server/170302-2131_Image_SYSVOL_rw/Image_SYSVOL_170302-2131.raw -rwxr-x--- 1 urbackup urbackup 367525376 Mar 2 21:32 /media/backup2/urbackup/win2012server/170302-2131_Image_SYSVOL_rw/Image_SYSVOL_170302-2131.raw
Image size is 716799s so we need to add one sector:
truncate -s +512 /media/backup2/urbackup/win2012server/170302-2131_Image_SYSVOL_rw/Image_SYSVOL_170302-2131.raw
Assemble volumes using Linux device mapper
The Linux device mapper linear target can be used to assemble several disks into one device mapper device (this is what LVM uses to combine disks).
First create loop devices for the different image files:
losetup /dev/loop1 /media/backup2/urbackup/win2012server/170302-2131_Image_SYSVOL_rw/Image_SYSVOL_170302-2131.raw --offset 524288 losetup /dev/loop2 /media/backup2/urbackup/win2012server/170302-2132_Image_C_rw/Image_C_170302-2132.raw --offset 524288
Then as a final step setup the new device mapper device. The offsets and sizes are from the partition table above:
echo "0 2048 linear /dev/loop0 0 2048 716800 linear /dev/loop1 0 718848 188022784 linear /dev/loop2 0" | dmsetup create win2012server_img
The assembled disk image is then at /dev/mapper/win2012server_img.