Linux LVM simple tutorial

Source: Internet
Author: User
Tags hex code

Linux LVM simple tutorial

Logical volume management LVM is a versatile hard disk system tool. Both Linux and other similar systems are very easy to use. It is very troublesome to adjust the size of a traditional partition by using a fixed size partition. However, LVM can create and manage "logical" volumes, rather than directly using physical hard disks. The administrator can elastically scale up and down the management logic volume, and the operation is simple without damaging the stored data. You can add new hard disks to the LVM at will to directly expand existing logical volumes. The LVM does not need to be restarted to let the kernel know the existence of the partition.

LVM uses a layered structure, as shown in.

At the top of the figure, the actual physical disk, its partition, and its physical volume (PV) are used ). One or more physical volumes can be used to create a volume group (VG ). Then, you can create logical volumes (LV) based on the volume group ). As long as there is space available in the volume group, you can create logical volumes as you like. The file system is created on a logical volume and can be mounted and accessed in the operating system.

RHCE125_135 LVM

RHEL5.9 LVM usage

LVM instance Creation

Linux System Management-LVM case

RHCE series LVM-theoretical

LVM Test Description

This article describes how to create and manage LVM volumes in linux. We will divide it into two parts. First, create multiple logical volumes on one hard disk and mount them to the/lvm-mount directory. Then we will resize the created volume. In the second part, we will add additional volumes from the other hard disk to the LVM.

Prepare Disk Partitions

Create a disk partition by using fdisk. We need to create three 1g partitions. Note that the partition size is not required to be consistent. Similarly, partitions must use the '8e' type to make them available for LVM.

  1. # Fdisk/dev/sdb
  1. Command (m for help): n # create
  2. Command action
  3. E extended
  4. P primary partition (1-4)
  5. P # primary Partition
  6. Partition number (1-4): 1 # Partition number
  7. First cylinder (1-1044, default1): # default 1 for vehicle return
  8. Last cylinder, + cylinders or + size {K, M, G} (1-1044, default1044): + 1G # size
  9. Command (m for help): t # change the type
  10. Selected partition 1
  11. Hex code (type L to list codes): 8e # LVM partition code
  12. Changed system type of partition 1 to 8e (Linux LVM)

Repeat the preceding operation to create the other two partitions. After the partition is created, we should have output similar to the following:

  1. # Fdisk-l
  1. DeviceBootStartEndBlocksIdSystem
  2. /Dev/sdb1 11321060258 + 8 eLinux LVM
  3. /Dev/sdb13326410602908 eLinux LVM
  4. /Dev/sdb3 26539610602908 eLinux LVM
Prepare physical volume (PV)

The created partition is used to store physical volumes. LVM can use physical volumes of different sizes.

  1. # Pvcreate/dev/sdb1
  2. # Pvcreate/dev/sdb2
  3. # Pvcreate/dev/sdb3

Run the following command to check the creation of a physical volume. The following part of the output is truncated. "/Dev/sdb2" is a new physical volume of "1.01 GiB.

  1. # Pvdisplay
  1. --- NEW Physical volume ---
  2. PV Name/dev/sdb2
  3. VG Name
  4. PV Size1.01GiB
  5. Allocatable NO
  6. PE Size0
  7. Total PE 0
  8. Free PE 0
  9. Allocated PE 0
  10. Pvuuid jszvzz-ENA2-g5Pd-irhV-T9wi-ZfA3-0xo092

Use the following command to delete a physical volume.

  1. # Pvremove/dev/sdb1
Prepare a volume group (VG)

Run the following command to create a volume group named 'Volume-group1' and use/dev/sdb1,/dev/sdb2 and/dev/sdb3.

  1. # Vgcreate volume-group1/dev/sdb1/dev/sdb2/dev/sdb3

Use the following command to verify the volume group.

  1. # Vgdisplay
  1. --- Volumegroup ---
  2. VG Name volume-group1
  3. System ID
  4. Format lvm2
  5. MetadataAreas3
  6. MetadataSequenceNo1
  7. VG Access read/write
  8. VG Status resizable
  9. Max lv 0
  10. Cur LV 0
  11. Open LV 0
  12. Max PV 0
  13. Cur PV 3
  14. Act PV 3
  15. VG Size3.02GiB
  16. PE Size4.00MiB
  17. Total PE 774
  18. Alloc PE/Size0/0
  19. Free PE/Size774/3.02GiB
  20. Vg uuid bwd2pS-fkAz-lGVZ-qc7C-TaKv-fFUC-IzGNBK

From the output, we can see the volume group usage/total. The physical volume provides space for the volume group. As long as there is space available in this volume group, we can create logical volumes at will.

Use the following command to delete a volume group.

  1. # Vgremove volume-group1

For more details, please continue to read the highlights on the next page:

  • 1
  • 2
  • 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.