Create LVM volumes in LINUX

Source: Internet
Author: User
Article Title: Create LVM volumes in LINUX. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

LVM is a mechanism provided by IBM on the AIX system that enables AIX administrators to use disk space more elastically. Later, IBM transplanted the LVM technology to the LINUX system. From REDHAT9.0, REDHAT provides LVM functions in its own products.
LVM is short for logical disk volume Management (LogicalVolumeManager). 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. The LVM system administrator can easily manage disk partitions. For example, you can connect several disk partitions to an entire volume group (volumegroup) to form a storage pool. The administrator can create a logical volume group (logicalvolumes) at Will on the volume group and create a file system on the logical volume group. Through LVM, administrators can easily adjust the size of storage volume groups and name, manage, and allocate disk storage by group. For example, they can define disk storage by usage: "development" and "sales" instead of using the physical disk names "sda" and "sdb ". When a new disk is added to the system, the LVM Administrator does not need to move the disk files to the new disk to make full use of the new storage space. Instead, the file system can be directly expanded to span the disk.


Ii. Basic Terms of LVM
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. First, we will discuss the following LVM terms:
* Physical storage media (Thephysicalmedia)
This refers to the storage device of the system, such as/dev/hda1 and/dev/sda. It is the storage unit at the lowest layer of the storage system.
* Physical volume (physicalvolume)
A physical volume refers to a hard disk partition or a device (such as RAID) with the same functions as a disk partition logically. It is the basic storage Logical Block of LVM, however, compared with basic physical storage media (such as partitions and disks), it contains management parameters related to LVM.
* Volume group (VolumeGroup)
An LVM volume group is similar to a physical hard disk in a non-LVM system and consists of physical volumes. You can create one or more "LVM partitions" (logical volumes) on the volume group. The LVM volume group consists of one or more physical volumes.
* Logicalvolume)
The logical volume of LVM is similar to the hard disk partition in a non-LVM system. A file system (such as/home or/usr) can be created on the logical volume ).
* PE (physicalextent)
Each physical volume is divided into basic units called PhysicalExtents. pes with unique numbers are the smallest units that can be addressed by LVM. The PE size is configurable. The default value is 4 MB.
* LE (logicalextent)
Logical volumes are also divided into the addressable basic units called LE (LogicalExtents. In the same volume group, the LE size and PE are the same and one-to-one correspondence.
First, we can see that the physical volume (PV) is composed of an equivalent basic unit PE.
A volume group consists of one or more physical volumes.
As you can see, PE and LE have a one-to-one relationship. The logical volume is created on the volume group. A logical volume is equivalent to a non-LVM system disk partition. You can create a file system on it.
I will not talk about other concepts. Next I will introduce how to create LVM volumes.

1. view the available disk space in the system and set the partition ID to 8e.
# Fdisk/dev/hda; if it is SCSI or SATA, It is/dev/sda
Input p to view partitions
Execute the t command to notify fdisk that I want to modify the system identifier data of the partition.
Specify the Partition Number to modify
Directly specify the new system identifier as 8e
Input w to save
Last restart (you can enter partprobe without restarting)
2. Create a physical volume
# Pvcreate/dev/hda13; set the Partition Number to 13.
Physical volume "/dev/hda13" successfully created
3. Create a volume group
# Vgcreate mainVG/dev/hda13
Volume group "mainVG" successfully created
4. Create a logical volume
The following is an example of creating a MB logical volume space:
# LV create-L 100 M-n 1 stLV mainVG
Logical volume "1 stLV" created
After creating a logical volume, you can use the logical volume as a partition. For example, you can create a file system on the logical volume and mount the file system.
It is worth noting that do not forget to create a file system
Take my LVM as an Example
# Mkfs-t ext3/dev/mainVG/1 stLV
Then mount it.
Method for detaching a volume:
Detach a physical volume: pvremove PVDEVICE
Unmount volume group: vgremove VGNAME
Unmount logical volume: lvremove LVDEVICE
Sequence of uninstallation: Logic first and then the last physical volume of the volume group
Do not forget to back up before uninstalling

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.