The step of online expansion of LVM in Linux

Source: Internet
Author: User

Ext.: https://jingyan.baidu.com/article/25648fc18f22b29191fd0011.html

You can see the original picture without seeing it clearly

LVM is the short name of the Logical Disk volume management (Logical Volume Manager), which is a mechanism for managing disk partitions in a Linux environment, and LVM is a logical layer on top of hard disks and partitions to improve the flexibility of disk partition management. 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. Physical volume (physical volume) physical volume refers to a hard disk partition or a device that logically shares the same functionality as a disk partition (such as RAID), which is the basic storage logic block of LVM, but is compared to the basic physical storage media (such as partitions, disks, etc.) and contains management parameters related to LVM.

Advantage:

Ability to expand the current partition capacity online.

One of the most common and difficult questions that Linux users encounter when installing Linux operating systems is how to properly evaluate the size of each partition to allocate the appropriate hard disk space. When a partition is exhausted, the solution is usually to use symbolic links, or to use tools that resize the partition (such as patitionmagic, etc.), but this is only a temporary workaround and does not solve the problem at all. With the advent of Linux's logical volume management capabilities, these problems are solved, allowing users to easily adjust the size of each partition without the need for downtime.

Structure:

In the whole LVM structure is divided into: "Physical volume, physical volume partition, volume group, logical volume", I explained in detail the following four kinds of structure:

1: Physical Volume: Physical Volume, abbreviated as PV, a physical volume is simply a physical storage medium with LVM management data added to it. To use an LVM system, first initialize the disk to be used for LVM and initialize it to identify the disk or partition as a physical volume of LVM. Use the Pvcreate command to mark a disk as an LVM physical volume.

2: Physical partition: Physical extents, abbreviated PE,LVM each physical volume is referred to as the addressable storage unit of the physical partition, and the size of the storage unit is typically a few megabytes. The first part of the disk is LVM metadata, and then the index is zero, and each physical partition is incremented by one, sequentially.

3: Volume Group: Volume Group, referred to as VG, physical volumes can be organized into volume groups. A volume group can consist of one or more physical volumes, and there can be multiple volume groups in the system. After a volume group is created, the volume group (not the disk) is the entity that represents the data store. Therefore, even though the disk was previously moved from one system to another, using LVM, the volume group was moved from one system to another. For this reason, it is often convenient to create multiple volume groups on one system.

4: Logical partition: Logical extents, or LE, the basic allocation unit of a logical volume is called a logical partition. Logical partitions are mapped to physical partitions, so if the size of the physical partition is 4MB, the logical partition size will also be 4MB. The size of the logical volume depends on the number of logical partitions allocated.

Tools/Materials
    • A server or notebook with a Linux operating system installed
    • The virtual machine environment can also

Method/Step
  1. To build LVM, you first need to prepare the disk or partition for LVM. If you use a disk partition as a physical volume, you need to identify the partition as "Linux LVM" with the partition ID "0x8e", and then I'll show you the configuration process and the online expansion of the partition.

    Objective of this experiment: to expand the online Linux system root partition

    Here's an explanation:

    When I install the system is the default partition, when the system default allocation of 2 zones, boot and root, and the root partition for the LVM system, in order to facilitate future online expansion, now I want to do is to expand the root partition 5G, currently 17G, expand 5G after the size of 22G, Expansion mode for online expansion, business is not interrupted, the machine does not need to shut down, the expansion target is the root partition.

  2. Expansion Order:

    Create a new PV---Add the new PV to the current VG---Expand the existing LV----expansion file system

    Divide a partition, size 5G, partition ID: 83, I need to modify to 8E, continue the following configuration, if you want to know what the partition identification number, you can view the help.

  3. Create a new PV and add the new PV to the existing VG:

    Command: Pvcreate (Create PV, if it is to create a VG before modifying to VG can, just slightly different syntax)

    Command: Vgextend (for VG expansion)

    Syntax: Vgextend existing VG + PV absolute path

    Syntax: Pvcreate partition 1 + partition 2 + partition 3 + ...

    Syntax: Vgcreate–s PE vgname PV + + + (the parameter-s here indicates the size of the PE block is modified when the VG is created)

    Note: The size of the PE block can only be a multiple of 2, the lowest starting from 4, and so on 8, 16, 32 ... The biggest should be 64M.

    is the original VG, the size of 17G, where the new VG has not been added, the new VG added to the view after the results, you can see the size of the 22G, can be allocated PE has 159.

  4. For the expansion of LV and file system expansion:

    Command: Lvresize or Lvextend

    Syntax: Lvresize-l size required to expand the LV absolute path

    The display has now been expanded successfully, the current capacity has reached 21G, capacity before the expansion of 16G, the following use the command to see the current LV status.

  5. The LV capacity has been successfully expanded to 21G, compared with the previous increase of 5G, but the current file system has not been enlarged, so the size of the root partition is still unchanged, or 17G, as follows

    The entire root directory has been successfully expanded to 22G, compared to the previous 17G, increased 5G capacity, the entire operation process is completed online, the business is not interrupted, the system does not need to restart.

Precautions
    • If the root partition is scaled down, it cannot be done online, and the risk of reduction is often greater than the risk of expansion, such as failure to reduce it will result in the entire file system being destroyed.

The step of online expansion of LVM in Linux

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.