Dd: larger disk to smaller disk
15
As others have mentioned here using just dd won't work due to the copy of the GPT table placed at the end of the disk.
I have managed to perform a migration to a smaller drive using the following method:
First - boot into liveCD distro of your choice.
Resize the source drive partitions to indeed fit within the smaller drive's constraints (using gparted for example). Then, assuming sda is the source disk, using sgdisk, first create a backup of GPT table from the source drive to be on the safe side: `
sgdisk -b=gpt.bak.bin /dev/sda
Assuming sdb is the target, replicate the table from the source drive to the target:
sgdisk -R=/dev/sdb /dev/sda
sgdisk will now complain that it tried placing the header copy out of the bounds of the target disk, but then will fallback and place the header correctly at the upper bound of the target disk.
Verify that a correct clone of the partition table has been created on the target drive using the tool of your choice (gparted for example).
Using dd, copy each partition from the source drive to the target:
dd if=/dev/sda1 of=/dev/sdb1 bs=1M conv=sync,noerror,notrunc status=progress dd if=/dev/sda2 of=/dev/sdb2 bs=1M conv=sync,noerror,notrunc status=progress dd if=/dev/sda3 of=/dev/sdb3 bs=1M conv=sync,noerror,notrunc status=progress etc...
Obviously, if you mix up the names of the drives when replicating the GPT partition table without a backup or when dding the content you can kiss your content goodbye :)