Linux LVM HDD Management and LVM expansion-Reprint

Source: Internet
Author: User

Linux LVM HDD Management and LVM expansion

LVM Disk Management

I. Introduction of LVM ... 1

Second, the basic terminology of LVM ... 2

Iii. installation of LVM ... 3

Iv. Creating and Managing LVM ... 4

2. Create PV. 6

3. Create VG. 7

4. Create LV. 9

5. LV format and Mount ... 10

I. Introduction of LVM

LVM is shorthand for Logical Volume Manager (Logical Volume management), which is implemented by Heinz Mauelshagen on the Linux 2.4 kernel. LVM sets the partition of one or more hard disks logically, equivalent to a large hard disk to use, when the hard disk space is not enough to use, you can continue to add the partitions of other hard disks, so that the dynamic management of disk space, relative to the normal disk partition has a lot of flexibility.

LVM provides a higher level of disk storage for computers than traditional disks and partitions. It makes it easier for system administrators to allocate storage space for apps and users. Storage volumes under LVM management can be resized and removed as needed at any time (file system tools may need to be upgraded). LVM also allows storage volumes to be managed by user groups, allowing administrators to identify storage volumes with more intuitive names (such as "Sales", "development") instead of physical disk names (such as ' SDA ', ' SDB ').

LVM Model:

A large amount of space can be composed of four partitions, and then some logical partitions are partitioned, and when there is not enough space for a logical partition, some space can be allocated from the remaining space to the partition where space is not available.

Ii. Basic terminology of LVM

As mentioned earlier, LVM is a logical layer that is added between the disk partition and the file system to mask the underlying disk partition layout for the file system, providing an abstract disk volume, and creating a file system on the disk volume. First we discuss the following LVM terminology:

Physical storage media (the physical media): This refers to the system's storage device: The hard disk, such as:/DEV/HDA1,/DEV/SDA, etc., is the lowest layer of storage system storage unit.

Physical volume (physical volume): a physical volume refers to a hard disk partition or a device (such as RAID) that logically has the same function as a disk partition, which is the basic storage logic block of LVM, but is compared to basic physical storage media (such as partitions, disks, etc.) and contains management parameters related to LVM.

Volume group (Volume Group): LVM volume groups are similar to physical hard disks in non-LVM systems, which consist of physical volumes. You can create one or more LVM partitions (logical volumes) on a volume group, and an LVM volume group consists of one or more physical volumes.

Logical volumes (logical volume): LVM logical volumes are similar to hard disk partitions in non-LVM systems, and file systems (such as/home or/usr) can be created on top of logical volumes.

PE (physical extent): each physical volume is divided into a basic unit called PE (physical extents), with a uniquely numbered PE being the smallest unit that can be addressed by LVM. The size of the PE is configurable and defaults to 4MB.

Le (logical extent): Logical volumes are also divided into addressable basic units called LE (logical extents). In the same volume group, the size of Le is the same as the PE, and one by one corresponds.

In simple terms:

PV: is a physical partition of the disk

The physical disk partition in VG:LVM, which is PV, must be added to the VG, which can be understood as a warehouse or a few large hard disks.

LV: The logical partition from the VG

As shown in PV, VG, LV three relations:

Iii. installation of LVM
First determine if the LVM tool is installed in the system:
[Email protected] root]# Rpm–qa|grep LVM
Lvm-1.0.3-4
If the command result input is similar to the previous example, the system already has the LVM management tool installed, and if the command does not have output, then the LVM management tool is not installed, you need to download from the network or install the LVM RPM Toolkit from the CD.

Iv. Creating and Managing LVM

To create an LVM system, you typically need to go through the following steps:
1. Create a partition

Using the partitioning tool (such as FDISK, etc.) to create an LVM partition is the same way as creating other general partitions, except that the partition type of LVM is only 8e. As shown in the following figure:

View disk partition Table

Use Fdisk to create a partition to enter partition management based on the absolute path (/DEV/HDA) of the device file

Be sure to specify a partition format of 8e , this is LVM the partition format

2. Create PV

3. Create VG

After the VG is created, a LV can be divided from the VG.

4. Create LV

A partition named Lvdata, with a capacity size of 100M, is created, where:-L: Specifies the size of the LV-N: Specifies the name of the LV. VO1GROUP00: Represents the division of LV from this VG;

5. LV format and Mount

The next step is to format the LV (using MKSF for formatting), and then LV to store the data

The formatted LV partition is mounted to the specified directory, and the data can be stored like a normal directory.

Once mounted, you can see the capacity of this LV.

If you want to start the LV when the system starts, it is best to write lvdata to the fstable file as follows:

Using the Vim editor, Open/etc/fstab, as shown in the last line add, where/dev/volgroup00/lvdata specifies the partition to mount Lv,/root/test specify the directory to mount (mount point), ext3 partition file system format, Other uses default can be

Expanding the current partition

First, create a new partition:

Fdisk/dev/hda

N

L #选择逻辑分区, if not, first create an extended partition and then add the logical partition (hard disk: up to four partitions p-p-p-p or P-P-P-E)

6 #分区号 (starting from 5),/dev/hda6

T 8e #分区类型8e表示LVM分区

W #写入分区表

Partprobe #重读分区表

Mkfs–t Ext3/dev/hda6 #格式化

Partx/dev/hda #查看当前硬盘的分区表及使用情况

Second, the creation of PV, expansion vg,lv

Pvcreate/dev/hda6

Vgdisplay #查看当前已经存在的VG信息, taking the existence of vg:volgroup00 as an example

Vgextend Volgroup00/dev/hda6 #扩展VolGroup00

Lvdisplay #查看已经存在的LV信息, taking the existence of LV:LOGVOL01 as an example

Lvextend–l 1g/dev/volgroup00/logvol01 #扩展LV

Resize2fs/dev/volgroup00/logvol01 #执行该重设大小, valid for LogVol01 currently in use

Df–h #查看挂载情况, has been enlarged

Linux LVM HDD Management and LVM expansion-Reprint

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.