[ubuntu-us-mi] resizing mounted filesystem

Robert Citek robert.citek at gmail.com
Wed Oct 6 01:20:57 BST 2010

I'm running into some kind of limit for expanding a mounted file
system.  Does anyone know of a workaround that allows me to expand yet
keep the filesystem mounted?

In brief, I have a mounted filesystem that I want to make larger, e.g.
from 5MB to 10GB.  However, resize2fs gets about half-way before
stopping with an error.  Nothing on the filesystem seems to be broken,
I just can't make it any larger.  If I unmount, fsck, resize, and
mount again, that works just fine.  But I'd rather not unmount.  Or if
I do need to unmount, only unmount to change some setting on the
filesystem and not do a full fsck. (still googling to figure out what
that setting might be.)

Here's a simple script to replicate the issue I'm having.  It needs to
be run as root.  So, if you are not comfortable with that, please do
not run it.

# code to demonstrate issue
dd if=/dev/zero of=ext4.img bs=1M count=10000
mkfs.ext4 -F ext4.img 5M
mkdir -p ext4.loop
mount -o loop ext4.img ext4.loop
df -PhT ext4.loop
resize2fs $(mount | grep ext4.loop | cut -d" " -f1)
df -PhT ext4.loop

# workaround to demonstrate filesystem can be resized, just not when mounted
umount ext4.loop/
e2fsck -fy ext4.img
resize2fs ext4.img
mount -o loop ext4.img ext4.loop
df -PhT ext4.loop

BTW, this was tested on Ubuntu Lucid 10.04.

- Robert

More information about the ubuntu-us-mi mailing list