Expanding A Root-FS


There might be the situation, that your root filesystem runs out of space, so it has to be expanded. With filesystems other than the root filesystem this could easily be done for instance with gparted. With the root filesystem this is not possible, as gparted could only expand filesystems that are not mounted, which is impossible with the root filesystem. The only way to enlarge the root filesystem is to boot from a kind of rescuesystem, Live-CD or the like, and then to expand the root filesystem.

The following tutorial describes, how this is achieved by using Systemrescue-CD. SysRescCD is (as the name says) a kind of minimal Rescue Linux, often used as bootable CD or bootable USB Stick, or also usable as a bootable ISO Image directly in VMware ESX/Server, Virtualbox or similar virtualizers. It has a lot of useful stuff which could be used for maintenance tasks (to be honest, it is NOT minimal as written above).



As installations may differ widely, this tutorial could only be a kind of cooking recipe, a rough guide, and has to be adapted to the concrete setup. This procedure has been developed for a system running as VM under VMware ESX, the root filesystem being LVM2 based ext3, inside a SAN. Operating System was CentOS 5.

Be careful with all you are doing, all actions are performed with root permission. So make a full backup before you do anything other. You should also be familiar working in a shell. Also do whenever possible "dry-runs" before you do real modifications, and carefully inspect all messages whether they correspond with your expectations.

For details regarding SysRescCD please have a look at it's documentation on http://www.sysresccd.org/Online-Manual-EN

For details regarding LVM2 please have a look at the manpages or on http://sources.redhat.com/lvm2/ or http://www.sysresccd.org/Sysresccd-LVM2-Documentation

There is one other Rescue-System I'm aware of, which may also be used, namely GRML: http://grml.org/

Another distro which is also often used as a Rescue-System is Knoppix: http://www.knoppix.net/

A very tiny distribution, which may also do the job outlined below is Damn Small Linux: http://www.damnsmalllinux.org/


Let's dive in

* Create a new disk/partition in the Admin console of ESX

* Attach an ISO-Image of SysRescCD to the CD/DVD drive of the VM, and boot it. You should see the messages of the booting SysRescCD, and after a while you should get a prompt. If you have problems booting SysRescCD, or if you want to see the possibilities booting SysRescCD you can press F1 .. F7, and/or have a look into the documentation of SysRescCD.

Now we are ready to start:

* Type


and hope that X11 comes up. Otherwise you have to do the whole following procedure in the shell. But don't forget that you have several consoles you can access with <ALT>-<F1-F6>

* When X11 does not start, another possibility might be to fire up networking by doing

net-setup eth0

and the SSH server by doing

/etc/init.d/sshd start

and try to run gparted with the help of the X-forwarding feature of SSHD, or may be you have luck to access the Rescue System by connecting the VNC Server.

Share this page:

3 Comment(s)

Add comment


From: Anonymous at: 2009-11-30 09:06:17

It might be worth pointing out that all the tasks done above can be done online, without rebooting. Even resizing the filesystem, with resize2fs or ext2online. You'll only need to boot if you need to add a disk physically, or you're not using LVM in the first place.


From: Grant at: 2009-11-30 20:46:44

In addition, if using ReiserFS, you don't even need to unmount the file system to do this, just extend the LV, then resize the FS hot.



vmetch:/mnt# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              20G   12G  7.2G  62% /
tmpfs                 506M  8.0K  506M   1% /lib/init/rw
udev                   10M  240K  9.8M   3% /dev
tmpfs                 506M     0  506M   0% /dev/shm
                      200M   33M  168M  17% /mnt/lvm
vmetch:/mnt# lvresize -L +10M /dev/TestLVM/test1
  Rounding up size to full physical extent 12.00 MiB
  Extending logical volume test1 to 212.00 MiB
  Logical volume test1 successfully resized
vmetch:/mnt# resize_reiserfs /dev/TestLVM/test1
resize_reiserfs 3.6.21 (2009 www.namesys.com)

resize_reiserfs: On-line resizing finished successfully.

vmetch:/mnt# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              20G   12G  7.2G  62% /
tmpfs                 506M  8.0K  506M   1% /lib/init/rw
udev                   10M  228K  9.8M   3% /dev
tmpfs                 506M     0  506M   0% /dev/shm
                      212M   33M  180M  16% /mnt/lvm

From: Anonymous at: 2009-12-11 22:34:46

Unfortunately you cannot shrink a mounted / partition, that's what this article documents.