Friday, July 18, 2008

Hard Drive upgrade and Gparted

I spent a little time last week working with parted. Parted and Gparted, the GUI driven version of parted, is a partition editor (for creating, destroying, resizing, checking and copying partitions, and the file systems). When I worked with parted last week it was to repartition compact flash images for use on an embedded system. I'm still not clear on how to use the CLI parted for repartitioning but I've had very good luck with gparted. This week it was so I could upgrade my laptop's drive from a 40G drive (25G for Windows, 14G for Ubuntu). Living with the 14G reserved for Linux was getting difficult. I need space for my homework and my home automation development projects. I was actually living with 1 - 1.5G of free space and that gets eaten up very quickly when you start working with compact flash images (128 - 256M). So I sprang for a new drive, a 250G drive (I also have another 512M of RAM on the way). Now that the upgrade went well I can add the Java SDK (J2SE, J2EE and J2ME) along with the custom distribution I'm working on.

The good news is that this wasn't difficult to do. First thing I did was to backup the existing 40G drive (/dev/sda) to an external 40G USB drive (/dev/sdb). I used a bootable CD so there was no access to the hard drives (not mounted and no swap turned on) and to minimize ram usage. Here's the first command I used once I booted from the CD:

 # dd if=/dev/sda of=/dev/sdb bs=32768 

I need the external USB drive because I couldn't hook up both the 40G laptop drive and the 250G laptop drive at the same time (I couldn't find the correct adapters). Next I shutdown, replace the 40G drive with the 250G drive. I then booted back up with the CD and copied the external 40G to the new 250G drive.

 # dd if=/dev/sdb of=/dev/sda bs=32768 

I'd like to point out here that if the external drive had been larger than the original 40G drive I'd now be copying more than 40G worth of data to the new drive though I only needed the 40G of data. You can use the appropriate options to dd to only copy what you need. Once I completed the copy, using dd, I unmounted all the hard drive file systems and removed the external drive. At this point the new drive is bootable but you'll only see the 40G of useable space. The extra 210G is unformatted but I could have formated it as ext3 (my FS of choice) and just mounted it as a new file system. But that's not what I wanted.

So I started up gparted and something mounted the file systems (grrr!), so I manually unmounted them again. I also turned swap off (swapoff). I observed that I had three partitions (kind of). I had the initial 25G - NTFS (Windows), the 14G - Linux root partition and the swap partition (an extended partition). I also had a lot of unformatted space. Since I had the original data backed up on two drives I decided that I was going to remove the extended partition. The swap partition was in the extended partition so I removed it first. I then removed the extended partition, applied every thing (the changes won't take effect until you apply them) and waited. At this point gparted (or something) remounted my partitions and I unmounted them again. I knew they were mounted because new Nautilus sessions would open up (this was very annoying and I think it was Ubuntu doing this). Finally I resized the existing Linux partition leaving 2G (2048) above it for the new swap partition (I have 512M of RAM now but 512M more is on the way). I applied the changes and let it go. After a long while (it was very busy) it completed. I now added the swap to the remaining space and applied it. Once done I exited gparted and rebooted the system. When I rebooted I had a working system and no files appear to be missing. This whole process took several hours (from copying the drives to the final reboot). Over all that wasn't painless (dang remounting file systems, grrr) but it wasn't difficult either. Next task is to move the Fedora serv er over to Centos. That I'm sure will be a major undertaking and work for another day (I have a second computer for that).

Labels: , , ,

3 Comments:

At 7/18/2008 5:04 PM, Anonymous Ed D said...

I think you need to look in System->Preferences->Removable Drives and Media. At least, that's what it's called on Gutsy Gibbon.

 
At 7/18/2008 7:28 PM, Blogger Neil Cherry said...

I'm not sure I follow? Is this about the auto-mount problem? I followed those menus and all I could find was something about "Import digital photos when connected". Everything else was turned off.

 
At 7/30/2008 8:14 AM, Anonymous Ed D said...

Oops, sorry for the delay.

Yes, it was about auto-mount. The "Import digitial photos..." bit is under the Cameras tab. The check boxes I had in mind are "Mount removable drives when hot-plugged" and "Mount removable media when inserted" which are under the Storage tab.

 

Post a Comment

<< Home