12

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.

11

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
  • Thanks! wonder why lvresize didn't do the same thing. – Toothrot Feb 18 '17 at 12:47
  • added to answer. – Rui F Ribeiro Feb 18 '17 at 12:55
  • 1
    A small -l didn't work for me now, I had to use -L. – Toothrot Feb 10 '18 at 15:28
5

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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