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.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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
Method 2
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.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0