User Tools

Site Tools


software:ntfsclone

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

software:ntfsclone [2021/03/07 23:48] – created rodolicosoftware:ntfsclone [2021/03/08 00:18] (current) rodolico
Line 1: Line 1:
 ====== ntfsclone ====== ====== ntfsclone ======
  
 +You can efficiently back up a Windows virtual domain (or, just a Windows server) from unix using the ntfsclone command. This only copies the used parts of an NTFS file system but, it only works on //file systems// (not block devices), so you have to go through some additional steps if you want the entire disk backed up. The following is an example of backing up everything you need for recovery.
  
-DO NOT USE, NOT READY YET. +It assumes we are shutting down a Windows 10 workstation, using Xen. The Windows 10 machine is named 'win_test', and uses one LVM2 Logical volume, /dev/vg0/win_test.disk. We will be putting the output on a USB drive mounted on /mnt.
- +
-You can efficiently back up a Windows virtual domain (or, just a Windows server) from unix using the ntfsclone command. This only copies the used parts of a system, however, it only works on //file systems// (not block devices), so you have to go through some additional changes. The following is an example of backing up everything you need for recovery. +
- +
-It assumes we are shutting down a Windows 10 workstation, using Xen. The Windows 10 machine is named 'win_test', and uses two Logical volumes, /dev/vg0/win_test.disk0 and /dev/vg0/win_test.disk1. We will be putting the output on a USB drive mounted on /mnt.+
  
 <code bash> <code bash>
Line 14: Line 11:
 xl top xl top
 # ok, it is gone, now create snapshots # ok, it is gone, now create snapshots
-lvcreate -s -L 10G -n snap.win_test.disk0 /dev/vg0/win_test.disk0 +lvcreate -s -L 10G -n snap.win_test.disk /dev/vg0/win_test.disk 
-lvcreate -s -L 10G -n snap.win_test.disk1 /dev/vg0/win_test.disk1 +# we have our snapshot, so we can start win_test back up
-# we have our snapshot, so start win_test back up+
 xl create /etc/xen/win_test.hvm xl create /etc/xen/win_test.hvm
 # create a directory for all our stuff # create a directory for all our stuff
 mkdir -p /mnt/win_test mkdir -p /mnt/win_test
-# get disk sizes +# get disk size 
-lvs | grep win_test.disk> /mnt/win_test/lvs.disks+lvs | grep win_test.disk > /mnt/win_test/lvs.disks
 # get partitioning # get partitioning
-for disk in 0 1 +sfdisk -d /dev/vg0/snap.win_test.disk > /mnt/win_test/win_test.disk.sfdisk 
-do +# get MBR and bootloader 
-   # get partition scheme +dd if=/dev/vg0/snap.win_test.disk of=/mnt/win_test/win_test.disk.mbr+bootloader bs=512 count=63
-   sfdisk -d /dev/vg0/win_test.disk$disk > /mnt/win_test/win_test.disk$disk.sfdisk +
-   # get MBR and bootloader +
-   dd if=/dev/vg0/win_test.disk$disk of=/mnt/win_test/win_test.disk$disk.mbr+bootloader bs=512 count=63 +
-done+
 # get domain configuration # get domain configuration
 cp -av /etc/xen/win_test.hvm /mnt/win_test/ cp -av /etc/xen/win_test.hvm /mnt/win_test/
-Do the actual copy +break apart the image. kpartx will create a separate entry in /dev/mapper for each 
-get partition information from disk0 +# partition on the image. The '-v' parameter ensures it tells us what the name is 
-fdisk -/dev/vg0/win_test.disk0 +# so we can use it below 
-for every parition, do the following (I use # to indicate the partition number) +kpartx -av /dev/vg0/snap.win_test.disk 
-ntfsclone --save-image --output - /dev/vg0/win_test.disk0#+# do this for each partition defined by kpartx. Replace the pound sign with the partition name 
 +ntfsclone --save-image --output - /dev/mapper/name_for_each_from_above | pbzip2 -c > /mnt/win_test/win_test_disk#.img.bz2 
 +redo the ntfsclone for each partition, changing the name on input 
 +# and partition number on the output file. 
 +
 +# we're done, so clean up 
 +# remove the kpartx entries in /dev/mapper 
 +kpartx -dv /dev/vg0/snap.win_test.disk 
 +lvremove -f /dev/vg0/snap.win_test.disk
 </code> </code>
  
 +Some points on the process
 +  * If you don't know how much space is going to be used, ntfsresize will give it to you if you just use the --info flag. The number will be off by about 2%, but it helps. <code bash>ntfsresize --info /dev/mapper/name_of_partition</code>
 +  * You do not have to use pbzip2. I like it because it uses all processors, and the syntax is easier than xz (which may give you better compression), it uses all processors (unlike bzip2) and gives better compression than gzip.
 +  * kpartx is really, really useful. Instead of manually doing offsets into an image, kpartx will simply create multiple entries in /dev/mapper. However, it is likely Linux specific; I haven't tried to do this on a FreeBSD system yet.
 +  * If you're running Linux, it is very possible to script this. kpartx has a specific name it uses for its mappings, and xl or virsh can give you the full paths to the block devices.
  
 +===== Links =====
  
-ntfsresize --info /dev/sda1+* https://edoceo.com/dev/ntfsclone-transfer-windows
  
software/ntfsclone.1615182481.txt.gz · Last modified: 2021/03/07 23:48 by rodolico