14

I tried to grow my LVM (on luks) root partition with

lvresize -L +5G -r /dev/vg/lv-root

and found that the file system wouldn't grow because it was mounted. Now I found this

https://ubuntuforums.org/showthread.php?t=1537569

that says I should boot from something else, and do

resize2fs /dev/vg/lv-root <size>

My question is: can I omit the size and just let the filesystem fill the partition (which was successfully enlarged before)? I'd try it but afraid of messing things up. Using (up to date) Arch and the filesystem is ext4.

2 Answers 2

13

You can resize it without rebooting, doing:

lvextend -r -l+100%FREE /dev/vg/lv-root

if you only have 5GB free on the volume group vg

or

lvextend -r -L+5G /dev/vg/lv-root

This commands adds the free space from the volume group vg to the volume lv-root, and extends it; with -r it also extends the underlying filesystem at the same time at run time. (So no need to reboot it from something else)

As for lvresize I think you have an extra space in the command. The command should be:

lvresize -L+5G -r /dev/vg/lv-root
5
  • Thanks! wonder why lvresize didn't do the same thing.
    – Toothrot
    Feb 18, 2017 at 12:47
  • added to answer. Feb 18, 2017 at 12:55
  • 1
    A small -l didn't work for me now, I had to use -L.
    – Toothrot
    Feb 10, 2018 at 15:28
  • Little L -l for extents i.e +100%FREE and big L -L for size i.e. +5G Sep 19, 2022 at 23:05
  • @Shadetheartist Thanks, corrected. Sep 22, 2022 at 1:06
6

Yes, you can omit the size from your second command. In this case, the fs will be resized to use the whole block device (lv-root).

In general, this can be done with unmounted partitions only. But ext4 (and also some different fs) has a special feature, that it can be grown while it is online. It is the feature of the ext4 filesystem driver. In this case, the resize2fs command will only ask this online grow functionality of the kernel fs driver.

You must log in to answer this question.

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