Trending September 2023 # How Lvm Works In Linux With Examples? # Suggested October 2023 # Top 16 Popular | Saigonspaclinic.com

Trending September 2023 # How Lvm Works In Linux With Examples? # Suggested October 2023 # Top 16 Popular

You are reading the article How Lvm Works In Linux With Examples? updated in September 2023 on the website Saigonspaclinic.com. We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested October 2023 How Lvm Works In Linux With Examples?

Introduction to Linux LVM

In today’s world, when the entire world is going to be built on the data it becomes a daunting task for system admins to manage the disk space. In earlier times, when one used to run out of space, a long cumbersome process used to start in order to increase the space available to a disk partition. Not only this the system had to be taken off-line. In Linux LVM or Logical Volume Manager, when introduced in Fedora Linux, was a savior as it was the first time some abstraction layer allowed flexible disk management. To formally define LVM, it is a device mapper framework that enables allocation of space on a mass storage device with a hint of flexibility.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

Syntax:

In Linux, there are infinite possibilities of LVM and in this article, we will discuss the ones which are widely used when it comes to the utility of LVM. In this section we will come face to face with the syntax as in the next section we will take a dig at how LVM works.

1. Display Physical Volumes

pvs

OR

pvdisplay

2. Displaying Volume Groups

Syntax:

vgs

OR

3. Creating Logical Volumes

Syntax:

4. Listing the partition types in Linux

Syntax:

lsblk

5. Mount Logical Volumes

Syntax:

6. Extending a Logical Volume

Syntax:

7. Removing a Logical Volume

Syntax:

How LVM works in Linux?

Now that we syntactically have a brief idea of what a Logical Volume Manager looks like, it is time for us to understand how does LVM works in Linux. To begin with, LVM deals with the management of disk allocation, stripping of disks, mirroring disks, and resizing the logical volumes. Now, if you look at the syntax carefully, you will find that the first 3, has just few alphabets been different or in other words, understanding each of the 3 different chronological portions of the architecture.

The first one is the Physical Volume. This has a LVM utility prefix pv. These are block devices or disk-like devices that act like raw material for LVM to build a higher abstraction layer. The next item on the architecture is Volume Group which has utility prefix vg. LVM helps in a combination of physical volumes into pools of storage. These layer abstracts the characteristics of the underlying device. The third and the last is Logical Volume, which is prefixed as lv. This is analogous to partition on a physical disk, except having a bit more flexibility. All these three can be considered as a subset within the previous one, i.e. Logical Volume group is combined to Volume Group, Pool of volume groups make a physical volume.

Now that we have a complete understanding of LVM and its different components, let us start with some chronological order of steps. For using LVM, we would first need to create a partition on the unpartitioned disk. For the sake of this article, we will assume that the partition can be created on the single partitions. The other, by the way, is a raw and unpartitioned hard disk. For this, cfdisk command is used. Next is to have physical volumes created, for which pvcreate command is used. Once the physical volume is created it is time to create a volume group inside that, as this is the group which will act like a container for all of our storage. Now we need to create the most granular level of the architecture, i.e. Logical volume. It is like cutting smaller pieces of cake from a big piece of cake. This smaller logical volume can be of any number, but the net size of all these smaller pieces of cake should never exceed that of the volume group where these logical volumes are created.

At this point of time, our logical volume is ready to use. At this point, we can start creating file systems in our logical volumes. One should be aware of the fact that a small % of space is reserved for super-users (by default 5%).

Examples

Lets us discuss the examples of Linux LVM.

Example #1 – Display Physical Volumes

Syntax:

pvs

Output:

Example #2 – Displaying Volume Groups

Syntax:

vgs

Output:

Example #3 – Creating Logical Volumes

Syntax:

lvcreate -L 5G -n EduCBAVol1 EduCBADemoGrp lvcreate -L 2G -n EduCBAVol2 EduCBADemoGrp lvcreate -L 1G -n EduCBAVol3 EduCBADemoGrp

Post creating of Logical Volume:

Syntax:

vgs -o +lv_size,lv_name

Output:

Example #4 – Listing the partition types in Linux

Syntax:

lsblk

Output:

Example #5 – Mount Logical Volumes Syntax: mount /dev/EduCBADemoGrp/EduCBAVol1 /mnt/EduCBAVol1 mount /dev/EduCBADemoGrp/EduCBAVol2 /mnt/EduCBAVol2 mount /dev/EduCBADemoGrp/EduCBAVol3 /mnt/EduCBAVol3 vi /etc/fstab

Output:

Example #6 – Extending a Logical Volume

Syntax:

lvextend -L +600 /dev/EduCBADemoGrp/EduCBAVol1

Output:

Example #7 – Removing a Logical Volume

Syntax:

lvremove /dev/EduCBADemoGrp/EduCBAVol2

Output:

Conclusion

With the set of examples and explanations to working of how LVM works and what different utilities the command caters to in Linux. We encourage you to experiment more with different parameters and get acquainted with some failure modes which acts like a block for using LVM in some scenarios!

Recommended Articles

We hope that this EDUCBA information on “Linux LVM” was beneficial to you. You can view EDUCBA’s recommended articles for more information.

You're reading How Lvm Works In Linux With Examples?

Update the detailed information about How Lvm Works In Linux With Examples? on the Saigonspaclinic.com website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!