$ hdparm -I /dev/sda $ hdparm -I /dev/sdb
$ gksudo gparted
Now shrink the main partition so that it will fit on the new drive. You may want to restart the computer so the operating system can detect this change in partition before moving on.
dd if=/dev/<old> of=/dev/<new> bs=512k conv=noerror
If you want to see the progress while copying you can run:
dd if=/dev/<old> bs=512k conv=noerror | pv -s 512G | dd of=/dev/<new> bs=512k conv=noerror
You may want to limit the total amount copied by dd:
dd if=/dev/<old> of=/dev/<new> bs=512k conv=noerror count=<number of blocks to copy>
parted /dev/<new> (parted) print Warning: ...bad GPT... Fix/Ignore? Fix (parted) quit
gpartedto blow away the old partitions on the old hard drive. You can tell which is which by the unallocated space on each drive.
The easiest way (albeit a little sketchy) is to change the UUID of the old drive, so that grub won't boot to it and you don't need to update grub at all.
To change the UUID of an ext partition:
tune2fs /dev/<old> -U `uuid`
For the boot partition, things are a tad more complicated. Apparently the way to do this is to manually change the UUID of an
vfat partition. The idea is to copy the raw data that represents the UUID, manually edit it, and then write it back.
First, find the current UUIDs.
Now you need to copy the data (and save a backup while you're at it).
dd if=/dev/<old boot partition> of=~/superblock bs=512 count=1 dd if=/dev/<old boot partition> of=~/superblock_backup bs=512 count=1
Then, you need to use a hexeditor to modify the UUID in the superblock.
hexedit ~/superblock / <search for a byte of the old uuid> <type a number to change a byte of the old uuid> [ctrl+s] save the file [ctrl+c] to exit
Now, if you want to check everything is good, you can compare the two superblock files.
hexdump ~/superblock > ~/s_hex hexdump ~/superblock_backup > ~/s_backup_hex diff ~/s_hex ~/s_backup_hex
You should only see your change to the UUID.
Last you need to write it back.
dd if=~/superblock of=/dev/<old boot partition> bs=512 count=1