[How-To] Move your Ubuntu Installation to new hard-drive

I had some hard-drive free space constraints and bought a new 500GB one. Now I wanted to transfer/migrate my current installation to the new hard-drive. Here’s how to do it.

First we need to copy the complete filesystem to the new drive. Connect both the drives to your computer and boot using ubuntu live cd. We need to boot using live cd because we can’t copy the filesystem while booted into it.

Mount both the partitions, that is – your older root partition and the newer root partition (I assume you have already partitioned your drive).

sudo mkdir /media/old
sudo mkdir /media/new
sudo mount /dev/sda7 /media/old
sudo mount /dev/sdb7 /media/new

Now copy using rsync.

rsync -ax /media/old /media/new

This will take much time as it will copy all the data to your new drive/partition.

After this, you’ll still have to setup your MBR (master boot record). For that you’ll need to install Grub on your new drive. Click here to find about how to setup grub.

Recovering GRUB2 after hard-drive upgrade

I upgraded to a 500GB hard-drive and installed windows 7 on it. I then moved my current ubuntu installation from the older HDD to the newer one on another partition, but of course there was no bootloader to load it. I had GRUB2 on older hard drive. I googled about how to recover GRUB2 but couldn’t find one. All I could find was solutions to fix corrupt Grub. So, I just reinstalled grub and then upgraded it to Grub2.

Here’s how to do it:

Boot into Ubuntu Live CD.
Mount the root disk (Disk on which Ubuntu is installed).

mkdir /media/root
mount /dev/sda7 /media/root

where /dev/sda7 is your disk.

If you don’t know which disk the ubuntu is installed on, you can fdisk

sudo fdisk -l

Now, when you can install grub using grub-install

sudo grub-install --root-directory=/media/root /dev/sda --recheck

This will install the grub on the mounted disk. You can now reboot and get into your Ubuntu and upgrade it to GRUB2.

If this doesn’t work, you will have to change the root to the hard disk and install grub. To do that,

Unmount your boot partition (I’ll take sda7 as the example again) before proceding.

mkdir /mnt/root
mount /dev/sda7 /mnt/root
mount -o bind /proc /mnt/root/proc
mount -o bind /dev /mnt/root/dev
chroot /mnt/root

You may need to run these as root/superuser. If successful, you’ll get the terminal access to your boot partition. You can now install the grub using apt-get.

apt-get install grub

But since, this is a new hard-drive, uuid won’t match. Hence, booting will fail.
To address this issue, you can install the grub2 without restarting

apt-get install grub2

Reboot. Grub2 should be installed now.

[Solved] Ath5k wifi module not working in Karmic Koala

I noticed was my wifi (Atheros AR5001/5007EG) stopped working after I upgraded to Karmic Koala. I searched endlessly on Google without any answer. Then, I remembered that Karmic comes with newer kernel 2.6.31. And ath5k kernel module hasn’t been loaded yet into this newer kernel.

So, I simply executed

modprobe ath5k

in the terminal.
And in an instant, I saw my wifi connected to my access point.
The command loaded the module into the kernel.

Hope, this helps.