Difference between revisions of "duplicate a hard drive using dump and restore"
(→perform dump / restore) |
|||
Line 38: | Line 38: | ||
Disk identifier: 0x01a8acb1 | Disk identifier: 0x01a8acb1 | ||
<br> Device Boot Start End Blocks Id System | <br> Device Boot Start End Blocks Id System | ||
− | /dev/ | + | /dev/sdb1 2048 133119 65536 83 Linux |
− | /dev/ | + | /dev/sdb2 133120 16910335 8388608 82 Linux swap / Solaris |
− | /dev/ | + | /dev/sdb3 16910336 121767935 52428800 83 Linux |
Line 48: | Line 48: | ||
# '''mkdir /mnt/sdb1''' | # '''mkdir /mnt/sdb1''' | ||
− | # '''mkdir /mnt/ | + | # '''mkdir /mnt/sdb3''' |
+ | |||
+ | note: we are skipping the swap partition as there is no point in duplicating data there | ||
dump first partition (in this example boot) | dump first partition (in this example boot) |
Revision as of 14:06, 30 June 2014
This guide will show you how to duplicate a hard drive's running, mounted filesystems to another drive.
source drive = /dev/sda target drive = /dev/sdb
prep target drive
create the partitions and filesystems on the destination hard drive
from the restore man page...
Restore (rebuild) a file system. The target file system should be made pristine with mke2fs(8), mounted, and the user cd'd into the pristine file system before starting the restoration of the initial level 0 backup.
list source drive partion info
# fdisk -l /dev/sda
Disk /dev/sda: 64.0 GB, 64023257088 bytes, 125045424 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 Disk identifier: 0x77804419
Device Boot Start End Blocks Id System /dev/sda1 * 2048 133119 65536 83 Linux /dev/sda2 133120 16910335 8388608 82 Linux swap / Solaris /dev/sda3 16910336 121767935 52428800 83 Linux
duplicate the partition info above on the target drive
one limitation of using dump / restore is that the filesystem geometry must match between the source and the target drives. I use fdisk to do this. The steps aren't included here. When done your target drive partions should match the source above.
example:
# fdisk -l /dev/sdb
Disk /dev/sde: 80.0 GB, 80026361856 bytes, 156301488 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 Disk identifier: 0x01a8acb1
Device Boot Start End Blocks Id System /dev/sdb1 2048 133119 65536 83 Linux /dev/sdb2 133120 16910335 8388608 82 Linux swap / Solaris /dev/sdb3 16910336 121767935 52428800 83 Linux
perform dump / restore
make temporary mount points
# mkdir /mnt/sdb1 # mkdir /mnt/sdb3
note: we are skipping the swap partition as there is no point in duplicating data there
dump first partition (in this example boot)
# mount /dev/sdb1 /mnt/sdb1 # cd /mnt/sdb1 # dump -0 -f - /boot | restore -r -f - DUMP: WARNING: no file `/etc/dumpdates' DUMP: Date of this level 0 dump: Tue Apr 29 15:45:03 2014 DUMP: Dumping /dev/sda1 (/boot) to standard output DUMP: Label: none DUMP: Writing 10 Kilobyte records DUMP: mapping (Pass I) [regular files] DUMP: mapping (Pass II) [directories] DUMP: estimated 24536 blocks. DUMP: Volume 1 started with block 1 at: Tue Apr 29 15:45:03 2014 DUMP: dumping (Pass III) [directories] DUMP: dumping (Pass IV) [regular files] DUMP: Volume 1 completed at: Tue Apr 29 15:45:03 2014 DUMP: Volume 1 24580 blocks (24.00MB) DUMP: 24580 blocks (24.00MB) DUMP: finished in less than a second DUMP: Date of this level 0 dump: Tue Apr 29 15:45:03 2014 DUMP: Date this dump completed: Tue Apr 29 15:45:03 2014 DUMP: Average transfer rate: 0 kB/s DUMP: DUMP IS DONE
look at my pretty files
# ls -1 System.map-genkernel-x86_64-3.10.17-gentoo System.map-genkernel-x86_64-3.7.9-gentoo boot grub initramfs initramfs-genkernel-x86_64-3.10.17-gentoo initramfs-genkernel-x86_64-3.7.9-gentoo ...
now for the good stuff, dumping a running root filesystem!
mount and cd to restore point on the target drive
# mount /dev/sdb3 /mnt/sdb3 # cd /mnt/sdb3
dump and restore files
# dump -0 -f - / | restore -r -f - DUMP: WARNING: no file `/etc/dumpdates' DUMP: Date of this level 0 dump: Tue Apr 29 15:45:46 2014 DUMP: Dumping /dev/sda3 (/) to standard output DUMP: Label: none DUMP: Writing 10 Kilobyte records DUMP: mapping (Pass I) [regular files] DUMP: mapping (Pass II) [directories] DUMP: estimated 14965465 blocks. DUMP: Volume 1 started with block 1 at: Tue Apr 29 15:45:54 2014 DUMP: dumping (Pass III) [directories] DUMP: dumping (Pass IV) [regular files] DUMP: 36.90% done at 18406 kB/s, finished in 0:08 DUMP: 77.94% done at 19441 kB/s, finished in 0:02 DUMP: 98.49% done at 16232 kB/s, finished in 0:00 DUMP: Volume 1 completed at: Tue Apr 29 16:01:38 2014 DUMP: Volume 1 14918960 blocks (14569.30MB) DUMP: Volume 1 took 0:15:44 DUMP: Volume 1 transfer rate: 15803 kB/s DUMP: 14918960 blocks (14569.30MB) DUMP: finished in 944 seconds, throughput 15803 kBytes/sec DUMP: Date of this level 0 dump: Tue Apr 29 15:45:46 2014 DUMP: Date this dump completed: Tue Apr 29 16:01:38 2014 DUMP: Average transfer rate: 15803 kB/s DUMP: DUMP IS DONE