This blog is NOFOLLOW Free!
Print This Post Print This Post

The Linux Chronicles – Installing a New Hard Drive


There comes a time in any computer’s life when a larger hard drive is necessary.  In my case, the time came quickly, as I had installed Linux on an old 40 gig drive just to see if I liked it.  I obviously did, hence this series, so a larger drive quickly became a necessity.

I procured a 120 gig drive and started doing my homework to see what was involved in moving to a larger drive.  In the good old days, all one had to do was make the drive bootable (write the boot sector and master boot record) to the drive and then copy everything over using cp or dd or tar.

Alas, things have changed.  In an effort to make drives portable, the Linux developers invented something called the UUID (Unique Unit ID, I think).  It assigns a large random ID number to each drive.  A new drive gets assigned a new UUID when it is made bootable.  The copied-over boot loader (GRUB) is still expecting the old UUID and therefore cannot find the new drive.  A hung boot is the result.  Here’s an article that discusses UUIDs in far more details than you probably want to know about.

If you want to see what the uuid of your drive is, execute the following command from the command prompt (open a terminal window to get the prompt:

$ sudo vol_id -u <device>

where <device> (without the brackets) is the name of the drive.  In my case, my boot drive is /dev/sda1 so the command is

$ sudo vol_id -u /dev/sda1

which produces


Nice friendly and easy-to-remember number, isn’t it?  NOT!

Now one can go hacking around in /etc and /boot and fix up the UUID of a new drive but it is easier and about as fast to simply clone the main partition as I will outline below.

The first thing you need to know is the name of your drive.  To do that, execute the command “mount”

$ mount

It will return something like below.

/dev/sda1 on / type ext3 (rw,relatime,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
/sys on /sys type sysfs (rw,noexec,nosuid,nodev)
varrun on /var/run type tmpfs (rw,noexec,nosuid,nodev,mode=0755)
varlock on /var/lock type tmpfs (rw,noexec,nosuid,nodev,mode=1777)
udev on /dev type tmpfs (rw,mode=0755)
devshm on /dev/shm type tmpfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
lrm on /lib/modules/2.6.24-16-generic/volatile type tmpfs (rw)
securityfs on /sys/kernel/security type securityfs (rw)
none on /proc/fs/vmblock/mountPoint type vmblock (rw)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
gvfs-fuse-daemon on /home/jgd/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=jgd)

All you’re interested in is the root drive which is shown in the first line (bold faced) above.  Ignore everything else.  In my case on this laptop the drive is /dev/sda and the first partition, the main one is /dev/sda1.  This is the partition that we want to clone.  Write down whatever “mount” returns for your system and substitute it for “/dev/sda1” in the procedure that follows.

We’ll use a couple of programs to assist us in this endeavor, both of which either are on the distribution disk (distro) or in the repository that can be accessed with the Synaptics package manager (system->administration->synaptics package manager).  The programs are:

Partimage – copies a partition to another drive and stores it in a single file.  It also restores that partition when commanded

GParted – the GNU partition editor.  This utility enables us to resize partitions on the fly.  We’ll be using the one that came on the distro disk (system->administration->Partition Editor).  It is important to use this one, as other versions such as the one in the repository won’t work.

Note: you do not need to download from the above links. I included them for reference only.

In the procedure below we’ll be working with a laptop.  If yours is a desktop machine, simply substitute your first drive for “drive bay”.

You’ll need something to mount the old drive on.  With my laptop, that was a USB adapter.  If you have multiple drive bays in your desktop, simply substitute another drive bay for “USB adapter”.  Even with a desktop machine, however, a USB adapter is very handy to use since you don’t have to open up your machine or shut it down to connect or disconnect drives.

Without further ado, here is the step by step procedure.

  1. Place the new 120 gig drive in the laptop bay, put the distro disc in the CD drive and boot from the distro disk.  Boot to the desktop and choose “install”
  2. Let the install run its course.  Shut down the system.  A virgin Ubuntu system is now installed on the new drive.
  3. Install the old drive on a USB adapter.  Boot the new drive to the virgin Ubuntu system.  Make sure the distro disc is removed from the CD.
  4. Go to Synaptics and fetch partimage.  This is a program that copies an exact copy of a partition.
  5. The old drive on the USB adapter is /dev/sdb.  The first partition is /dev/sdb1. (note: substitute whatever location your old drive is in for /dev/sdb using the “mount” command to discover it)
  6. Get a command prompt and start up PartImage.
    $ partimage

    Select /dev/sdb1.  Select a destination on another hard drive large enough to hold the image.  I chose the 400 gig drive (one of my USB drives that is always connected to my system).  Follow the menus and start the clone.  Go away for 3 hours or so, depending on how full the old drive is.  When the program finishes, there will be an image of the old drive’s partition in a file on the 400gig drive.  Shut down the system

  7. Place the new drive on the USB adapter and the old drive back in the laptop’s drive bay.  Boot.  Run PartImage again.  Select /dev/sdb1 and “restore” mode.  Write the image to the new drive.  This takes about an hour and a half.  Shut the system down.
  8. Install the new drive in the drive bay and lay the old drive aside.  Put the distro CD in the drive and boot from it.
  9. At this point the new drive has the old drive’s data on it but the partition size is that of the old drive.  In my case the old drive was 40 gig and the new 120.  The new drive’s first partition still looks like a 40 gig partition. We must expand it.
  10. With the distro CD booted, select system->administration->partition editor.  The drive to change is on /dev/sda and the partition is the first one, /dev/sda1.  Note:  This program takes about 3 minutes to start during which time it shows no indication of life.  You’ll think that the program has hung.  It hasn’t.
  11. Select the first partition (/dev/sda1 and choose “resize”.  It may indicate that it is already the same size as the drive.  Don’t believe it.  If the partition is still small, change it to the maximum available.  If the partition indicates that it is already large, change it by a tiny amount, say, 1Mb, just enough to enable the “resize” button.  Hit “apply”.  This process takes about 5 minutes.
  12. Shutdown.  Remove the distro CD and boot from the new drive.  Check the new size with the “df -h” command.  It should show the full drive size.  Congrats.  You’ve just installed your new drive.

See, that wasn’t difficult – much easier than futzing around in windows.

Posted by neonjohn on February 17th, 2009 under Computing

3 Responses to “The Linux Chronicles – Installing a New Hard Drive”

  1. Toby Says:

    I’ve always seen UUID defined as “universally unique ID” along the same lines as the GUID’s (globally unique ID’s) seen frequently in the Windows world. Randomly generated in a way that’s supposed to make it essentially impossible that any other computer would ever generate the same ID.

    One big advantage to using them to identify drives and partitions is supposed to be that you can move drives around between different controller channels and device IDs and still have their contents get mounted in the right place in the filesystem. Whereas the “old” way of doing things would have stuff end up in the wrong place in that scenario.

  2. Cliff Says:

    Damn John … you are definently getting into Linux. Good … cuz I need HELP! (all caps, notice?) I’ve just thrown in the towell and gone back to BG’s VirusWare. Frank Tabor and I are talking via email. Hey, when was the last time you came up for air, worked on sumptin else? Go camping? Fix a generator? Cook some Pig? Try to make a refrigerator fly? I’ll be home soon, you need to plan some downtime, come to the Cave, have a nice cuppa tea or coffee and kick back and relax, then we’ll have a “small” wine, and talk Linux, fishin’, squirrels, rednecks, WOMEN! You know, the Important Stuff! Cj of Cj and M

  3. Rob Morgan Says:

    Just found neon-john by accident today. Tried his e-mail which didn’t work. Once worked with him. Any info will be greatly appreciated.

Leave a Comment

Comments links could be nofollow free.


  • Meta