LVM: LogicalVolumeManager logical volume manager. The underlying Block devices are combined into a new logical whole through software, which can be managed separately. Mark the hard disk as a special type (8e), and then reorganize these special types of disks into a large whole. It is equivalent to an extended partition, And you can re-partition it. So on the basis of it, You can divide various logical segments. In this structure: the bottom layer is PV, a physical volume. (Real hard drives) in the middle, combining PV
LVM: Logical Volume Manager.
The underlying Block devices are combined into a new logical whole through software, which can be managed separately.
Mark the hard disk as a special type (8e), and then reorganize these special types of disks into a large whole. It is equivalent to an extended partition, And you can re-partition it. So on the basis of it, You can divide various logical segments.
In this structure:
The lowest layer is PV, a physical volume. (Real hard drives)
In the middle, the VG combined by PV is equivalent to an extended partition, which is not usable and needs to be divided into new partitions.
The top is LV, which is the new partition mode after partitioning. LV can be formatted like normal partitions.
LVM expands the original boundary without damaging the original data. Dynamic Scaling. It can be expanded directly throughout the process without formatting.
The volume has another function
Snapshot .).
At a certain moment, users can be prevented from writing data, and then instantly take a snapshot of the data on the hard disk, and then follow the snapshot content when backing up. In this way, the content of the entire logical volume is the same.
======================================
Features of LVM
The size of the disk boundary, which can be dynamically expanded.
Snapshot: This feature provides a very convenient data backup channel. Snapshot Backup does not require much space for storage, but the data is complete.
The logical volume function can be provided in terms of software functions. One is a logical volume and the other is a file system developed by SUN.
LV <------------------ separates extended partitions into new partitions, called the true LVM
VG <---------------- combines physical hard disks to become new extended partitions
PV <-------------- physical hard drives
PE <-------------- physical disk Area
The space for LV extension is actually to add more LE, while LE is actually the mode that PE adds to VG.
When performing the LV operation, you can directly specify the PV to use.
One operating system can have multiple VG and VG can also have multiple lv pvs, and each VG is managed independently.
If you want to remove a PV, You need to first obtain the PV content to another PV.
The commands they support:
PV: pvcreate pvmove pvremove pvscan, pvdisplay
VG: vgcreate vgremove vgscan, vgdisplay vgreduce (scale down, remove a PV from VG) vgextend (ADD, add a PV from VG)
LV: lvcreate lvmove lvremove lvscan, lvdisplay lvreduce lvextend lvresize)
========================================================== ====
How to use PV
① Fdisk. Create partitions by n, and create two primary partitions by p. 5G 15G
② Press t to adjust the two hard disks of the 8e type.
③ Partprobe/dev/sdb
④ Create them as pv
Pvcreate/dev/sdb {1, 2}
⑤ Pvdisplay (view the PV Information)
VG is not added if new pv is contained.
The size of the PE is determined when the VG is created (two PVS cannot be added to the same VG to use different PES)
Usually pvdisplay/dev/sdb1 can display specific information.
⑥ Pvremove can be used to remove
========================================================== ======
How to Use VG (VG must have a name and is essential)
Vgcreate [command] vg name pv Disk
-S is used to specify the PE size.
① First use vgdisplay to check what vg has
PE is generated when VG is created.
② Vgcreate vg0/dev/sdb1
Vg0 is the name and multiple hard disks can be specified.
③ Expand VG
Vgextend vg0/dev/sdb2
Then, sdb2 is added to vg0.
④ If data already exists in VG, you must first use pvmove/dev/sdb1
⑤ Vgreduce can be used to reduce the size of VG only when no data is available.
Vgreduce vg0/dev/sdb1
Then, sdb1 is reduced from vg0.
========================================================== ======
Use various LV commands: (creating LV is troublesome)
For ease of management, almost all options must be manually specified: The size, name, and logical volume must be specified.
① Create LV
Lvcreate-L 2G-n lvm1 vg0
-L: the number of logical disks to be allocated to the lv, not the actual size of space.
-L: specify the size of the space directly. XK xM xG xT
-N: Specifies the name of the Current Logical volume. Name should be known and known as much as possible
Vg0: Specifies the volume group to create
② View LV
Lvdisplay/dev/vg0/lvm1
When viewing the LV, you must only use the path of the physical file. You cannot specify a single name or a volume group name. You can also choose not to specify anything to display all logical volumes.
③ Format the LV partition.
Mke2fs-j/dev/vg0/lvm1
④ LV-mounted Partition
Mount/dev/vg0/lvm1/backup
But when you use mount to view it, you find that/backup is mounted to/dev/mapper/vg0-1vm1.