LINUX creation and management of logical volumes

xiaoxiao2021-03-06  64

LVM (Logicl Volume Manager), logical volume manager, by using the logical volume manager to manage the hard disk storage device, you can achieve dynamic division and adjustment of the hard disk space.

First, basic concept

1. Physical volume ----- PV (Physical Volume) Physical volume is in the bottom of logical volume management, which can be partitioned on the actual physical hard disk, or the entire physical hard disk.

2, the volume group -------- VG (Volumne Group) The volume group is established on the physical volume, at least one physical volume in a volume group, which can be dynamically added to the volume group after the volume group is established. in. A logical volume management system project can have only one volume group or multiple volume groups.

3, logical volume ----- LV (Logical Volume) logical volume is built on the volume group, the unallocated space in the volume group can be used to establish a new logical volume, and the logical volume can be dynamically expanded and reduced. . Multiple logical volumes in the system are in the same volume group, or may belong to different multiple volume groups.

4, physical area -pe "physical area is the minimum storage unit that can be used for allocation in the physical volume, and the size of the physical area can be specified when establishing a physical volume according to the actual situation. Once the physical zone size is determined, the physical area of ​​all physical volumes in the same volume group needs to be consistent.

5. The logical area -le (Logical Extent) logic area is the minimum storage unit that can be used for allocation in the logical volume, and the size of the logical area depends on the size of the physical area in the volume group where the logical volume is located.

6. Volume Group Description Area ----- (Volume Group Descriptor Area) Volume Group Description Area exists in each physical volume, used to describe the physical volume itself, the logical volume and logic in the volume group belonging to the volume group All information such as the allocation of the physical area in the volume, the volume group description area is established when using PVCReate to establish a physical volume.

Second, the general operation of LVM

1. Create a physical volume on disk partition #fdisk / dev / hdb # pvdisplay / dev / hdb1 // build physical volume on a partition or hard disk, a physical volume # pvcreate / dev / hdb1

2. Use the physical volume to establish a volume group #vgcreate myvg / dev / hdb1 // to establish a volume group, you can add a new physical volume to the already volume group as needed in the future.

3. Establish a logical volume in the volume group #Lvcreate -l 10m -n mylv1 myvg // Establish a logical volume from the already volume group, usually only partially assigned some space to the log // series

4. Create a file system 5 on the logical volume, mount the file system into the directory tree of the Linux system, add a new physical volume in the volume group, when there is not enough space in the volume group to be assigned to logical volumes, you can use The VGExtend command adds a new physical volume to the volume group to expand the volume group capacity. In one special case, the existing physical volume in the volume group can also be displayed. #vgextend myvg / dev / hdb2

7. Capacity of the expansion logical volume When the logical volume is not met, you can use the LVEXTEND command to assign the idle space in the volume group to the logical volume to extend the capacity of the logical volume. When the idle space of the logical volume is too large, you can also use the LVReduce command to reduce the capacity of the logical volume. This enables dynamic adjustment of logical volume capacity. #LVEXTEND -L 4M / dev / myvg / myLV

8, adjust the size of the file system in the logical volume

Third, common order

1. Physical volume command General maintenance command: #pvscan // Search for existing physical volume # pvdisplay physical rolls in all disks of the system to display the properties of the specified physical volume. #PVDATA Physical Volume Path Name // Used to display the volume group description area information of the physical volume for debugging purposes. #pvchange -x | --allocation {y | n} Physical Volume Path Name // Used to change the allocation license setting of the physical volume

The creation of the physical volume and the delete command # pvcreate device full path name // is used to create physical volume initialization information on a disk or disk partition to manage the // The physical volume is logical. #PVMOVE Source Physical Volume Hot Path I [Purpose Physical Volume Path Name] // Used to move data from a physical volume to other specialty volumes in the same volume group. 2, volume group command General Maintenance Command #vgscan // Instructions All Disk #vgck [Volume Group] // for check the consistency of the volume group in the volume group. #vgdisplay [volume group name] // Display the property information #vgrename Original volume group name new volume group name #vgchange -a y | n [volume group name] // change the corresponding attribute of the volume group. Whether or not #vgchange -l maximum logical volume // Volume group can accommodate the maximum logical volume #vgchange -xy | n [volume group name] // Volume is valid #vgmknodes [volume group name | volume group path] /// Used to establish (re-establish) Existing volume group directory and device text /

The backup and recovery command #vgcfgbackup [volume group name] // back up the VGDA information in the volume group to the file #vgcfgrestore -n volume group name Physical Volume is named /// Information from the backup file must specify the information of the physical volume

Create and delete command #vgcreate volume group name physical volume full path name [physical roll full path name] #vgmove volume group name

Volume group expansion and reduction command #vgextend volume group name physical volume full path name [physical volume full path name] #vgreduce volume group name physical volume full path name [physical volume full path name]

The consolidation of the volume group and the split #vgmerge destination volume group name source volume group name // combined two existing volume groups, requiring the physical // regional size of the two volume groups equal to, and the source volume group is non-active. #vgsplit existing volume group new volume group physical volume full path name [physical volume full path name]

Volume group input and output command #vgexport volume group name #vgimport volume group name volume group Physical volume in the volume group

3, logical volume command general command # lvscan # lvdisplay logical volume full path name [logical volume full path name] #LVRENAME old logical volume full path name new logical volume full path name #LVRENAME volume group name old logical volume name new logical volume name # lvchange # e2fsadm -l | - Logic Volume Adjustment Logic Volume Full Path Name

Logical volume creation with delete command # lvcreate # lvremove

Logical volume expansion and zoom command #LVEXTEND -L | --SIZE logical volume size incremental logic roll full path name #LvReduce Q -L | --Size logical volume minus logical volume full path name

4, logical volume management command #LVMDiskscan // detects all SCSI, IDE and other storage devices #LVMChange -r | --RESET // Reset logical volume manager #LVMSADC [log file full path name] // recipient logical volume management Read the statistics to save to the logen //. #LVMSAR log file full path name // read and report the read and write statistics of the logical volume // manager from the log file generated by the LVMSADC command. If you have any questions, please contact me: Webmaster@bcxy.com

转载请注明原文地址:https://www.9cbs.com/read-111538.html

New Post(0)