Linux LVM hard disk management and LVM resizing

Source: Internet
Author: User
Document directory
  • Resize current Partition

LVM disk management

1. LVM introduction... 1

Ii. Basic Terms of LVM... 2

3. Install LVM... 3

4. create and manage LVM... 4

2. Create PV .. 6

3. Create VG... 7

4. Create LV .. 9

5. lv formatting and mounting... 10

I. Introduction to LVM

LVM is short for logical volume manager (logical volume management), which is implemented by Heinz mauelshagen on the Linux 2.4 kernel. LVM logically sets partitions of one or more hard disks, which is equivalent to a large hard disk. When the hard disk space is insufficient, LVM can continue to add partitions of other hard disks, this allows you to dynamically manage disk space, which is more flexible than common disk partitions.

Compared with traditional disks and partitions, LVM provides a higher level of disk storage for computers. It allows the system administrator to allocate storage space for applications and users more conveniently. Storage volumes under LVM management can be changed and removed as needed (File System Tools may need to be upgraded ). LVM also allows you to manage storage volumes by user group, allowing administrators to use more intuitive names (such as "sales" and "development ') replace the physical disk name (such as 'sda 'and 'sdb') to identify the storage volume.

LVM model:

A large space can be formed by four disk partitions, and then some logical partitions are divided in these spaces. When the space of a logical partition is insufficient, you can divide the remaining space into partitions that are insufficient for use.

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:

The physical media 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: 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: An LVM volume group is similar to a physical hard disk in a non-LVM system. It 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.

Logical volume: 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 (physical extent): Each physical volume is divided into basic units called PE (physical extents). 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 (logical extent): Logical volumes are also divided into the addressable basic units called Le (logical extents. In the same volume group, the Le size and PE are the same and one-to-one correspondence.

In simple terms:

PV: A physical disk partition.

VG: physical disk partition in LVM, that is, PV, must be added to VG. You can think of VG as a warehouse or several large hard disks.

LV: the logical partition divided from VG.

See the following figure for the Relationship Among PV, VG, and LV:

3. Install LVM
First, determine whether the LVM tool is installed in the system:
[Root @ www root] # rpm-Qa | grep LVM
Lvm-1.0.3-4
If the command result is similar to the preceding example, the LVM management tool is installed. If the command is not output, the LVM management tool is not installed, you need to download or install the lvm rpm toolkit from the network.

Iv. create and manage LVM

To create an LVM system, follow these steps:
1. Create a partition

Use a partitioning tool (such as fdisk) to create LVM partitions. The method is the same as that for creating other general partitions. The difference is that the LVM partition type is 8e. As shown in the following column chart:

View the disk partition table

Use fdisk to create a partition and enter the partition management path based on the absolute path of the device file (/dev/hda ).

Make sure to specify the format of the partition 8EThis is LVMPartition format

2. Create a PV

3. Create VG

After creating a VG, you can divide a LV from the VG.

4. Create an LV

A partition named lvdata with a capacity of MB is created, where-L: Specifies the LV size-N: Specifies the LV name. Vo1group00: Indicates dividing LV from this VG;

5. lv formatting and mounting

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

Mount the formatted LV partition to the specified directory to store data like a normal directory.

After mounting, you can see the capacity of this LV.

If you want to start LV at system startup, it is best to write lvdata into the fstable file, as shown below:

Use the vim editor to open/etc/fstab and add it in the last line, as shown in./dev/volgroup00/lvdata specifies the partition LV to be mounted, /root/test specifies the directory (mount point) to be mounted, ext3 partition File System Format, others use the default

 

Resize current Partition

1. Create a New partition:

Fdisk/dev/hda

N

L # select logical partition, if not, first create an extended partition and then add a logical partition (Hard Disk: up to four partition P-P-P-P or P-P-P-E)

6 # Partition Number (starting from 5),/dev/hda6

T 8e # partition type 8e indicates LVM Partition

W # Write to partition table

Partprobe # reread a partition table

Mkfs-T ext3/dev/hda6 # format

Partx/dev/hda # view the partition table and usage of the current Hard Disk

Ii. Create PV, resize VG, and LV

Pvcreate/dev/hda6

Vgdisplay # view the existing VG information. Take the VG: volgroup00 as an example.

Vgextend volgroup00/dev/hda6 # extended volgroup00

Lvdisplay # view the existing LV information. The following uses the LV: logvol01 as an example.

Lvextend-L 1g/dev/volgroup00/logvol01 # extended LV

Resize2fs/dev/volgroup00/logvol01 # execute this Reset size, which is effective for the currently used logvol01

DF-h # Check the mounting status and resize it

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.