4th Street Bar Hive-Bar

Hive-Bar Powered by Hive beta-fdb5b5b

Community post

LVM Basics (Logical Volume Manager)

I have been trying to get my head around the basic features of LVM for my LPIC-1 Exam 101. I thought I would share my revision notes with the Steemit community, I have been working with Centos 7.

https://s33.postimg.org/gi83k0dpr/lvm.png

Physical Volumes


pvdisplay – displays physical volumes

pvcreate – creates a physical volume

lsblk – lists block devices

Begin by using lsblk to show physical devices.

lsblk

In this example, we’ll say sda and sdb are listed. The below command will create a physical volume.

pvcreate /dev/sdb

Next, you want to display the physical volumes to see if it has been created successfully.

pvdisplay

Now you should see the new physical volume 'sdb'.


Volume Groups


vgdisplay – displays volume groups

vgcreate – creates a volume group

Next, you want to display the volume groups to see if it has been created successfully.

vgdisplay

Now you should see the new volume group 'testvg'.


Logical Volumes


lvdisplay – displays logical volumes

lvcreate – creates a logical volume

I ran the below command to create a logical volume called ‘mylv’ which is located in the volume group ‘testvg’. I used the -l 100% to use 100% of the volume group.

lvcreate -l 100%VG -n mylv testvg

Next, you want to display the logical volumes to see if it has been created successfully.

lvdisplay

Now you should see the new volume group 'mylv'.


Creating a filesystem and mounting


The below command will create a file system using ext4 on the logical volume ‘mylv’ that was created previously.

mkfs.ext4 /dev/testvg/mylv

Next, I made a directory to mount the logical volume with the below command.

mkdir /mnt/media

I then mounted the logical volume to /mnt/media

mount /dev/testvg/mylv /mnt/media


Editing fstab


For the volume to automount on reboot you will need to edit fstab.

cd /etc/

vi fstab

Within ‘fstab’ you will need to specify some options regarding the new logical volume and it’s mount point. For this example, I added the below.

/dev/testvg/mylv /mnt/media ext4 defaults 0 0

You can read more about ‘fstab’ at the below link;

https://community.linuxmint.com/tutorial/view/1513

I hope this is of use to some people, it certainly helped me break down the LVM hierarchy and how to create a file system in Linux.

Liam AKA Gadgie

11 upvotes $0.00

Replies (7)

Review before signing

Posting as . Signing with . Keychain permission: Posting. Hive Keychain will ask you to approve this action next.


  
Technical details

Operation fingerprint: