Monday, March 15, 2010

Resizing an LVM /usr partition in OpenSUSE 11.1

The yast2 tool makes resizing lvm partitions a very straightforward matter. The only requirement is to unmount the partition being resized. To achieve an unmount of /usr one has to boot to single user mode since there are many process which have open files on that partition. Running lsof /usr | wc -l as root on one instance turned up 2588 files!

It turns out that after running umount /usr successfully in single user mode, yast2 disk fails since there are some files that yast2 needs in the unmounted /usr partition. This left me only with the option of using the console tools. Below is the sequence of commands that I run to add 5G to my /usr partition.

modprobe dm_mod
lvextend -L +5G /dev/mapper/system-usr
shutdown -r 0
resize2fs /dev/mapper/system-usr


The first command to load the device mapper kernel module was necessary since the module was not loaded automatically in my case. I was only able to resize the file system after a reboot because I could not figure out a way to mount the partition in single user mode but I believe it should be possible.

2 comments:

  1. Thankfully, increasing the size of an lvm partition in Ubuntu does not need it to be unmounted.

    Decreasing the size would surely need it unmounted but it would be very hard since the Ubuntu recovery environment programs e.g. bash and recovery-menu use the /usr partition.

    ReplyDelete
  2. I think the reason why I was able to increase the size of a partition in ubuntu 10.04 while it was mounted is because the file system is ext4 unlike ext3 for openSUSE 11.1.

    ReplyDelete