Messing with hard drives

Hard disk dissection
Copying these isn't that simple

I’ve been randomly offline a lot over the last few days. Partially because I’ve been visiting friends and family, partially as I’ve been migrating hard drives in my laptop. Again.

Currently I run Windows XP and Ubuntu Jaunty Jackalope (9.04) – predominantly the latter, though I keep the former around for a couple of utilities and for checking things when I’m doing support. I’ve also decided I want to install the Windows 7 release candidate I downloaded. However, disc space wouldn’t let me do that without ditching one of the other OS‘s so I turned to Amazon and ordered a 160Gb ATA drive (the largest available in 2.5″ format, I think) and an external caddy into which to place the soon-to-be-spare 120Gb device.

The procedure should be simple with the right tools:

  1. Attach new hard drive via USB
  2. Mirror internal 120Gb onto USB 160Gb
  3. Use some partition software to increase the size of data partition, leaving space for Windows 7 install
  4. Remove 120Gb and swap it with the 160Gb which becomes my internal drive

Of course, these are computers. So it wasn’t going to go smoothly. Especially with the mixed operating systems.

First up, the hard drive enclosure I bought didn’t seem to like the 160Gb drive. If I connected it under Ubuntu, it detected it fine. Windows, however, did not. It “bing”ed to say a USB device had been attached, then never let me see it. Not even through Disk Manager so it wasn’t the fact that it was empty. I couldn’t even create a partition. If I rebooted the machine while the device was attached, the reboot stalled on the BIOS screen.

I disassembled another enclosure I have and tried that with more success. Reboots were fine and the drive was detected under both OSs. Hopefully the new enclosure would have more success with the older 120Gb drive I was soon to have spare.

Next step was to mirror the drive. I tried Paragon Partition Manager’s imaging (which has worked for me in the past), but it kept getting partway through and then rebooting with only a fraction of the drive copied. I began to worry about the new disc, but an attempted surface scan looked like taking 24 hours+.

Instead, I downloaded the (simple and free) Easus Disk Copy program. Burn the ISO onto a CD, reboot with the disc in the drive and away you go.

Slowly. Very slowly indeed.

The initial estimated time was around an hour. The copy eventually took a smidgen under 21 hours.

I had planned on using GParted to shift the partitions around, but it seems it’s not capable of doing this. What I needed to do was to alot roughly half of the increased 40Gb to my FAT32 data partition and leave the rest unallocated so that Win7 could use this when I installed it. So, back into XP and Partition Manager Pro for this task.

Before the repartitioning would complete, I had to run checkdisk on the two FAT32 source drives. On my copy run, it had to come up with read errors. In all, there were 200 and PMP would not continue until these were cleared.

So off I went to play Lego Batman and Guitar Here while the checks and the data migration occured. Finally I had a hard disc with everything organised as required. Phew.

Out with the old, in with the new, reboot… and a screen full of flickering “GRUB“s. No boot menu, no progress. Ah. By moving all the partitions around, I’d shafted GRUB. And possibly the MBR on the boot drive. Here’s where it got technical.

Step one was to repair the MBR and this is where having a bootable CD/DVD with your operating system on is very useful. Laptop manufacturers can burn in Hell if they don’t supply these. If you don’t have one, download it via a Torrent. You’ve paid for a license, there’s nothing wrong in having a copied disc with the software on in case you need to fix it.

Quickly boot off the Windows CD, go to the recovery console, boot into the Windows install on the C: and run one command:

fixmbr

It takes less than a second and on reboot, the PC went right into Windows. A step forward, but still no GRUB so I couldn’t access Ubuntu. Out with the 8.10 CD that I have kicking around, and into a Live session. With a terminal open, the commands to fix things weren’t too hard (thankfully).

sudo grub
root (hd0,5)
setup (hd0)

Well, it would have been nice if it were that simple. First of all, finding the correct partition to use in “root” takes a little digging.

As I’d jiggled things around, what had been (0,4) in my old setup had been changed to (0,5) – this can be discovered by running the command:

sudo fdisk -lu

Assuming you only have one Linux install, only one of these will be labelled “Linux”. Take the number “x” from the left column “/dev/sdax”.

That gave me (0,5) as I used. However, I then got an “Error 12: Invalid device requested” when running the “setup” command. A lot of digging online got me a solution to this. First “quit” out of the grub program to the command prompt again. Then:

sudo fdisk /dev/sda

At the prompt that comes up, enter “w” (no quotes) and hit return. Then repeat the grub commands listed above.

Finally:

sudo gedit /dev/sda/boot/grub/menu.lst

And ensure all the menu entries are correct. As I said, I had to change all my (0,4)s to (0,5)s.

Save, reboot, clap with glee.

Next step is to install Win7, which is tomorrow’s little job. I fully expect to have to repair GRUB again afterwards. Windows (all versions) has a habit of deciding that all other boot loaders are “wrong” and places itself before them. At least I’m expecting it!

Reblog this post [with Zemanta]

Subscribe
Notify of
guest

4 Comments
Inline Feedbacks
View all comments
Dale

Hi Iain,

Not 2 days ago, I did a very similar thing. My laptop has a 60GB Drive with 3 partitions, and I was replacing it with a 120GB Drive, whilst increasing the 2nd partition to cover the full space. (I could have easily left it for an extra partition). Here is what I did:

1. Install Jaunty to a USB Stick (See http://www.pendrivelinux.com)
2. Boot using the USB stick, you have a full Ubuntu distro running.
3. Plug the 120GB Drive via a caddy into USB
4. Start Gparted.
5. Using Gparted, Use the copy and paste functions, moving between devices (The paste function is brilliant, it allows you to say how much space to leave before AND after each partition. I.E. Where on the physical drive you want the partition!):
A) Copy /dev/sda1, paste it onto /dev/sdc (sdb was the pen drive!)
B) Copy /dev/sda2, paste it onto /dev/sdc
C) Copy /dev/sda3 (An NTFS partition which worked fine!). This time I pasted it to the END of the 120GB Drive (0 MB AFTER the end)
D) Resize /dev/sdc2 to fill up the gap left.
E) Start

About 2 hours later it was done. BUT I had 2 easy problems to fix.
The copy and paste had NOT copied the partition flags. So I had to set /dev/sdc2 to BOOT and LBA as they are on the original drive.
Finally install “install-mbr”. Then replace the mbr so that it boots of the BOOT partition (This laptop is not duel boot), but I could have easily installed GRUB instaed.

Switch drives, boot. Ran a disk check. absolutely no problems. The copy is perfect!!!

Mosh

I couldn’t suss how to get GParted to extend the size of a partition that already existed. Copying wouldn’t have been a problem.

Also, my laptop won’t boot from USB devices – hence my need for CDs. Hmm. Wonder if there’s a BIOS update that would rectify that? Another task for today!

My other issue is that I can’t seem to get XP to connect to the wifi from our new router. At all. Ubuntu is fine with is – unencrypted, WEP or WPA2. No worries. XP just isn’t having it. Most annoying.

Dale

To resize a partition using GParted (assuming there is a gap) you simply grab the edge of the patrition on the diagram, and drag. You don’t use the menus. Easy when you know, but not what I first thought of! Instead of booting Live USB, you could just boot liveCD. I just happen to have a LiveUSB of Ubuntu that I always keep with me so I can have Linux wherever I go. Also it is persistant so changes are kept, unlike the Live CD.

As for your router, I got mine working, and I’ve left wireless networking at that. Always hated networking.

4
0
Would love your thoughts, please comment.x
()
x