LVM questions

General support questions
Post Reply
FranekW
Posts: 36
Joined: 2017/05/11 21:19:21

LVM questions

Post by FranekW » 2017/06/17 15:39:08

I am planning to reinstall centos 7. One of the reasons is I did not add LMV before because did not really understand what it was and decided to go for regular partitions. I understand LMV now and I know how to create Group Volume(s) from physical volumes, logical volumes etc.

I would also like to test something and I want to leave about 10-20GB of disk space for an extra primary partition that would not be covered by LVM; I would like to install another linux distro on that partition. Later, I plan to get rid of the other system and extend /home partition. I have added a picture to illustrate what I mean:
- grey areas are primary partitions for /boot folders of two distros I would like to install
- green space is for LMV
- the group volume will be split into system folder /, swap, /home and another system folder / for the other distro.

I have two questions. If I decide to get rid of the other primary partition, is it difficult to extend the Group Volume of LMV to cover remaining free space? I would also like to remove the other yellow LV (right) and extend /home directory. Is it hard to reconfigure LVM?

The second question is about the other linux distribution. Can the other system recognise my LMV configuration I made while installing the first system, such as Group Volume and logical volumesf?

Thanks
Attachments
lvm50.png
lvm50.png (4.26 KiB) Viewed 1555 times

User avatar
InitOrNot
Posts: 122
Joined: 2015/06/10 18:26:51

Re: LVM questions

Post by InitOrNot » 2017/06/17 22:15:00

FranekW wrote:- the group volume will be split into system folder /, swap, /home and another system folder / for the other distro.
Don't do that. You are betting yourself for a world of hurt.

Do not share PVs between different installs (therefore, do not share VGs and/or LVs between different installs).

If you are using a MBR-style partition table, it would be better to do this:

sda1, primary -> /boot for Distro-1
sda2, primary -> /boot for Distro-2
sda3, primary -> PV for LVM for Distro-1
sda4, primary -> PV for LVM for Distro-2

Then, when you are done testing Distro-2, just add sda2 and sda4 as additional PVs to the VG for Distro-1, and grow some LV of Distro-1 to use that free space.

FranekW
Posts: 36
Joined: 2017/05/11 21:19:21

Re: LVM questions

Post by FranekW » 2017/06/18 09:50:19

Thanks for pointing out the issue with different systems using the same LVM.

I tested LVM in CentOS 7 installed in virtual box with LVM. I only tested how to extend space, so I added a new virtual drive, created PV, then extended both Volume Group and then LV. It seems easy to do :)

User avatar
InitOrNot
Posts: 122
Joined: 2015/06/10 18:26:51

Re: LVM questions

Post by InitOrNot » 2017/06/18 17:46:15

FranekW wrote:Thanks for pointing out the issue with different systems using the same LVM.

I tested LVM in CentOS 7 installed in virtual box with LVM. I only tested how to extend space, so I added a new virtual drive, created PV, then extended both Volume Group and then LV. It seems easy to do :)
Yes, it's very easy to do once you get the hang of it.

I guess that you also did a resize2fs afterwards, in order to grow the filesystem(s) residing on the already grown LV, right?

Going the other way (i.e., reducing the space consumed by LVM) is also possible, but much more involved because the resize2fs can only to operate off-line when reducing filesystems. Luckily, reducing the space consumed by LVM is not a common real-world need.

hunter86_bg
Posts: 2019
Joined: 2015/02/17 15:14:33
Location: Bulgaria
Contact:

Re: LVM questions

Post by hunter86_bg » 2017/06/18 18:59:04

Resizing logical volumes is far safer if you use the '-r' option.
For example, lvreduce will even ask you to 'umount' the volume before proceeding further.

FranekW
Posts: 36
Joined: 2017/05/11 21:19:21

Re: LVM questions

Post by FranekW » 2017/06/21 07:27:45

InitOrNot wrote:I guess that you also did a resize2fs afterwards, in order to grow the filesystem(s) residing on the already grown LV, right?

Going the other way (i.e., reducing the space consumed by LVM) is also possible, but much more involved because the resize2fs can only to operate off-line when reducing filesystems. Luckily, reducing the space consumed by LVM is not a common real-world need.
Yes, I have used resize2fs. I followed a blog and this command was the last to execute. I had to check other websites to make sure this would need to be run. I was surprised by the last step. I did not know about changing file systems explicitly after changing size of a partition. I also read resize2sf should be run first if we going to shrink partitions.
hunter86_bg wrote:Resizing logical volumes is far safer if you use the '-r' option.
For example, lvreduce will even ask you to 'umount' the volume before proceeding further.
thanks for the clue :)

EDIT.
I have just read on Unix & Linux SE website about '-r' option. It seems the best way to do as it automatically resizes a file system. 'lvextend' does not have it, though.
Last edited by FranekW on 2017/06/21 09:26:34, edited 1 time in total.

User avatar
TrevorH
Site Admin
Posts: 33216
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: LVM questions

Post by TrevorH » 2017/06/21 08:21:59

lvextend has a -r option.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

FranekW
Posts: 36
Joined: 2017/05/11 21:19:21

Re: LVM questions

Post by FranekW » 2017/06/21 09:28:32

Thanks. Yes, it does. I was not at computer while writing the last post and found some strange man website regarding 'lvextend'.

Post Reply