LVM development needs
When you use a Linux system, you need to install a GB disk to meet the current work requirements. However, as the company develops, you find that the space for storing data increases, will you buy another disk for installation on the machine? Data is copied every time a disk is re-allocated. Is it very troublesome for you to work? If we use LVM, we can solve such disk management problems.
LVM Introduction
The straightforward translation of LVM (logical volume manager) is: Logical scroll bar administrator, that is, logical volume management. It is a mechanism for managing disk partitions in Linux. LVM is a logical layer built on hard disks and partitions to improve the flexibility of disk partition management. LVM is a logical layer added between the disk partition and the file system. LVM allows each disk partition in the lower layer to be viewed as a large disk by the file system for use by the file system.
LVM has the following knowledge,
PV (physical volume) object scroll bar
PV is the most basic physical component of LVM. The fdisk command is used to convert the actual partition into the 8e system format, and the command pvcreate is used to convert the partition into the physical volume that can be used.
PE (physical extend) entity extended Block
PE is the smallest storage unit of LVM, generally 4 MB. It is the basic unit of VG. PE is the unit of data storage for VG, for example, block. The PE size is not fixed, but changeable. Therefore, PE determines the flexibility of LVM, that is, it can be expanded or reduced.
VG (volume group) scroll bar group
VG, just like the disk we use, can be partitioned. For the file system on the LVM, VG is a large disk. When the file system does not see the components below the LVM, it is used only, while the LVM is responsible for managing the components below.
LV (logical volume) logic scroll bar
LV is something that VG cut into similar partitions. We can use it for formatting and mounting. However, LV is cut into VG, and VG is composed of a large number of PES, therefore, the LV size depends on the number of PES contained in the LV. (Picture from laruence private dish (3 edition) 650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/3E/D9/wKioL1PH41Th5TRSAACCMbNZ2dM319.jpg "Title =" 12.png" alt = "wkiol1ph41th5trsaaccmbnz2dm319.jpg"/>
The specific operating mechanism of LVM is as follows:(The image is a bit rough with word)
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/3E/DB/wKioL1PH53LzTkf7AAGL6wMjGwo827.jpg "Title =" 2.png" alt = "wkiol1ph53lztkf7aagl6wmjgwo827.jpg"/>
For example, from the grass-roots layer, convert partition to the PV of the upper layer, use the PV set to synthesize the VG, and then separate the VG into the LV, and finally mount and use it.
The process:
Step 1: Use fdisk to create the system format of the partition, for example:
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/3E/DE/wKioL1PH7UXR8qp1AAGDR5_XFTo307.jpg "Title =" 6.png" alt = "wkiol1ph7uxr8qp1aagdr5_xfto307.jpg"/>
(We can see that the following system is Linux, which cannot be used as LVM. It needs to be converted to 8E Linux LVM format, such as hda6, 7,8)
Step 2: Use pvcreate/dev/hda {6, 7, 8, 9} to create a PV.
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/3E/DE/wKioL1PH7SaQiVFrAADrU6VMpqo258.jpg "Title =" 7.png" alt = "wkiol1ph7saqivfraadru6vmpqo258.jpg"/>
Step 3: Create a VG using PV, specify the PE size as 16 MB, and use vgscan to view the creation result.
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/3E/DF/wKiom1PH7PyS1bC1AABiFO4HWNE650.jpg "Title =" 10.png" alt = "wkiom1ph7pys1bc1aabifo4hwnew.jpg"/>
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/3E/DF/wKiom1PH7X-BKnvLAACl2scma9Q318.jpg "Title =" 8.png" alt = "wKiom1PH7X-BKnvLAACl2scma9Q318.jpg"/>
Step 4: Separate VG to become LV. the following commands are required for LV,
For example, lvcreate lvscan lvdisplay.
LVM features scalability and capacity reduction, which determines LVM Flexibility Management.
Command: lvextend,
Create a/dev/hda10 file and extend the hda10 file to the created logical volume.
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/3E/E0/wKioL1PH8T6yNiA_AABW-5e1FzM272.jpg "Title =" qq20140717242534.png "alt =" wKioL1PH8T6yNiA_AABW-5e1FzM272.jpg "/>
Instead, lvresize-is used to reduce the capacity -.
Some commands used in the entire LVM operation are as follows:
When creating a partition, fdisk, set 8e system format,
Then let the kernel repeat the newly created partitiong, kpartx-AF Device
Partx-
When PV is created, pvcreate, pvscan, and pvdisplay
When creating VG, vgcreate, vgscan, and vgdisplay
Lvcreate, lvscan lvdisplay lvextend lvreduce lvremove
Finally, create a filesystem and mkfs for the logical volume.
The Mount and unmount commands are used for mounting.
This article from the "Linux small pot friends" blog, please be sure to keep this source http://ny0716.blog.51cto.com/9154254/1439756