Day: October 31, 2008

Gentoo

Doing it the hard way, rather than the really hard way

When I shut down the server, prior to moving, I installed an extra hard drive I had laying around before packing it up to be shipped. With the move, and all the work and busy running about since then, I managed to forget that there was a 40GB drive, just waiting to be used.

The other day, I noticed in my daily email from the emerge –sync that cron runs, that it was unable to complete because there was not enough space on the disk. I logged on and df -h showed me that, yes, the drive was full. I did some cleanup and maintenance on the drive and managed to clear out about 1GB of space. This is important, because I needed to increase the size of my boot partition. When I first built this server (using Gentoo 2006.0) I had been having terrific results with a tiny little 32MB boot partition. Now I was having problems, because the boot partition didn’t have enough room to build the initrd for 2.6.27-gentoo-r1. I’m not sure why, but for some reason every kernel I have tried to compile after 2.6.25-gentoo-r1 (including r2, r3, r4, and r5 of the same kernel branch) would create an initrd that was in the 25MB range. Well, that plus a kernel and the configs and you have a no-go on a 32MB boot partition.

Anyway, after cleaning up the drive I was going to use parted to shrink the root partition and grow the boot partition. But parted requires that ext2 and ext3 partitions always start from the same block. Not a problem, the plan was to shrink the root partition, move the swap partition there and then grow the boot partition. Then the really hard part would have come – finding another drive (since this one was too small) and taking the entire server down for a rebuild. Ugh.

So I fired up parted and did a print all to see the block numbers for my partitions, and there it was, 40GB of unused space on another drive. (You probably heard the facepalm from wherever you are and wondered what that noise was.)

So, using good old cfdisk I created 3 partitions on the new drive, a 19GB ext3 partition, a 20GB ext3 partition and a 1GB swap partition. I copied the contents of /usr to the first, and the contents of /var to the second and used a little command chaining to put those where they belonged. (If you are curious, it went something like mv /usr /usr.old && mkdir /usr && mount /dev/hdd1 /usr followed by the same sort of chain for /var and then restarting a few services that point to files in var or usr).

I then did a swapon /dev/hdd3 swapoff /dev/hda2 and then edited fstab to match the new layout. Now for the fun part. Since I didn’t see a way in parted to delete a partition I shrunk the old swap partition down to 1MB, and then resized the boot partition to fill the new space. I did run into an issue where parted gave the error “Error: Filesystem has an incompatible feature enabled.” I found the fix for that to be using tune2fs to turn off resize_inode. That means no online resizing, but since this is not on an LVM that is not an issue. So, run tune2fs -O^resize_inode /dev/hda1 and then run parted and whoosh! A larger boot partition that will fit the massively fat initrd I am trying to stuff in there, and things are better. And with /usr and /var split off onto the new disk the root file system disk now has 11GB of space available.

And, in the spirit of doing things the hard way, I am posting this from my iPhone while laying about waiting for the stomach cramps to subside enough to sleep. (I hate this flu.)