Your Ubuntu Linux installation is getting bigger and bigger and you are running out of space on your hard disk. You got your new hard drive and now you need to clone your old drive to the new one. The dreaded cloning is actually quite easy and relatively simple to do. The only thing you will need is a little patience and some typing skills. No special software just your already installed Ubuntu Linux.
The regular obligatory disclaimer: This procedure worked for me several times, I use it almost on a daily basis and I had no problems with it. Your mileage my vary. Make sure you double check all the commands that you type and that you do not format your data drive. You will end up with two empty disks. If you have any questions feel free to ask.
The very basic scenario is assumed here. You have one hard drive installed as /dev/sda and you want to replace it with a new one. You could just add the new drive and mount it to /home directory for example, but sometimes that is not what you want. I am also assuming that you have SATA drives. This procedure can also be used if you get a new computer and you do not want to bother with new installation. In this case you will have to be more careful if you are moving from one platform to another.
Step 0 – Prerequisites
First make sure that you have all the software installed:
$ sudo apt-get install grub-pc rsync
Yes, that is it.
Step 0.5 – Disk juggling
Turn off your computer, connect your new hard drive and turn your computer back on. Make sure that you do not disconnect the old drive, you still need it. ;)
Step 1 – Partitioning, formatting and mounting
Check where your new drive is, it will usually be accessible as /dev/sdb. Use fdisk to partition the hard drive and then mkfs to format it. If you created more than one partition then you will have to mount all of them. In this example the unknown user created swap, root and home partitions. Here’s how you mount them:
$ sudo mount /dev/sdb2 /mnt $ sudo mkdir /mnt/home $ sudo mount /dev/sdb3 /mnt $ sudo mkswap /dev/sdb1
Step 2 – Cloning
After your new partitions are mounted you need to copy all your data to the new location. You will do this with rsync.
$ sudo rsync --exclude="mnt" --exclude="lost+found" --exclude="sys" --exclude="proc" -avP / /mnt/ $ sudo mkdir /mnt/mnt /mnt/proc /mnt/sys
No need to copy /proc and /sys, they are virtual file systems and they will be created later on. You still need to create the directories that were not copied.
Step 3 – Rescuing the system
Data is transferred and now you need to take care of few other minor details. In /mnt/etc/fstab you will have to change the UUID string for mounting the partitions. I suggest that you replace UUID with /dev/sda2 for root disk and /dev/sda3 for /home. This will vary depending on your configuration. If you are feeling adventurous you can find the UUID’s of your new partitions and replace the old ones with them. Use the blkid command to get the UUID for each partition.
$ sudo blkid -p -o full /dev/sdb2 /dev/sdb2: UUID="1a78c1f3-d9d0-4bbc-8dc2-603c2b46f5fc" VERSION="1.0" TYPE="ext4" USAGE="filesystem" $ sudo blkid -p -o full /dev/sdb3 /dev/sdb3: UUID="7f5a59ae-43c2-4747-a369-6fc01244ee21" VERSION="1.0" TYPE="ext4" USAGE="filesystem"
Now just copy and paste the UUID into /mnt/etc/fstab.
If you are cloning your disk to be used on a different computer then you should also take care of network interfaces. Delete the last line, or the last two, depends on how many network interfaces you have, in /etc/udev/rules.d/70-persistent-net.rules file. The lines should look roughly like this:
# PCI device 0x8086:0x294c (e1000e) SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="xx:xx:xx:xx:xx:xx", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
I will not go into details here, let’s just say that Ubuntu will remember what names were used for your network interfaces and when you boot into the new system you will end up having eth1 instead of eth0.
Don’t worry, the lines will be back once you reboot your system. After this you can shutdown and disconnect the old drive. Now turn on your computer and boot into a non working system. Have no fear, you will get it fixed in no time.
Step 4 – First boot
Your boot loader will die. Don’t worry it was supposed to, because it doesn’t know what to boot from and where your new disk is. What you see now is a Grub rescue shell. Does it say on the screen that you can use help? Lovely, because you can’t, Grub still didn’t load the help. Now you have to boot your computer manually. Like this:
insmod /boot/grub/linux.mod linux /vmlinuz root=/dev/sda2 ro initrd /initrd.img boot
First you load the Linux module so that you can tell Grub where to find Linux kernel and initial ram disk. Then you can boot. If you have your root partition on /dev/sda2 then you should see your computer rebooting. After you login, open a terminal so that you can fix Grub:
$ sudo update-grub $ sudo grub-install /dev/sda $ sudo reboot
Step 5 – Second Reboot & The End
After the reboot everything should be back to normal. If you are again stuck at the Grub rescue prompt, then repeat the above procedure with Grub and rerun update-grub and grub-install. As you can see, cloning disk isn’t not so hard and you don’t need any special tools or software, except your beloved Ubuntu Linux.


I just finished moving my Ubuntu installation from the original harddisk in my laptop to the new SSD. I had done the rsync beforehand, but when looking at the fstab and grub issues I found this page.
Your description is great.
There is a missing detail though: for the first boot, I needed to specify “boot (hd0,1)” [in my case it was /dev/sda1, in your example with /dev/sda2 it would be (hd0,2)] before insmod, as otherwise it could not find the files. Then I got “linux is already loaded” when I tried insmod, so maybe that step would not be necessary. The rest went exactly as you said, and now I’m writing this from the new system.
I think the rsync command isn’t quite right; it will fail to clone things like /usr/include/sys
You might be onto something. I’ll have to re-check this. However, I didn’t have any problems with it, maybe I never accessed /usr/include/sys. :)
Wow, thanks a ton! Worked great with 10.04
extramarks (a study material software) install in ubunto 11 , after cloning to new hardisk , new hdd not loging to ubunto, and software extramark displays ” you r not authorised”
please help me……..
there may be uuid problen to new hdd, i think but , extramarks software (an interactive school studymaterial guide) should work,but it is not opening , the clone hdd is working by booting through pendrive in that same old hardware , but on different hareware it displays ” you are not authorised”
please help me, i have bought this expensive software…..