8

I have seen some tutorials on extending an LVM2 logical volume. None of them instruct you to unmount the filesystem. They claim that you can extend an LVM volume while it is in use. Is this right?

4
  • This can be easily verified by trying....
    – Karlson
    Commented Dec 13, 2012 at 17:54
  • 1
    Growing and shrinking (the two components of resizing) are typically handled differently, and both are dependent on the file system type itself. This is not related to LVM: you extend the "partition" that contains a file system with or without LVM.
    – jw013
    Commented Dec 13, 2012 at 18:02
  • 5
    @Karlson Generally speaking, "just try it" isn't a great idea when it comes to questions like "will this corrupt my filesystem if I do it wrong" Commented Dec 13, 2012 at 18:24
  • @MichaelMrozek I would agree with you if the only way to do this is to try it on a live production system. Normally one would have a dummy volume or a system that this would be tested on, so if you corrupt anything the answer is obviously no and no harm comes to the data on your original volume.
    – Karlson
    Commented Dec 13, 2012 at 18:32

2 Answers 2

13

That depends on whether the filesystem can be extended online. Most major Linux filesystems can be extended while they are mounted (btrfs, ext2, ext3, ext4, xfs, zfs) — the main exception is reiserfs. If you want to extend one of these filesystems on an LVM volume, you can extend the volume with lvextend, then extend the filesystem to fill the enlarged volume, all without deactivating or unmounting anything.

If you're shrinking the volume, there are fewer filesystems that don't require mounting: only btrfs and zfs can be shrunk online. Shrink the filesystem, then call lvreduce to bring the logical volume size down to the size of the filesystem.

6

There is no need to unmount an ext3 or ext4 filesystem to expand it. Shrinking the filesystem, however, is another matter. That requires it to be unmounted and fscked before it is down-sized.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .