Cloning multiple partitions in Ubuntu
Solution 1:
Just dd
the section of the disk that goes from the start of the disk to the end of the last partition.
In your case the last partition is /dev/sdb3
, so:
- Find
/dev/sdb3
's end usingsudo fdisk -l /dev/sdb
(End
column); -
dd
the section of the drive that goes from the start of the disk to the end of/dev/sdb3
(let's assume that the end of/dev/sdb3
is on byte 50000000000 and that the target drive is/dev/sdc
for the sake of the example):sudo dd if=/dev/sdb | head -c 50000000000 | sudo tee /dev/sdc
Solution 2:
I was able to clone to a smaller drive by the following steps:
Before doing this I prepared the destination disk by creating a replica of the source partition table on the destination disk as described by Malte Skoruppa here. (essentially you make the same size partitions on the destination drive before cloning). I used Gparted for this.
The method of cloning was to plug in an external drive that had working clone of my original install and copy that using:
sudo -s
dd if=/dev/sda1 of=/dev/sdb1 & pid=$!
while kill -USR1 $pid; do sleep 1; done
dd if=/dev/sda2 of=/dev/sdb2 & pid=$!
while kill -USR1 $pid; do sleep 1; done
(this will give you the output as the data is copied)
Next was to reinstall GRUB which would also need to be configured, so I booted up in BOOT-Repair LIVE to fix GRUB. I selected ADVANCED mode to reinstall GRUB and purge the old one.
See also my thread HERE So with the help of many wise Ubuntu gurus I was able to acomplish cloning onto a smaller drive. Thank you to all who contributed.