� Lord of War | Main | M$ DRM debacle �

October 14, 2005

Mtools and Parted save the day

I've been struggling with a weird computer problem, so I've not had the time to post anything lately. Besides the other distractions (Pinstripes || Tang Soo Do). Suffice to say, that I have it under control now. I think it might be instructive to discuss it here, as some of you might find it helpful. Additionally, there are still pieces of the problem which have me baffled. That is I'm still having issues with my dual CPU setup. I've had this box for since 2003, and the dual CPU setup worked fine using the earlier 2.6.5 kernel. Once I decided to add another 512MB DIMM (unbuffered), and upgrade the kernel to 2.6.11, all hell broke loose. I've posted my question to LKML, but to no avail. It really seems that I have a hardware issue and not a kernel bug.

Basically, if I enable the MP table within the BIOS, I get all of these weird IRQ vector (AB, AC,AD) trapping errors. I've tried passing 'noapic' 'noirqdebug' and of host of other workarounds to the kernel at boot time, but none of them have worked. I even removed the additional DIMM and I still get these problems. I also ran 'memtest86' and the test did not reveal any problems that would indicate bad memory. So for now, I'm stuck with a crippled uniprocessor box.

Anyway, while trying to deal with these problems, I stumbled into another mess. Apparently, while playing around with different kernel images, I exhausted the space in my /boot partition. I suppose it was poor planning on my part, as I'd only allotted 7.5mb for that partition. So, I was in a bit of quagmire.

Enter GNU/Parted. It was truly a godsend. Those of you who use M$, GNU/Parted is the equivalent of Partition Magic. Of course the obvious difference is that GNU/Parted is totally free software. The interesting part about this whole exercise, is that I had not backed up the /boot partition. My plan was to shrink the /swap or /dev/hda2 partition and increase the space in /boot to 20mb. Conventional wisdom always suggests that you back up your data, before doing anything to your partitions. Nonetheless, I threw caution to the wind and just ran the application. Besides, I could always download another kernel.

So, I grabbed bootable GNU/Parted image and copied it to a floppy. Another rule of thumb, _never_ repair a partition that is mounted to running filesystem. This is why Parted manpage recommends that you use a boot floppy. Essentially, the system boots into single user mode.
Alas, there is yet another hurdle to leap. Somehow, my latest kernel image became corrupted due to the lack of space on the /boot partition. So I really didn't have a functional system. I couldn't boot into the 2.6.13 kernel, and utilize various filesystem modules (ie. vfat, reiserfs, etc). So, copying the Parted boot image from the floppy to hard disk would be a challenge.

Enter GNU/mtools. I had first been exposed to the virtues of mtools while working as an undergrad, at a facility that was then called SCRI. I used an old IBM RS/6000 which had a 1.44mb floppy drive that could read DOS floppies because the AIX system had mtools installed by default. Gotta love GNU :)

After reading the mtools manpage, I realised that running the following: 'mread a:\ .' (note the '.') would copy the image to hard disk. The next task would be to write the bootable image back to floppy.

As root, I ran 'dd if=partroot-1.6.6.gz of=/dev/fd0 bs=1440k' to create the root floppy disk
and 'dd if=partboot.img of=/dev/fd0 bs=1440k' to create the boot floppy disk.
Yes, the 'disk duplicate - (dd) is also a GNU tool. According to the Parted docs, you need a root disk and boot disk, I repeated the steps for boot disk too. Once completed, with writing both images to floppy, I simply rebooted the system.

Once the system had finished reading the rootdisk into RAM, I then was requested to insert the Parted bootdisk. After the bootdisk image was read into RAM, I then ran 'fdisk -l' so that I could read the partition table and write down some critical values.

My before table was as follows:
Device Boot Start End Blocks Id System
/dev/hda1 * 1 1 24066 83 Linux
/dev/hda2 2 124 971932+ 82 Linux swap
/dev/hda3 125 9729 77152162+ 83 Linux

Later the table would appear as follows:
Device Boot Start End Blocks Id System
/dev/hda1 * 1 3 24066 83 Linux
/dev/hda2 4 124 971932+ 82 Linux swap
/dev/hda3 125 9729 77152162+ 83 Linux

To increase /dev/hda1 (/boot) to a larger size, by reclaiming a portion of /dev/hda2 (Linux swap)...
I ran the following Parted commands in interactive mode:

# parted /dev/hda

# Remove partition 2 (the swap partition). Normally, you wouldn't want to delete a partition with data on it. However, a swap partition doesn't contain data when it isn't "swapped on" (mounted), so you can remove it, and create a replacement swap partition later. Additionally, swap space isn't being used since we booted with the Parted boot disks into single-user mode.

(parted) rm 2

# Create the new swap partition at the end of the disk:

(parted) mkpartfs primary linux-swap 971 999.9
(parted) print
Disk geometry for /dev/hda: 0.000-77152162.000 megabytes
Disk label type: ext3
Minor Start End Type Filesystem Flags
1 0.063 20.000 primary ext2
2 20.000 971.000 primary linux-swap

# Grow partition 1, into the adjacent free space:

(parted) resize 1 0.063 20.5

All done!

Afterwards, I printed the disk table again as a confirmation. All looked as expected. I removed the boot disk and rebooted the machine.

Posted by AG at October 14, 2005 2:14 AM