Shifting to a new hard drive (using Ubuntu Live CD)

I needed to shift the contents, bit for bit, from a 1TB HDD to a 1.5TB HDD. The process takes several hours and may be best completed as an over-nighter.

Boot into a Ubuntu Live CD
Choose to Try It (not Install It)
Applications>Accessories>Terminal
sudo su (so we don’t have to use sudo all the time)
cfdisk /dev/sda (so we can see which HDD is which – it is VERY important to get the source and destination details the right way around)
cfdisk /dev/sdb (in my case it was 1.5TB and had no partitions so sdb was the destination for me. NB to get this the right way around)
dd if=/dev/sda of=/dev/sdb bs=30M & (‘dd’ for disk duplicator; ‘if’ is the source – ‘if’ for input file; ‘of’ is the destination – ‘of’ for output file; bs is block size and I chose 30M; & so the process runs in the background without feedback)

To get feedback as the process runs we use the scary command “kill”, but only as USR1. All this does is say Hi to the process and we hear back how long it has been running and how much it has processed.

My process number was 4569 but yours will be different:

kill -USR1 4569

At the end there will be a message about the task, and the kill command will be told the process is not running any more.

In my case I also wanted to change to ext4, delete the swap partition on the new (1.5TB) HDD, resize the partition on the new HDD, resize the file system on the new HDD, and create a swapfile.

The best and easiest way to do this is probably to use gparted from within the live CD.

System>Administration>GParted Partition Editor

From this point on, use advice at own risk:

OK – the destination disk is potentially 1.5 TB but it is currently only making 1TB available. We need to delete the partition, then create a new one (which should start at the same position).

cfdisk /dev/sdb (the destination, which might be a in your case)

cfdisk

d for Delete to remove the appropriate partition
n for New to make a new one
p for primary
Enter to accept size suggested
b to set the disk as bootable (will show up under flags)
A capital W for write and then yes to confirm (not y but yes)
q to quit

NB make sure the drive you want to modify is unmounted (to prevent severe damage).

May need to reboot to read everything properly.

e2fsck -f /dev/sdb1 (the destination, which might be a in your case)

Re: e2fsck see e2fsck(8) – Linux man page
-f Force checking even if the file system seems clean.
-y might also be useful: Assume an answer of ‘yes’ to all questions; allows e2fsck to be used non-interactively

resize2fs /dev/sdb1 (the destination, which might be a in your case)

The next instructions must be treated with caution as they are my recollection of the steps taken.

Open and edit /etc/fstab

The column headings are: file system, mount point, type, options, dump, pass

Where I saw ext3 I changed it to ext4:

UUID= .../ ext4 relatime,errors=remount-ro 0 1

I commented out the swap UUID:

#UUID=... none swap sw 0 0

And added a swapfile line:

/swapfile none swap sw 0 0

After Ubuntu upgraded the kernel later on I needed to reboot into the old kernel and run:

sudo update-grub

to be able to boot in an ext4 system.

Everything is working well and there were no issues when I upgraded from Lucid to Maverick a few weeks later.