LVMLogical Volume Manager
Physical Volume of PV (physical volume)
VG (volume group) volume group
LV (logical volume) logical volume
1. fdisk/dev/SDB
Partition sdb1, sdb2, sdb3
Partition type 8e (Linux LVM)
If the system is using SDB, restart the system to re-read the partition table information of the SDB.
2. # pvcreate/dev/SDB [1-3] initialize the physical volume
3. # vgscan scans physical volumes and creates a volume group database
4. # vgcreate vg0/dev/sdb1/dev/sdb2 use sdb1 and sdb2 to create a volume group vg0
# Vgdisplay vg0
5. # lvcreate-N data-l 10 m Create a new name named data from vg0 in vg0, size 10 m Logical volume
6. # format mkfs. ext3/dev/vg0/Data
7. # Mount/dev/vg0/data/mnt
# Lvdisplay/dev/vg0/data view partition of logical volume data
# Lvcreate-n test-L 5 vg0 use-L to specify the number of logical volumes. The default size of logical volumes is 4 MB, that is, 20 mb.
You must format mkfs. ext3 before using the created logical volume.
# Lvscan scan logical volumes to view their activity
# Lvextend-L + 20 m /Dev/vg0/data to expand the logical volume 20 m , Umount partition first, and then expand
# E2fsck-F/dev/vg0/Data forcibly check the data logical volume
# Resize2fs/dev/vg0/Data redefinition of partition size
The preceding three steps must be performed in sequence.
# View the current physical volume of the system using pvscan
# Vgextend vg0/dev/sdb2 expand the volume group vg0 and add the partition sdb3 to the volume group
# Pvmove/dev/sdb1 remove a physical volume
# Vgreduce vg0/dev/sdb1 Delete sdb1 from the volume group
Pvmove removes data, but sdb1 is still in vg0 and belongs to the volume group area. vgreduce deletes sdb1 from vg0.
When creating a volume group, the default PE size is 4 MB, and the maximum LV size is 256 GB.
# Vgcreate-S 8 m Vg1/dev/sdb1
-S specifies the PE block size
You can change the maximum logical volume capacity allowed by the volume group by changing the PE block size.
TIPS:
# Clear screen
# DF-lH shows the current partition mounting STATUS OF THE SYSTEM
Create snapshot (back up data)
# Lvcreate-S-l 52 m -N snap/dev/vg0/Data
-S indicates a snapshot.
-L the snapshot size must be greater than or equal to the logical volume data
-N snapshot name
Snapshots can be used without formatting
Procedure for deleting a logical volume
1. umount all LV
2. lvremove/dev/vg0/data (viewed through lvscan) If there is a snapshot, remove the snapshot before removing the logical volume.
3. # vgremove vg0
If any errors occur during use, you can view the system logs.
# Tail/var/log/message