Difference between revisions of "duplicate a hard drive using dump and restore"
(→perform dump / restore) |
(→prep target drive) |
||
(3 intermediate revisions by one user not shown) | |||
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 |
+ | '''create filesystems''' | ||
+ | # '''mkfs /dev/sdb1''' | ||
+ | # '''mkswap /dev/sdb2''' | ||
+ | Setting up swapspace version 1, size = 2097148 KiB | ||
+ | no label, UUID=29a1c896-1122-4172-b4c7-0213ed4d639c | ||
+ | # '''mkfs.ext3 /dev/sdb3''' | ||
+ | mke2fs 1.42.7 (21-Jan-2013) | ||
+ | Filesystem label= | ||
+ | OS type: Linux | ||
+ | Block size=4096 (log=2) | ||
+ | Fragment size=4096 (log=2) | ||
+ | Stride=0 blocks, Stripe width=0 blocks | ||
+ | 1810432 inodes, 7228622 blocks | ||
+ | 361431 blocks (5.00%) reserved for the super user | ||
+ | First data block=0 | ||
+ | Maximum filesystem blocks=4294967296 | ||
+ | 221 block groups | ||
+ | 32768 blocks per group, 32768 fragments per group | ||
+ | 8192 inodes per group | ||
+ | Superblock backups stored on blocks: | ||
+ | 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, | ||
+ | 4096000 | ||
+ | Allocating group tables: done | ||
+ | Writing inode tables: done | ||
+ | Creating journal (32768 blocks): done | ||
+ | Writing superblocks and filesystem accounting information: done | ||
== perform dump / restore == | == perform dump / restore == | ||
Line 48: | Line 74: | ||
# '''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) | ||
Line 95: | Line 123: | ||
# '''dump -0 -f - / | restore -r -f -''' | # '''dump -0 -f - / | restore -r -f -''' | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
DUMP: WARNING: no file `/etc/dumpdates' | DUMP: WARNING: no file `/etc/dumpdates' | ||
DUMP: Date of this level 0 dump: Tue Apr 29 15:45:46 2014 | DUMP: Date of this level 0 dump: Tue Apr 29 15:45:46 2014 |
Latest revision as of 14:50, 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
create filesystems
# mkfs /dev/sdb1 # mkswap /dev/sdb2 Setting up swapspace version 1, size = 2097148 KiB no label, UUID=29a1c896-1122-4172-b4c7-0213ed4d639c # mkfs.ext3 /dev/sdb3 mke2fs 1.42.7 (21-Jan-2013) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 1810432 inodes, 7228622 blocks 361431 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=4294967296 221 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done
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