Create and manage LVM Logical Volumes in Linux

Source: Internet
Author: User
LVM (LogiclVolumeManager) and logical volume manager. by using the logical volume manager to manage hard disk storage devices, you can dynamically divide and adjust the hard disk space. I. basic concepts 1. physical volume ----- PV (PhysicalVolume) physical volume is at the lowest level in logical volume management. it can be a partition on a physical hard disk or

LVM (Logicl VolumeManager) and logical volume manager. by using the logical volume manager to manage hard disk storage devices, you can dynamically divide and adjust the hard disk space.

I. Basic concepts

1. Physical Volume ----- PV (Physical Volume)

The physical volume is at the bottom of the logical volume management. it can be a partition on the actual physical hard disk or the entire physical hard disk.

2. volume Group -------- VG (Volumne Group)

A volume is created on top of a physical volume. a volume group must contain at least one physical volume. after a volume group is created, the physical volume can be dynamically added to the volume group. A logical volume management system project can have only one or more volume groups.

3. Logical Volume ----- LV (Logical Volume)

The logical volume is created on the volume group. unallocated space in the volume group can be used to create new logical volumes. after the logical volume is created, the space can be dynamically expanded and reduced. Multiple logical volumes in the system must belong to the same volume group or different volume groups.

4. Physical zone-PE (Physical Extent)

The physical area is the minimum storage unit that can be allocated to a physical volume. The size of the physical area can be specified when a physical volume is created based on the actual situation. The physical region size cannot be changed once determined. the physical regions of all physical volumes in the same volume group must be consistent.

5. what is the logical region? LE (Logical Extent)

The logical area is the minimum storage unit that can be allocated in a logical volume. 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 DescriptorArea)

The volume group description area exists in each physical volume and is used to describe the physical volume itself, the volume group to which the physical volume belongs, the logical volume in the volume group, and the allocation of physical areas in the logical volume, the volume group description area is created when you use pvcreate to create a physical volume.

II. general LVM operations

1. create a physical volume on the disk partition

# Fdisk/dev/hdb

# Pvdisplay/dev/hdb1 // create a physical volume on the created partition or hard disk

# Pvcreate/dev/hdb1

2. create a volume group using physical volumes

# Vgcreate myVG/dev/hdb1 // Create a volume group. you can add new physical volumes to an existing volume group as needed.

3. create a logical volume in the volume Group

# Lvcreate CL 10 M Cn myLV1 myVG // create a logical volume from an existing volume group. Generally, only part of the space is allocated to this volume. //

4. create a file system on a logical volume

5. mount the file system to the directory tree of the Linux system

6. add a new physical volume to the volume group.

When the volume group does not have enough space to allocate to the logical volume, you can use the vgextend command to add a new physical volume to the volume Group to expand the volume group capacity. In special cases, you can also remove existing physical volumes from the volume group.

# Vgextend myVG/dev/hdb2

7. expand the capacity of the logical volume

When the space of the logical volume cannot meet the requirements, you can use the lvextend command to allocate the free space in the volume group to the logical volume to expand the capacity of the logical volume. When the free space of the logical volume is too large, you can also use the lvreduce command to reduce the capacity of the logical volume. In this way, the logical volume capacity is dynamically adjusted.

# Lvextend CL + 4 M/dev/myVG/myLV

8. adjust the file system size in the logical volume

III. common commands

1. physical volume command

General maintenance commands:

# Pvscan // search for existing physical volumes on all disks of the system

# Pvdisplay physical volume full path name // used to display the properties of the specified physical volume.

# Pvdata physical volume full path name // displays the volume group description area information of the physical volume for debugging purposes.

# Pvchange Cx | -- allocation {y | n} full physical volume path name // used to change the physical volume allocation permission settings

Command for creating and deleting physical volumes

# Pvcreate device full path name // used to create physical volume initialization information on a disk or disk partition, so that

// Logical volume management for this physical volume.

# Pvmove source physical volume full path I [target physical volume full path name] // used to convert data in a physical volume

// Move to other special journals in the same volume group.

2. Volume Group Command

General Maintenance Commands

# Vgscan // Check all disks in the system

# Vgck [Volume group name] // used to check the consistency of volume group description region information in the volume group.

# Vgdisplay [Volume group name] // display the volume group attributes

# Vgrename original volume group name new volume group name

# Vgchange-a y | n [Volume group name] // change the corresponding attributes of the volume group. Allocable or not

# Vgchange-l maximum number of logical volumes // the maximum number of logical volumes that a volume group can accommodate

# Vgchange-x y | n [Volume group name] // whether the volume is valid

# Vgmknodes [Volume group name | volume Group path] // used to create (re-establish) an existing volume Group Directory and the device files in it

// Piece

Backup and Recovery commands for volume group configuration

# Vgcfgbackup [Volume group name] // back up VGDA information in the volume group to a file in the "/etc/lvmconf" directory

# Vgcfgrestore-n volume group name physical volume full path name // you must specify the physical volume information from the backup file

Volume Group creation and deletion commands

# Vgcreate volume group name physical volume full path name [physical volume full path name]

# Vgmove volume group name

Command to expand or contract a volume Group

# 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]

Merge and split a volume Group

# Vgmerge target volume group name source volume group name // merge two existing volume groups, requiring the physical

// The Source volume group is not active when the region size is equal.

# Vgsplit full path name of the physical volume in the new volume Group of the existing volume Group [full path name of the physical volume]

Volume Group input and output commands

# Vgexport volume group name

# Vgimport volume group name physical volume in the volume Group [physical volume in the volume Group]

3. logical volume command

General Commands

#LvsCan

# Lvdisplay full logical volume path name [full logical volume 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 + |-full path name of the logical volume

Command for creating and deleting logical volumes

# Lvcreate

# Lvremove

Logic volume expansion and reduction commands

# Lvextend-L | -- size + logical volume size incremental logical volume full path name

# Lvreduce q-L | -- size + logical volume reduction full logical volume path name

4. logical volume management commands

# Lvmdiskscan // Check all storage devices such as SCSI and IDE

# Lvmchange-R | -- reset // reset logical volume manager

# Lvmsadc [full log file path name] // read/write statistics of the receiver Logical Volume Manager, saved to the log file

.

# Full path name of the lvmsar log file // read and report the logical volume from the log file generated by the lvmsadc command

// Read/write statistics of the manager.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.