Online Filesystem Resizing with LVM

I use LVM on my main desktop machine. This is awesome because it allows me to dynamically allocate space to partitions as I choose, however I always forget how to do a resize, so I’m going to write it down here. This isn’t going to be a full LVM tutorial (there’s plenty of material out there for that), although maybe that’s an idea for the future.

The following commands will resize an ext2, ext3, or ext4 filesystem running on LVM while it is mounted:

$ sudo lvresize -L +XXG <path to fs device>
$ sudo resize2fs <path to fs device>

In the above command you need to replace XX with the number of GB you want the filesystem to grow by and <path to fs device> by the device node (typically /dev/mapper/something).

An there you have it, done! Obviously there is a huge amount more you can do with the two tools above, take a look at their man pages for more info.

Hopefully this post will save me from having to work out how to do this every time!

3 thoughts on “Online Filesystem Resizing with LVM

  1. You might want to clarify that resizing mounted volumes is limited to growing, you can’t shrink using resize2fs unless the block device is unmounted.

  2. Vishal Gori says:

    ext2online even this command cant be used? Infact I am not able to find this command in RHEL6

Leave a Reply

Your email address will not be published. Required fields are marked *