In this tutorial, you will learn How to LVM Partitioning on a Dedicated Server. LVM stands for Logical Volume Management, which provides us with a high-level view of disk storage, compared to the traditional method. This gives more flexibility to the system administrator to assign space to users and programs. Storage volumes are created under LVM control and can be resized and moved anywhere. LVM allows you to manage Storage Volumes in groups.
To work with LVM, you need to familiarize yourself with the different parts of the LVM building, which we will define here.
1. Volume Group (VG) code:
VG is the highest appearance level used by LVM. A VG aggregates a set of LVs and PVs into a single management unit.
2. Physical Volume (PV) code:
PVs are usually a hard disk or something similar (for example, a Raid Device).
3. Code (LV) Logical Volume:
It is equal to partitions in non-LVM systems.
4. Code (PE) Physical Extent:
Each PV is divided into large pieces of data called PE, these pieces (extent) have a size equal to LE in LVs.
5. Code (LE) Logical extent:
Each LV is divided into large chunks of data called LEs, this size is the same for all LVs in a VG.
In the continuation of this article, we will teach you How to Install LVM on Dedicated Server. Be careful that most new distributions have LVM version 2 and you just need to install it:
apt-get install lvm2
In the first step, you must initialize the partitions. This command creates a VG descriptor on the first disk:
pvcreate /dev/hda5
You can now create a VG by running the following command:
vgcreate my_volume_group /dev/hda5
To access LVs and VGs, you need to enable VGs using the following command:
vgchange -ay my_volume_group
If you want to add another PV to VG, you can do as follows:
vgextend my_volume_group /dev/hdb1
To create an LV with a capacity of 10G, you must use the following command:
lvcreate -L 10G my_volume_group --name my_logical_volume
If you want to create an LV that contains all VGs, use vgdisplay to see the total number of PEs available. Then run the lvcreate command:
vgdisplay | grep "Total PE"
Total PE 3576
In the above command, there are 3576 PEs in this VG. To create an LV that includes all this space, use the following command:
lvcreate -l 3576 my_volume_group --name my_logical_volume
Note: Here, the lowercase letter l is used for the value.
In the previous section, you were completely familiar with how to partition with LVM and its terminology. Now the LV is ready and you can treat it as a normal partition.
Format it by running the following command:
mkfs.ext3 /dev/my_volume_group/my_logical_volume
Then mount it and use it.
Note: if you want it to mount automatically during system startup, add it to fstab.
In this section, we are going to teach you how to develop an LV. Be careful if you add a PV to the VG, or if you have free space in the current VG, you can expand the LV.
There are two ways to develop LV.
The following command increases the LV volume to 12G:
lvextend -L12G /dev/my_volume_group/my_logical_volume
And the following command adds 1 gigabyte to my_logical_volume:
lvextend -L+1G /dev/my_volume_group/my_logical_volume
One thing to note is that after you expand the LV, you need to expand the filesystem to match it. To do this, you can run the following commands:
e2fsck -f /dev/my_volume_group/my_logical_volume
resize2fs /dev/my_volume_group/my_logical_volume
LVM is for the Linux Kernel, which is used to manage disks. This system and mechanism can be implemented for many Linux distributions such as RedHat, CentOS, Fedora, Ubuntu, Debian, Suse, etc. In this post, you learned LVM Partitioning on a Dedicated Server. If you intend to grow your business, we suggest you read the article Exploring the Benefits of Buying a Dedicated Server.
How useful was this post?
Click on a star to rate it!
Average rating 3.8 / 5. Vote count: 8
No votes so far! Be the first to rate this post.
In this article, we are going to teach you Why Do I Need Windows VPS Hosting? Windows VPS server is ...
Nowadays, businesses are constantly seeking ways to stand out from the competition and enhance their...
What is your opinion about this Blog?