The Golem Speaks

Upgrading Ubuntu Hard Drive

Published by Peter Mains on February 12, 2010 at 07:56 PM

Well, it may not have been pretty, but I was able to upgrade the hard drive on my Ubuntu Linux laptop. Hopefully this will save someone else the difficulties I had.

  • I connected my new hard-drive to my existing system using a USB cable.
  • Booted into a live CD of Karmic Koala Ubuntu (9.10) so that my hard drives weren't mounted.
  • Copied the contents of my old hard drive to my new using the dd command.
    • I first had to ascertain the locations of my drives. In my case, /dev/sda was my old hard drive, and /dev/sdb was the new hard drive that I'd connected via USB. These were found using the "sudo fdisk -l" command.
    • The syntax of the dd command was "dd if=/dev/sda of=/dev/sdb"
    • I was able to check dd's progress occasionally by issuing the
  • Shut down my laptop, and physically replaced my old hard drive with my new one.
  • Rebooted, again into the Live CD, and repartitioned my hard drive with GParted.
    • I copied the swap space to the end of the device (visually on the right).
    • Deleted the original swap space partition.
    • Copied the main, partition (in ext3 format) so as to be right next to the new space at the device's end.
    • Deleted the original ext3 partition.
    • Resized the new ext3 partition to fill all the new space I had.
  • Popped Super Grub into my CD-ROM drive, and booted into my new hard drive.
  • Re-installed grub using the instructions found on Super Grub's wiki.

Now, this was not a short process, and there were some pitfalls that I glossed over. For starters, dd and gparted took several hours each. To copy roughly 80GB of files via USB, dd took about 4 or 5 hours.

The first pitfall was trying to repartition while booted into my old hard drive. Since the new hard drive wasn't yet mounted, I figured I'd be able to go into GParted and partition away. Wrong. If you have two identical hard drives and one is mounted, then it just confuses GParted. Both have the same UUID, and that's apparently how GParted identifies devices.

The second pitfall was that I made the mistake of resizing my new ext3 partition twice. First, after I copied it to the far right of the drive, I resized it to take up all of the remaining space. I didn't delete the old ext3 partition, though. When I did and resized again, I was surprised to find that I was waiting an extra 2 or 3 hours. I should have realized that Linux would be moving all of the data again, sector by sector. In fact, it was much worse the second time, because it was moving 160GB of empty space as well.

The third major pitfall is that my newly partitioned drive no longer had grub installed properly! I'm not sure why. It may have been because I aborted my first attempt at doing the disk dump (dd). It may have been that GParted simply ate it. I don't know, because I didn't try to boot into my new hard-drive until after it was partitioned. All I know is that Grub failed to load, and left me with a cryptic "Error 22."

This is where Super Grub came to the rescue. I burned a Super Grub disk, and booted up with it in my CD-ROM. It asked me if I wanted to boot into Ubuntu Linux. I did. Using the sequence of commands found here, I was able to reinstall Grub. (If the link has moved, you want the "GRUB2 solution (Linux shell) (Recommended)" from the Super Grub wiki.) After that, I was able to boot directly into my new hard drive with the Super Grub disk.

Tada!

comments powered by Disqus
Latest Posts
February 07, 2011

Latest Articles
April 09, 2014