March 20, 2018

How to create/remove Logical volume in CentOS 7

For details on how to add disks and partitioning(sdb1, sdb2), see this(Link) and also see what is PV, VG, LV(Link). I let you know that I did this on VMware virtual environment. The procedure is as follows

partitioning → pvcreate → vgcreate → lvcreate → format → mount




1. pvcreate

pvcreate in create/remove Logical volume in CentOS 7

pvcreate [Device path] : This creates a physical volume.

Physical volume "/dev/sdb2" and "/dev/sdb1" is created.




2. vgcreate

vgcreate in create/remove Logical volume in CentOS 7

vgcreate [Volume group name] [Physical volume path 1] [Physical volume path N] -s [Size of PE] : This creates a volume group.

volume group vg1 is created containing 8 MiB PE size.




3. lvcreate

lvcreate in create/remove Logical volume in CentOS 7

lvcreate [Volume group name] -n [Logical volume name] -L [Size] : This creates a logical volume.

lvcreate -l 100%FREE : Allocate all remaining space.

Logical volume "/dev/vg1/lv2" and "/dev/vg1/lv1" is created.



4. format

formatting in create/remove Logical volume in CentOS 7

I did format two logical volumes with "xfs" and "ext4".



5. mount

mount in create/remove Logical volume in CentOS 7

Then I mounted the two.

The mounted result by upper method will be removed when the system is rebooted, so it may be helpful to mount it with "mount -a" command after registering it in "/ etc / fstab". Generally, you can add it to the bottom of "/etc/fstab" in the following format.

[UUID] [Absolute path to be mounted] [File system] defaults 0 0




removing method Logical volume in CentOS 7

As shown above, to remove the logical volume do the previous steps in reverse .




Check environment
O      S CentOS 7.4.1708(64bit) CPU Intel i7-4710MQ 2.50GHz
SHELL GNU bash (4.3.46(2)) RAM 1 GB