RedHatLinux dynamically extends system partitions through LVM

Source: Internet
Author: User
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 ),

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. The LVM system administrator can easily manage disk partitions. For example, you can connect several disk partitions to an entire volume group to form a storage pool. The administrator can create a logical volume group (logical volumes) 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.

Why use LVM

How to accurately assess and allocate the capacity of each hard disk partition when partitioning the system, because the system administrator should not only consider the capacity required by a certain partition, we also need to anticipate the maximum capacity that may be required after the partition. If the estimation is inaccurate, the Administrator may even need to back up the entire system, clear the hard disk, re-partition the hard disk, and restore the data to the new partition when a partition is insufficient.

Although there are many tools available for Dynamic Disk adjustment, such as Partation Magic, it cannot completely solve the problem because a partition may be exhausted again; in addition, this requires a reboot of the system. For many critical servers, shutdown is unacceptable and new hard disks are added, if you want a file system that can span multiple hard drives, the partition adjustment program cannot solve the problem.

Therefore, the perfect solution should be to adjust the file system size without downtime, so that the file system can easily span across different disks and partitions. Fortunately, the Logical disk Volume Management (LVM, Logical Volume Manager) mechanism provided by Linux is a perfect solution.

To put it simply, LVM can dynamically adjust the size of each partition without stopping services and keep the original file system unchanged.

Basic concepts 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: The storage device of The system: hard disk, such as/dev/hda and/dev/sda, 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.

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. The 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.

Install LVM

By default, the RedHat Linux system uses [root @ a ~] With the lvm tool installed by default. # Rpm-qa | grep lvm

Lvm2-2.02.56-8.el5

System-config-lvm-1.1.5-4.el5

[Root @ a ~] # Through the query can know that LVM needs lvm2-2.02.56-8.el5 and system-config-lvm-1.1.5-4.el5 two installation package support, if not installed on it.

LVM experiment: dynamically expanding system partitions

Add a new hard disk and allocate 1 GB space to the system LogVol00 without stopping the system. resize the system partition and ensure that the original files are not lost.

This requirement cannot be implemented in the windows system, but it can be easily implemented through Linux LVM.

First look at the original system partition [root @ a ~] # Df

File System 1 K-block used available % mount point

/Dev/mapper/VolGroup00-LogVol00

6983168 2909812 3712908 44%/the vg of the system partition is VolGroup00, And the VL is LogVol00

Here we add a hard disk/dev/sdb

Create/dev/sdb as pv [root @ a ~] # Pvcreate/dev/sdb

Physical volume "/dev/sdb" successfully created because the system already has VG: VolGroup00, add the new pv to the system VG: VolGroup00 [root @ a ~]. # Vgextend VolGroup00/dev/sdb

Volume group "VolGroup00" successfully extended added 1 GB space for the LogVol00 system LV [root @ a ~] # Lvextend-L + 1G/dev/VolGroup00/LogVol00

Extending logical volume LogVol00 to 7.88 GB

After resizing Logical volume LogVol00 successfully resized LV, You need to activate the modified configuration [root @ a ~] # Resize2fs/dev/VolGroup00/LogVol00

Resize2fs 1.39 (29-May-2006)

Filesystem at/dev/VolGroup00/LogVol00 is mounted TYPE = "audio/mpeg">

Related Article

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.