Dump partitions to new drive
From Wiki
To clone an existing install to a new drive the file systems must be dumped to the new drive. First, partition the new disk so that the data has a place to go.
fdisk /dev/sdb
Note: The server may need a reboot to see the new partition table
After the drive is ready you can use this script.
#!/bin/bash NEWDRIVE=sdb OLDDRIVE=sda # Create mount points mkdir /mnt/${NEWDRIVE}{1,2,5,6,7,8} # Create file systems PARTS="1 2 5 6 7 8" for part in $PARTS; do mkfs -t ext3 /dev/${NEWDRIVE}${part}; done # Mount them for part in $PARTS; do mount -t ext3 /dev/${NEWDRIVE}${part} /mnt/${NEWDRIVE}${part}; done # Transfer each partition cd /mnt/${NEWDRIVE}1 dump -0uan -f - /boot | restore -r -f - cd /mnt/${NEWDRIVE}2 dump -0uan -f - /usr | restore -r -f - cd /mnt/${NEWDRIVE}5 dump -0uan -f - /var | restore -r -f - cd /mnt/${NEWDRIVE}6 dump -0uan -f - /tmp | restore -r -f - cd /mnt/${NEWDRIVE}7 dump -0uan -f - / | restore -r -f - cd /mnt/${NEWDRIVE}8 dump -0uan -f - /home | restore -r -f - # Apply labels e2label /dev/${NEWDRIVE}1 /boot e2label /dev/${NEWDRIVE}2 /usr e2label /dev/${NEWDRIVE}5 /var e2label /dev/${NEWDRIVE}6 /tmp e2label /dev/${NEWDRIVE}7 / e2label /dev/${NEWDRIVE}8 /home e2label /dev/${OLDDRIVE}1 /boot-old e2label /dev/${OLDDRIVE}2 /usr-old e2label /dev/${OLDDRIVE}5 /var-old e2label /dev/${OLDDRIVE}6 /tmp-old e2label /dev/${OLDDRIVE}7 /-old e2label /dev/${OLDDRIVE}8 /home-old /sbin/grub --no-floppy --batch << EOF root (hd1,0) setup (hd1) EOF echo "Dumping file systems done." echo "grub --no-floppy" echo "root (hd1,0)" echo "setup (hd1)"