Saturday, October 2, 2010

Resizing the /boot Partition in OpenSUSE Linux

So after a couple of weeks (it was my home machine not a critical production server) of seeing the latest kernel update failing on my OpenSUSE 11.2 system because there wasn't enough space on the /boot partition I finally had to deal with this. Trouble is I had no idea how to deal with this. I've resized /home before but /home is right at the end of the drive array so shrinking it and growing it is relatively easy with the disk partitioning tool in YaST.

So with the help of this article http://www.timelordz.com/blog/?p=456 here's what I did.

From the command line I went into init 1 with the command:

su

Then the root password.

init 1

It'll shut down just about everything running and bring you to a prompt asking for the root password to enter maintenance mode. I again entered the root password then unmounted /home with:

umount /home

Then I brought up the command line version of yast with

yast

and brought up the partitioning tool and changed the size of the partition that gets mounted at /home (I brought it down by 1.5 GB). I've been caught in yast resizing partitions before with not entering the GB (or MB or TB) after the number. It took a while with this operation as the /home partition is fairly large but in the end I had 1.5 GB of unpartioned space.

Once done I went back into run level 5 by typing

init 5

The next step was to create a 1.5 GB partition and following the article in the link above I named it newboot. This was easy enough again using the partitioner in yast.

Once that was done again following along with the article I copied the contents of /boot into /newboot as root

cp --verbose --recursive /boot/* /newboot

The next step was to edit the /newboot/grub/menu.lst file. Trouble was that it wasn't immediately clear to me what to change it to. After a bit of trial and error (not really advisable when dealing with bootloaders I know!) I found that the newboot partition was at (hd0,9) in grubspeek (the old one was hd0,4). So, I got them changed over in menu.lst, crossed my fingers and typed 'reboot'.

When the thing booted I was quite pleased with myself until I realised that it was still booting from the old /boot partition. The fix was easy if a bit scary. I hadn't done the bit from the article where it says to:

# grub
grub> root (hd0,9)
grub> setup (hd0)
grub> quit
# reboot

So again crossed my fingers and typed reboot.

This time it booted but didn't have the fancy grub menu that openSUSE comes with. I then saw that I hadn't modified the gfxmenu line. I changed that to match the (hd0,9) of the kernel image I was wanting to boot from and all was good....

Well, at least until I tried to run the kernel update with:

zypper -n up

It was still erroring out saying there wasn't enough space on /boot to install. So, it's trying to install to /boot rather than /newboot. Makes sense, the standard place for it is /boot. No developer has any idea that I've gone and told my machine to boot from /newboot. So, back into the yast partitioning tool. I changed the mount point of /boot to /oldboot and that of /newboot to /boot saved the changes and rebooted just for good measure.

When the system came back up it booted from hd0,9 as written to the master boot record when I ran the commands at the grub prompt before. This time however the partition at (hd0,9) was being mounted as /boot rather than /newboot. So again I ran the update:

zypper -n up

This time with all the pieces in place the new kernel installed on my new 1.5GB /boot partition.

So thank you Pete Eby for the article that pointed me in the right direction.

1 comment:

  1. A note of caution; when I subsequently went and upgraded to OpenSUSE 11.3 I absent mindedly accepted the default boot configuration of the installer which borked my grub setup. It would hit the master boot record and reboot the machine when trying to load stage 2 of grub. Be sure to tell the installer to boot from the (new) /boot partition rather than the Master Boot Record (MBR).

    This was because the main drive is a raid array configured on my motherboard rather than 'normal' drives.

    ReplyDelete