Linux LVM simple tutorial
Logical volume management LVM is a versatile hard disk system tool. Both Linux and other similar systems are very easy to use. It is very troublesome to adjust the size of a traditional partition by using a fixed size partition. However, LVM can create and manage "logical" volumes, rather than directly using physical hard disks. The administrator can elastically scale up and down the management logic volume, and the operation is simple without damaging the stored data. You can add new hard disks to the LVM at will to directly expand existing logical volumes. The LVM does not need to be restarted to let the kernel know the existence of the partition.
LVM uses a layered structure, as shown in.
At the top of the figure, the actual physical disk, its partition, and its physical volume (PV) are used ). One or more physical volumes can be used to create a volume group (VG ). Then, you can create logical volumes (LV) based on the volume group ). As long as there is space available in the volume group, you can create logical volumes as you like. The file system is created on a logical volume and can be mounted and accessed in the operating system.
RHCE125_135 LVM
RHEL5.9 LVM usage
LVM instance Creation
Linux System Management-LVM case
RHCE series LVM-theoretical
LVM Test Description
This article describes how to create and manage LVM volumes in linux. We will divide it into two parts. First, create multiple logical volumes on one hard disk and mount them to the/lvm-mount directory. Then we will resize the created volume. In the second part, we will add additional volumes from the other hard disk to the LVM.
Prepare Disk Partitions
Create a disk partition by using fdisk. We need to create three 1g partitions. Note that the partition size is not required to be consistent. Similarly, partitions must use the '8e' type to make them available for LVM.
- # Fdisk/dev/sdb
- Command (m for help): n # create
- Command action
- E extended
- P primary partition (1-4)
- P # primary Partition
- Partition number (1-4): 1 # Partition number
- First cylinder (1-1044, default1): # default 1 for vehicle return
- Last cylinder, + cylinders or + size {K, M, G} (1-1044, default1044): + 1G # size
- Command (m for help): t # change the type
- Selected partition 1
- Hex code (type L to list codes): 8e # LVM partition code
- Changed system type of partition 1 to 8e (Linux LVM)
Repeat the preceding operation to create the other two partitions. After the partition is created, we should have output similar to the following:
- # Fdisk-l
- DeviceBootStartEndBlocksIdSystem
- /Dev/sdb1 11321060258 + 8 eLinux LVM
- /Dev/sdb13326410602908 eLinux LVM
- /Dev/sdb3 26539610602908 eLinux LVM
Prepare physical volume (PV)
The created partition is used to store physical volumes. LVM can use physical volumes of different sizes.
- # Pvcreate/dev/sdb1
- # Pvcreate/dev/sdb2
- # Pvcreate/dev/sdb3
Run the following command to check the creation of a physical volume. The following part of the output is truncated. "/Dev/sdb2" is a new physical volume of "1.01 GiB.
- # Pvdisplay
- --- NEW Physical volume ---
- PV Name/dev/sdb2
- VG Name
- PV Size1.01GiB
- Allocatable NO
- PE Size0
- Total PE 0
- Free PE 0
- Allocated PE 0
- Pvuuid jszvzz-ENA2-g5Pd-irhV-T9wi-ZfA3-0xo092
Use the following command to delete a physical volume.
- # Pvremove/dev/sdb1
Prepare a volume group (VG)
Run the following command to create a volume group named 'Volume-group1' and use/dev/sdb1,/dev/sdb2 and/dev/sdb3.
- # Vgcreate volume-group1/dev/sdb1/dev/sdb2/dev/sdb3
Use the following command to verify the volume group.
- # Vgdisplay
- --- Volumegroup ---
- VG Name volume-group1
- System ID
- Format lvm2
- MetadataAreas3
- MetadataSequenceNo1
- VG Access read/write
- VG Status resizable
- Max lv 0
- Cur LV 0
- Open LV 0
- Max PV 0
- Cur PV 3
- Act PV 3
- VG Size3.02GiB
- PE Size4.00MiB
- Total PE 774
- Alloc PE/Size0/0
- Free PE/Size774/3.02GiB
- Vg uuid bwd2pS-fkAz-lGVZ-qc7C-TaKv-fFUC-IzGNBK
From the output, we can see the volume group usage/total. The physical volume provides space for the volume group. As long as there is space available in this volume group, we can create logical volumes at will.
Use the following command to delete a volume group.
- # Vgremove volume-group1
For more details, please continue to read the highlights on the next page: