Standard disk setup here used to include a 5GB root partition (this has been upped to 10GB for a while now). I’ve just encountered the first machine with this setup to be running out of space on / - mostly this seems to be down to /usr/share.

Unfortunately resizing on-the-fly in this situation is difficult, due to the parted restriction that partitions can only be resized at the end - i.e. their start point must remain the same - which means that I can’t just take space off the front of the next partition along. The disk looks like this:

/dev/hda1      /             5GB
/dev/hda2      /local      105GB
(there’s swap and so on in there too, but let’s ignore that for the moment).

There is a solution to this, which goes like this (to expand /dev/hda1 by 5GB):

  • Resize /dev/hda2 to be 5GB, leaving 95GB spare.
  • Create a new partition in that 95GB.
  • Copy the data from /dev/hda2 to the new partition.
  • Delete /dev/hda2.
  • Resize /dev/hda1 to include that newly spare 5GB which used to be the resized /dev/hda2.
  • Tidy up as appropriate - all partition labels will have changed so you’ll need to edit /etc/fstab and possibly your boot loader, before you reboot.
Note that:
  1. This only works if you have less than 5GB of data in /dev/hda2.
  2. You’ll need to be running from a rescue disk or similar if you want to mess around with your / partition.
  3. Read the parted manual before actually doing the above :-)

Unfortunately, my /dev/hda2 partition in the above has rather more than 5GB of data so this plan won’t work. I was intending to dump the data off and then resize; but looking again at the partition table, I’ve noticed the existence of a swap partition between / and /local. Now, the data on this obviously doesn’t matter. So I can delete that partition, expand /dev/hda1 into that, shrink what is actually /dev/hda3 down by the appropriate size, and put in a new swap partition at the end of the disk. This will only get me 2GB, but that should be enough breathing space to be going on with.

All this did also lead me to thinking about the appropriate size for a / partition. 10GB seems like a lot to me… but for a machine with a lot of software, 5GB clearly isn’t enough any more. (There are operational reasons for keeping the root partition separate from ‘data’ partitions.). How much do I really need to allow for futureproofing on boxes I buy now and expect to last 3 yrs? Should I be upping the space to 15GB?