How to upgrade my HDD and keep my ubuntu 11.10 instalation

Q: hat is the best way to upgrade my 200 gb HDD to a new one of 500 gb but – and this is the tricky part – keep my ubuntu instalation. I curently have 2 partitions hda1 with the ubuntu 11.10 instalation and another partition hda5 with the home folder. On the new HDD I want to keep the same format 1 partition with ubuntu and another with the home folder.


Boot a live CD with both HDDs attached, start the Partition Editor (gparted), copy and paste the partitions from one drive to the other:

  1. In the top right corner select your old hard disk.
  2. Select a partition you want to copy (right-click → “Copy”):
  3. In the top right corner select your new hard disk.
  4. Paste the copied partition into unallocated space (right-click → “Paste”):
  5. Resize if you want (right-click on the partition → “Resize/Move”)

This will keep the unique identifiers of the partitions, so you shouldn’t need to adjust anything after cloning the drive.

The final part is to re-install GRUB:

  1. Note the root partition name of your new HDD (for example /dev/sdb1).
  2. Open a gnome-terminal and run (sorry, I don’t know a GUI way to do it, but it’s just a couple of commands):
    1. sudo mount /dev/sdb1 /mnt
    2. sudo grub-install --root-directory=/mnt /dev/sdb
    3. sudo umount /mnt

    Make sure you use the disk name at the end of point 2!

That’s it, reboot with only your new HDD and you should be fine.

NOTES: Installing GRUB using grub-install (

For information on where GRUB should be installed on PC BIOS platforms, see BIOS installation.

In order to install GRUB under a UNIX-like OS (such as GNU), invoke the program grub-install (see Invoking grub-install) as the superuser (root).

The usage is basically very simple. You only need to specify one argument to the program, namely, where to install the boot loader. The argument has to be either a device file (like ‘/dev/hda’). For example, under Linux the following will install GRUB into the MBR of the first IDE disk:

# grub-install /dev/hda

Likewise, under GNU/Hurd, this has the same effect:

# grub-install /dev/hd0

But all the above examples assume that GRUB should put images under the /boot directory. If you want GRUB to put images under a directory other than /boot, you need to specify the option –boot-directory. The typical usage is that you create a GRUB boot floppy with a filesystem. Here is an example:

# mke2fs /dev/fd0
# mount -t ext2 /dev/fd0 /mnt
# mkdir /mnt/boot
# grub-install --boot-directory=/mnt/boot /dev/fd0
# umount /mnt

Some BIOSes have a bug of exposing the first partition of a USB drive as a floppy instead of exposing the USB drive as a hard disk (they call it “USB-FDD” boot). In such cases, you need to install like this:

# losetup /dev/loop0 /dev/sdb1
# mount /dev/loop0 /mnt/usb
# grub-install --boot-directory=/mnt/usb/bugbios --force --allow-floppy /dev/loop0

This install doesn’t conflict with standard install as long as they are in separate directories.

Note that grub-install is actually just a shell script and the real task is done by grub-mkimage and grub-setup. Therefore, you may run those commands directly to install GRUB, without using grub-install. Don’t do that, however, unless you are very familiar with the internals of GRUB. Installing a boot loader on a running OS may be extremely dangerous.

Some advise: Do backups first! Only run one operation at a time and not all at once (so: copy → (resize) → copy → …).