I have a root lvm with 10 GB, most of which is used, and a /home lvm with 877 GB. I want to resize the /home lvm to free up space, and then allocate that to root. I'm not clear on whether I can dynamically resize the partitions while mounted, but as far as I can tell, that's not possible. Also, as far as I can tell, I can't unmount /home or root unless I'm using a rescue disk.
Normally if I wanted to resize a disk partition that I couldn't otherwise unmount, I would use a gparted live disk. But as far as I know, gparted only works on "real" partitions, and can't operate on lvm partitions. So what's the best way to get access to the unmounted partitions and resize them?
Thanks,
Maurice
Best Answer
LVM makes this rather easy and straightforward. lvreduce will have to unmount the filesystem you want to shrink, but the filesystm to be expanded can do so while being mounted.
Steps: 1 backup - 2 reduce home lv - 3 check - 4 grow root lv - 5 check - 6 backup config
Only steps 2 and 4 are needed - the rest is just good practice. I also recommend logging the entire process by running
script
.Note: The Volume group in the example output is called tetrad (same as the hostname), you will want to insert the name of your volume group into the commands. The example output was gathered from archived logs as might be deduced from the differring version numbers of the resize2fs command.
Backup (at least your current configuration). Copy your backup somewhere outside the volume group being modified.
Reduce home lv
root@tetrad# lvresize --resizefs -L -35G /dev/mapper/tetrad-export
Check (optional), backup current state as in step 1. You will notice that step 4 does a backup to
/etc/lvm/backup/<vgname>
, but since that's on the filesystem being modified, you want your copy somewhere else.Grow root lv
You're done. Now let's just admire the results and keep a backup of the current state.
pvs
,lvs