SYS: Create and remove physical volumes, assign physical volumes to volume groups, and create and delete logical volumes.

Share this link

Note: This is an RHCSA 7 exam objective.

Prerequisites

Before dealing with physical volumes, volume groups and logical volumes, you need to know how to create partitions on disk.

LVM Presentation

LVM stands for Logical Volume Manager. It’s the system component that is able to deal with partitions in a modern way.

Traditionally, Unix disks were divided into slices called partitions. It was possible to decide the size of each partition but, once done, you couln’t change it without destroying all data on it.

With LVM, you can allocate disk space in a flexible manner.

LVM relies on three main concepts:

  • physical volume or pv: a pv is a whole disk or a partition of a disk,
  • volume group or vg: a vg contains one or more pv; a pv can only belong to one vg,
  • logical volume or lv: a lv represents a portion of a vg; a lv can only belong to one vg; it’s on a lv that you can create a file system.

LVM brings flexibility compared to the previous system only based on partitions:

  • you can easily increase the size of a logical volume if you’ve got some space available in the associated volume group,
  • if you don’t have any available space anymore, you can add a new disk as a physical volume, add it to the volume group and increase the size of your logical volume: the logical volume will span two or more disks without any additional operations,
  • creating or extending logical volumes don’t require any downtime.

Configuration Report

Before starting any operation, you need to know the current configuration. Type:

# lsblk -a
NAME          MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
vda           252:0    0    6G  0 disk 
├─vda1        252:1    0  390M  0 part /boot
└─vda2        252:2    0  5.5G  0 part 
  ├─rhel-swap 253:0    0  552M  0 lvm  [SWAP]
  └─rhel-root 253:1    0    3G  0 lvm  /

With the lsblk command, you get quickly the following information:

  • it is a virtual machine (vda, sda would indicate a physical server),
  • there is only one disk /dev/vda of 6GB,
  • the disk is divided into two partitions (vda1 and vda2) respectively with a size of 390MB and 5.5GB,
  • the vda1 partition is mounted under /boot,
  • the vda2 partition consists in two logical volumes (lvm) swap and root in a volume group called rhel,
  • the swap logical volume is used by the system as a swapping area ([SWAP]) of 552MB,
  • the root logical volume is mounted under / with a size of 3GB,
  • there is around 2GB of free available space (5.5GB552MB3GB=2GB) in the vda2 partition,
  • none of the partitions are in Read-Only mode (RO=0) or ReMovable (RM=0).

Note1: lsblk should be the first command to type when dealing with partitions.
Note2: By default, the lsblk command doesn’t display empty devices. The -a option corrects this problem.

Physical Volume Management

To create a physical volume (here /dev/vda), type:

# pvcreate /dev/vda

To remove a physical volume not belonging to any volume group (here /dev/vda), type:

# pvremove /dev/vda

To get the list of the physical volumes, type:

# pvs

Volume Group Management

To create a volume group (here called vg using a physical volume /dev/vda) with a physical extent size of 8MB, type:

# vgcreate -s 8m vg /dev/vda

To add a physical volume (here /dev/vdb) to an existing volume group (here vg), type:

# vgextend vg /dev/vdb

To remove a physical volume (here /dev/vdb) from an existing volume group (here vg), type:

# vgreduce vg /dev/vdb

To remove an existing volume group (here called vg), type:

# vgremove vg

To get the list of the volume groups, type:

# vgs

Logical Volume Management

To create a logical volume (here called lv_vol with a size of 1GB in the vg volume group), type:

# lvcreate --size 1G --name lv_vol vg

To remove a logical volume (here called lv_vol in the vg volume group), type:

# lvremove /dev/vg/lv_vol

To get the list of the logical volumes, type:

# lvs

Additional Resources

You can also watch Ralph Nyberg‘s video about LVM (18min/2015) or Red Hat Training‘s Resizing a volume group (5min/2015).
Beyond the RHCSA objectives, you can read this tutorial about Creating a Thinly Provisioned Logical Volume.

(3 votes, average: 4.00 out of 5)
Loading...
22 comments on “SYS: Create and remove physical volumes, assign physical volumes to volume groups, and create and delete logical volumes.
  1. algorisms says:

    On my LFCS exam, they had asked us to do some work with LVM – I won’t discuss what they actually asked because that would be a cheating… But I will say that users should know what packages are needed… Sometimes, even though they are default packages, they aren’t installed… If you know what I mean…

  2. hunter86_bg says:

    You should add the lvresize command,which is quite useful.
    Ex: If you have a logical volume with name “lvol” in volume group “vg_new” and you wish to resize it:
    lvresize -L 10G -r /dev/vg_new/lvol0
    The command changes the size of the volume to 10 GB, resizes the file system automatically.Works in both up and down directions ( -L option specifies the amount of space you want for your lvol and it skips the usage of “lvextend” and “lvreduce”)
    N.B.:
    *”lvresize” must be used only when the volume is “umount”ed!
    * “-r” option resizes ext2,ext3,ext4 in both directions,”xfs” file system supports only growing!

  3. Ahmad says:

    Hi,

    Can you please help on the below two queries:

    1-Is shrinking LVM is an RHCSA objective?
    2-Is creating a LUKS encrypted partitions an RHCSA objective?
    3-If yes, how we can do both for the RHCSA perspective?

    • CertDepot says:

      1- You are supposed to know how to do it.
      2- LUKS encrypted partitions were an RHCSA 6 objective.
      3- You only need to be prepared for the point 1.

  4. ntorga says:

    Just a tip: If pvcreate and similars doesn’t work, you have to check with rpm -q lvm2 to see if lvm is installed.

  5. reaz_mahmood says:

    Hi, I have read somewhere that in the exam they ask to create lv in terms of PE unit. It is normally 1PE = 4 Mib. Is there any exception of this conversion or it will always be 4 Mib ?

  6. ercole1977 says:

    Hi guys probably a stupid question. I have 2 LVs configured and only one mounted. My scope is to check available space on them. If I do lvdisplay I see lv size, and with df -h I see free space of the mounted one. My question is….how can I see the free space of LV not mounted?

Leave a Reply

Upcoming Events (Local Time)

There are no events.

Follow me on Twitter

Archives

vceplus-200-125    | boson-200-125    | training-cissp    | actualtests-cissp    | techexams-cissp    | gratisexams-300-075    | pearsonitcertification-210-260    | examsboost-210-260    | examsforall-210-260    | dumps4free-210-260    | reddit-210-260    | cisexams-352-001    | itexamfox-352-001    | passguaranteed-352-001    | passeasily-352-001    | freeccnastudyguide-200-120    | gocertify-200-120    | passcerty-200-120    | certifyguide-70-980    | dumpscollection-70-980    | examcollection-70-534    | cbtnuggets-210-065    | examfiles-400-051    | passitdump-400-051    | pearsonitcertification-70-462    | anderseide-70-347    | thomas-70-533    | research-1V0-605    | topix-102-400    | certdepot-EX200    | pearsonit-640-916    | itproguru-70-533    | reddit-100-105    | channel9-70-346    | anderseide-70-346    | theiia-IIA-CIA-PART3    | certificationHP-hp0-s41    | pearsonitcertification-640-916    | anderMicrosoft-70-534    | cathMicrosoft-70-462    | examcollection-cca-500    | techexams-gcih    | mslearn-70-346    | measureup-70-486    | pass4sure-hp0-s41    | iiba-640-916    | itsecurity-sscp    | cbtnuggets-300-320    | blogged-70-486    | pass4sure-IIA-CIA-PART1    | cbtnuggets-100-101    | developerhandbook-70-486    | lpicisco-101    | mylearn-1V0-605    | tomsitpro-cism    | gnosis-101    | channel9Mic-70-534    | ipass-IIA-CIA-PART1    | forcerts-70-417    | tests-sy0-401    | ipasstheciaexam-IIA-CIA-PART3    | mostcisco-300-135    | buildazure-70-533    | cloudera-cca-500    | pdf4cert-2v0-621    | f5cisco-101    | gocertify-1z0-062    | quora-640-916    | micrcosoft-70-480    | brain2pass-70-417    | examcompass-sy0-401    | global-EX200    | iassc-ICGB    | vceplus-300-115    | quizlet-810-403    | cbtnuggets-70-697    | educationOracle-1Z0-434    | channel9-70-534    | officialcerts-400-051    | examsboost-IIA-CIA-PART1    | networktut-300-135    | teststarter-300-206    | pluralsight-70-486    | coding-70-486    | freeccna-100-101    | digitaltut-300-101    | iiba-CBAP    | virtuallymikebrown-640-916    | isaca-cism    | whizlabs-pmp    | techexams-70-980    | ciscopress-300-115    | techtarget-cism    | pearsonitcertification-300-070    | testking-2v0-621    | isacaNew-cism    | simplilearn-pmi-rmp    | simplilearn-pmp    | educationOracle-1z0-809    | education-1z0-809    | teachertube-1Z0-434    | villanovau-CBAP    | quora-300-206    | certifyguide-300-208    | cbtnuggets-100-105    | flydumps-70-417    | gratisexams-1V0-605    | ituonline-1z0-062    | techexams-cas-002    | simplilearn-70-534    | pluralsight-70-697    | theiia-IIA-CIA-PART1    | itexamtips-400-051    | pearsonitcertification-EX200    | pluralsight-70-480    | learn-hp0-s42    | giac-gpen    | mindhub-102-400    | coursesmsu-CBAP    | examsforall-2v0-621    | developerhandbook-70-487    | root-EX200    | coderanch-1z0-809    | getfreedumps-1z0-062    | comptia-cas-002    | quora-1z0-809    | boson-300-135    | killtest-2v0-621    | learncia-IIA-CIA-PART3    | computer-gcih    | universitycloudera-cca-500    | itexamrun-70-410    | certificationHPv2-hp0-s41    | certskills-100-105    | skipitnow-70-417    | gocertify-sy0-401    | prep4sure-70-417    | simplilearn-cisa    |
http://www.pmsas.pr.gov.br/wp-content/    | http://www.pmsas.pr.gov.br/wp-content/    |