Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm building a system with fairly limited disk space that will use LVM, and I'd like to be able to resize the partitions as freely as possible without bringing the system down. In particular, I'd like to be able to grow or shrink* /usr.

As I understand it, it's not possible (this is only half-true: see update) to resize a mounted ext2/3 partition, even if it is part of an LVM volume.

Would it be possible to unmount, say, everything but /bin and /sbin (assuming that those directories are on a separate partition, of course) for the duration of the resize? Or does resize2fs need libraries or other entities from /usr?

Perhaps this would be more appropriately done from within a chroot environment or by some other approach?

*: shrinking /usr would probably only be necessary right after the install, so is not as necessary as growing that partition.

update

I've discovered (see @baumgart's answer and its comments) that under recent/modern Linux kernels it's not necessary to unmount an ext3 filesystem in order to increase its size. Although it is pretty unlikely that I'd have a need to reduce the size of a /usr filesystem with any sort of frequency or immediacy, I'm still interested in learning how I would set things up so as to be able to do so, or at least in being told that "you can't get there from here".

So my original question stands.

share|improve this question
add comment

1 Answer

If you use LVM, you absolutely CAN resize ext2/3 filesystems. You can grow filesystems online, but shrinking them requires them to be offline.

If you configure all your filesystems (except /boot) using LVM, you can simply say lvresize -L +1G /dev/vgname/lvname, then use resize2fs /dev/vgname/lvname to do the filesystem resizing.

Check out the LVM page on Wikipedia and you'll see what it can do.

EDITED: Noted that shrinking requires taking the filesystem offline.

share|improve this answer
    
My concern isn't really with LVM, but with the limitations of the ext* filesystem. I read in a couple of places (e.g. here) information that suggested that it was necessary to unmount an ext* filesystem in order to run resize2fs. Though it looks like you're right, and those sources are outdated: the current (ubuntu 10.04) manual for resize2fs mentions that "As of this writing, the Linux 2.6 kernel supports on-line resize for filesystems mounted using ext3 only." –  intuited Sep 16 '10 at 2:32
    
This is correct, but only works when increasing the size of the file system. If you want to decrease it (shrink it), you still need to unmount the partition. BTW, Knoppix is an excellent choice for this sort of work. –  wolfgangsz Sep 16 '10 at 10:00
    
@wolfgangsz - Can you provide a source for the info about unmounting to shrink? I've never tried to shrink a filesystem at all, much less online, but all the information I'm seeing says that when using LVM and ext2/3, it is possible to do online resizing (both growing and shrinking). –  baumgart Sep 16 '10 at 13:57
    
Read the man page for resize2fs. In the "Description" section it says: The resize2fs program will resize ext2 or ext3 file systems. It can be used to enlarge or shrink an unmounted file system located on device. If the filesystem is mounted, it can be used to expand the size of the mounted filesystem, assuming the kernel supports on-line resizing. (As of this writing, the Linux 2.6 kernel supports on-line resize for filesystems mounted using ext3 only.). –  wolfgangsz Sep 16 '10 at 16:26
    
This is from version 1.41.3 (stock Debian lenny). If you use a newer version, this might be different. As said, read the man page. –  wolfgangsz Sep 16 '10 at 16:27
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.