LVM is short for Logical Volume Manager, which provides a higher level of disk storage management for hosts. LVM helps system administrators easily allocate storage space for applications and users. Logical volumes under LVM management can be resized or added as needed. In addition, LVM can provide customized naming identifiers for managed logical volumes. Therefore, the use of LVM is mainly to facilitate the management of the storage system, increasing the scalability of the system.
First, prepare lvm environment
1. Hard disk preparation
Added a hard disk /dev/hdb.
Prepared three partitions, scheme As follows: The capacity is 100M, which is only for experimental preparation.
/dev/hdb1
/dev/hdb2
/dev/hdb3
2. Convert partition type to lvm volume
Fdisk /dev/hdb
t to lvm volume type
Device Boot Start End Blocks Id System
/dev/hdb1 1 208 98248+ 8e Linux LVM
/dev/hdb2 209 416 98280 8e Linux LVM
/dev/hdb3 417 624 98280 8e Linux LVM
Then w save and
#partprobe /* Disk partitioning is effective*/
Second, lvm creation process
1. Create physical volumes (PV) from the hard drive partition.
2.Creating volume groups (VGs) from physical volumes
3.Creating logical volumes (LVs) from volume groups and dispatching logical volume mount points , where only logical volumes can write data.
The biggest feature of lvm is that it can dynamically adjust the size of the partition, and can increase the capacity of the disk space as the partition capacity increases.
LVM Configuration and Creation
Third, LVM Physical Volume PV
1. Related Commands
pvcreate Create PV
pvscan Scan PV
pvdisplay Display PV
pvremove Delete PV
partprobe
2.Create a physical volume
If the above capacity is not enough, you can Add another partition to the physical volume.
[root@redhat ~]# pvcreate /dev/hdb1 /dev/hdb2
Physical volume "/dev/hdb1″ successfully created
Physical volume "/Dev/hdb2″ successfully created
[root@redhat ~]# pvscan
PV /dev/hdb1 lvm2 [95.95 MB]
PV /dev/hdb2 lvm2 [95.98 MB]
Total: 2 [191.92 MB] /in use: 0 [0 ] /in no VG: 2 [191.92 MB]
[root@redhat ~]# pvdisplay
- NEW Physical volume -
PV Name /dev/hdb1
VG Name
PV Size 95.95 MB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID 2Ni0Tx-oeSy-zGUP-t7KG -Fh22-0BUi-iyPhhQ
- NEW Physical volume -
PV Name /dev/hdb2
VG Name
PV Size 95.98 MB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID 2XLXfY-V3L2-Mtsl-79U4-ovuJ-YaQf-YV9qHs
Fourth, create LVM volume group VG
1. Related commands
vgcreate Create VG
vgscan Scan VG
vgdispaly
vgextend
vgreduce
vgchange
Vgremove
2.Create logical volume VG
[root@redhat ~]# vgcreate vg0 /dev/hdb1 /dev/hdb2
Volume group "vg0″
[root@redhat ~]# vgscan
Reading all physical volumes. This may take a while…
Found volume group "vg0″ using metadata type lvm2
[root@redhat ~]# vgdisplay
- Volume group -
VG Name vg0
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open L V 0
Max PV 0
Cur PV 2
Act PV 2
VG Size 184.00 MB
PE Size 4.00 MB /*The size of the allocated block defaults to 4M*/
Total PE 46
Alloc PE /Size 0 /0
Free PE /Size 46 /184.00 MB
VG UUID kL5CGk-5Odk-r3PK-9q0A-s94h-OHv4-BojBnH Method to increase VG capacity to 1TB:
vgcreate -s 16M vg0 /dev/hdb1 /dev/hdb2
3. Delete and add logical volumes
[root@redhat ~]# vgreduce vg0 /dev/hdb2
Removed "/dev/hdb2″ from volume group "vg0″
[root@redhat ~]# vgextend vg0 /dev/hdb2
Volume group "vg0″ verified extended
V. Creating LVM logical volume LV
1. Related Commands
lvcreate
lvscan
lvdisplay
lvextend
lvreduce
lvremove
lvresize
2.Create a logical volume LV
[root@redhat ~]# lvcreate -L 184M -n data vg0
Logical volume "data" created
[root@redhat ~]# lvscan
ACTIVE '/dev/vg0/data' [184.00 MB ] inherit
[root@redhat ~]# lvdisplay
- Logical volume -
LV Name /dev/vg0/data
VG Name vg0< Br>
LV UUID HNKO5d-yRre-qVnP-ZT8D-fXir-XTeM-r6WjDX
LV Write Access read/write
LV Status available
# open 0
LV Size 184.00 MB
Current LE 46
Segments 2
Allocation inherit
Read ahead sectors 0
Block device 253:0
VI. Logical Volume LV Mounting LVM
Formatting of lv:
mkfs.ext3 /dev/vg0/data
mdkir /mnt/lvm
mount /dev/vg0/data /mnt/lvm
[root@redhat ~]# ls /mnt/lvm
lost +found
[root@redhat ~]# df -T
File System Type 1K-Blocks Available Available % Mounted Points
/Dev/hda3 ext3 7625092 2219460 5012040 31% /
/dev/hda1 ext3 101086 10006 85861 11% /boot
tmpfs tmpfs 150108 0 150108 0% /dev/shm
/dev/mapper/vg0-data
ext3 182469 5664 167385 4% /mnt/lvm
VII, LVM capacity adjustment
LVM capacity adjustment can be more The links are adjusted, for example, the capacity can be expanded on the physical volume, VG, and LV, which is one of the advantages of LVM.
Keepalived is a high-availability WEB service based on VRRP protocol, which can be used to avoid sin
The following folder on the desktop is shared as a shared folder to the Linux system in the virtual
Basic minimalist directory file after successful production First, the basic boot process of the s
Manually making U disk boot and basic principles for Linux
Linux system shutdown and restart command
Centos7 modify SSH port number
Ubuntu users and permissions (3)
Linux installation using jprofiler8 (tomcat)
Linux ubuntu12.04 Uninstall and install mysql
Linux learning: find command problem
How to uninstall ie10 in Win7 system
Win7 Ultimate version of the four ways to close the default shared file
How to use sed command in Linux
Win8.1 comes with a solution that the Metro app can't use
How to open voice recognition system in WinXP
Set WEB server IIS write permission Protection hacking
Microsoft and dealers secret talks
Group Policy Plus Win 7 Parental Control Restrictions Use Computer
Win7 system accidentally closes the task thumbnail after how to restore