Linux logical volume management LVM

Source: Internet
Author: User

LVM is short for Logical Volume Manager. 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. As mentioned above, LVM is a logical layer added between the disk partition and the file system to shield the file system from the underlying disk partition layout and provide an abstract disk volume, create a file system on the disk.

Related Concepts:

Physical Volume PV: Refers to a hard disk partition or a device that looks logically similar to a hard disk partition (such as a RAID device ).

Logical Volume LV: one or more physical volumes form one logical volume.

Volume group VG: one or more logical volumes form a volume group. A volume group combines multiple logical volumes to form a manageable unit.

Physical block PE: physical volumes are stored in units of equal size blocks. The block size is the same as the logical volume block size in the volume group.

Logical Block LE: Logical volumes are stored in blocks. The block size of all logical volumes in a volume group is the same.

  • Create a physical partition
  1. Before using LVM, you must first partition the disk, that is, use the fdisk command to partition the disk. You must specify the partition type as linux LVM, the corresponding ID is 8e (in fact, LVM can also identify linux's default partition type 83)
  2. [Root @ rhel5 ~] # Fdisk-l
  3. Disk/dev/sda: 21.4 GB, 21474836480 bytes
  4. 255 heads, 63 sectors/track, 2610 cylinders
  5. Units = cylinders of 16065*512 = 8225280 bytes
  6. Device Boot Start End Blocks Id System
  7. /Dev/sda1*1 13 104391 83 Linux
  8. /Dev/sda2 14 78 522112 + 82 Linux swap/Solaris
  9. /Dev/sda3 79 1383 10482412 + 8e Linux LVM
  10. /Dev/sda4 1384 2610 9855877 + 5 Extended
  11. /Dev/sda5 1384 1994 4907826 83 Linux
  12. [Root @ rhel5 ~] # Fdisk-t 8e/dev/sda5
  • Create a physical volume PV
  1. The command for creating a physical volume is pvcreate. You can use this command to create all the disk partitions or the entire disk to be added to the volume group (VG) as a physical volume. Format:
  2. Pvcreate disk partition or entire disk
  3. [Root @ rhel5 ~] # Pvcreate/dev/sda5
  4. Physical volume "/dev/sda5" successfully created
  • Create/activate volume group VG
  1. The command for creating a volume group is vgcreate, in the format:
  2. Vgcreate volume group name physical volume
  3. [Root @ rhel5 ~] # Vgcreate iscsi/dev/sda5
  4. Volume group "iscsi" successfully created
  5. After creating a volume group, you can use the vgchange command to activate the volume group without restarting the system. The format of Vgchange is as follows:
  6. Vgchange-a y volume group name (activate volume group)
  7. Vgchange-a n volume group name (Disable volume group)
  • Create logical Volume LV
  1. The command for creating logical volumes is lvcreate. The common format is:
  2. Lvcreate [-L logical volume size |-l number of PES]-n volume group name to which the logical volume name belongs
  3. Where:
  4. -L: the size of the logical volume that is followed by K, M, and G. Such as 100 M, 10g, etc.
  5. -L: Use the number of PES to calculate the logical volume size.
  6. [Root @ rhel5 ~] # Lvcreate-n sharedisk-L 2G iscsi
  7. Logical volume "sharedisk" created
  • Displays PV, VG, and LV attributes.
  1. [Root @ rhel5 ~] # Pvs
  2. Pv vg Fmt Attr PSize PFree
  3. /Dev/sda3 rootvg lvm2 a-9.97G 0
  4. /Dev/sda5 iscsi lvm2 a-4.68G 4.68G
  5. [Root @ rhel5 ~] # Vgs
  6. VG # PV # LV # SN Attr VSize VFree
  7. Iscsi 1 0 0 wz -- n-4.68G 4.68G
  8. Rootvg 1 1 0 wz-n-9.97G 0
  9. [Root @ rhel5 ~] # Lvs
  10. Lv vg Attr LSize Origin Snap % Move Log Copy % Convert
  11. Sharedisk iscsi-wi-ao 2.00G
  12. Rootlv rootvg-wi-ao 9.97G
  13. You can also view more detailed information through pvdisplay, vgdisplay, and lvdisplay.
  • 1
  • 2
  • 3
  • 4
  • Next Page

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.