Linux under Disk Management mechanism--LVM

Source: Internet
Author: User

When we use the disk with the traditional partitioning method, when the partition size is not enough, it is usually only possible to add a larger disk and recreate the partition to expand the space. However, this can only be the original disk offline, replace the new disk, the original data is written in the actual production process is not allowed. In this case, you need to use logical volume LVM to manage this type of disk partition.

A logical volume is a re-"split" of hard disk space into a block of equal size (PE) into a container (VG), when you need to be able to remove such a block in the container at any time, to achieve the dynamic adjustment of disk space size. Of course, the newly added block will not change the original file system, and the original disk will not be offline.

The following describes the basic components of a logical volume and the relationships between the parts:

    • PE (physical Extend): physical extension

    • PV (physical volume): Physical volume

    • VG (Volume Group): Volume group

    • LV (logical volume): Logical Volume

Illustrates the relationship between Pe,pv,vg,lv. The basic unit of LVM is that the PE,PV is to format each disk (partition) into equal size PE,VG, the function of which is the full collection of PE by the PV format number, which is equivalent to a container. LV when needed, can at any time to the container (VG) central to take PE, to achieve dynamic expansion.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/3D/2E/wKioL1PD7MaDJ4dKAAEx2v2w1Dc674.jpg "title=" Lvm222.jpg "alt=" Wkiol1pd7madj4dkaaex2v2w1dc674.jpg "/>

First, the creation of LVM

From the previous knowledge we can get, create an LVM device, first need to create PV,VG, then can create LV.

Prerequisites:

Get ready to do the LVM disk, we are in the partition instead.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/3D/31/wKiom1PD8-eQ3mroAAHUUxPYA_s008.jpg "title=" Lvm-fdisk.jpg "alt=" Wkiom1pd8-eq3mroaahuuxpya_s008.jpg "/>

After this step, you can create the PV, using pvcreate device ... can be achieved. After you have created PV, you can use PVS or pvdisplay to view the created PV.


650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/3D/32/wKioL1PD9XHywVh6AAH3t29llnE686.jpg "title=" Pvcreat.jpg "alt=" Wkiol1pd9xhywvh6aah3t29llne686.jpg "/>

The next step is to create the VG, using the command vgcreate-s pe_size vg_name DEVICE .... After creating the VG, you can use VGS or vgdisplay to view the relevant information.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/3D/32/wKioL1PD98CSVRUHAAJKnEfCh98241.jpg "title=" Vgcreate.jpg "alt=" Wkiol1pd98csvruhaajknefch98241.jpg "/>

The final step is to create the LV, using the lvcreate [options] ... Vg_name to create, you can also use Lvs,lvdisplay to view relevant information.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/3D/34/wKiom1PD_fbgt7RYAAM7ZReAc2I642.jpg "title=" Lvcreate.jpg "alt=" Wkiom1pd_fbgt7ryaam7zreac2i642.jpg "/>

Once we have created a logical volume, we can format it and mount it. Formatting and mounting are no longer detailed here.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/3D/34/wKioL1PD_3rTa8V6AAFx6K1hoEc540.jpg "title=" Df-lvm.jpg "alt=" Wkiol1pd_3rta8v6aafx6k1hoec540.jpg "/>


So we can use the logical volume. Of course, this is no different from our normal disk partitioning. Then look at the following content.


Ii. online expansion of logical volumes

The extension can be executed online without the need to unload the logical volume, but there is enough space in the VG to be extended if not enough.

In the VG There is enough space:

When you extend the LV, you first extend the physical boundary, followed by the extended logical boundary (file system).

Extend the physical boundary and use the command lvextend [options] Lv_device.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/3D/36/wKiom1PEAwmgL1mhAAOVsAywbug708.jpg "title=" Lvextend.jpg "alt=" Wkiom1peawmgl1mhaaovsaywbug708.jpg "/>

Here is the extended logical boundary, using RESIZE2FS lv_device.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/3D/36/wKiom1PEA7PhyqpCAALBlnFEL8M023.jpg "title=" Resize3fs.jpg "alt=" Wkiom1pea7phyqpcaalblnfel8m023.jpg "/>

The online expansion has been completed, in the process of expansion has been online.

In the case of VG space is insufficient:

The first thing to do is to enlarge the VG before you can extend the LV. But to extend the LV, you first have to add the disk partition, as follows:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/3D/37/wKiom1PEBtbAkNeyAABjr5ZymHQ456.jpg "title=" Qqqqqqqqqqqq.jpg "alt=" Wkiom1pebtbakneyaabjr5zymhq456.jpg "/>

Then you can extend the VG. Using Vgextend vg_name DEVICE

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/3D/37/wKiom1PEBx6A-O1LAABqe3mR8zY513.jpg "title=" Aaaaaaa.jpg "alt=" Wkiom1pebx6a-o1laabqe3mr8zy513.jpg "/>

At this point, we can see that the VG extension is successful, so we can do the LV expansion.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/3D/37/wKiom1PEB0ig-cx7AACpujeBe2o439.jpg "title=" Ssssssssssssssss.jpg "alt=" Wkiom1peb0ig-cx7aacpujebe2o439.jpg "/>


Third, the reduction of the logical volume

This operation is a dangerous action and requires caution in operation. Once the data is lost, it cannot be returned.

LV reduction process: The logical partition is reduced first, and the physical partition is reduced.

Reduce the physical partition, at which point the disk is unloaded, and the reduced partition size is determined to avoid data loss.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/3D/38/wKioL1PECZrABFvOAALg_9D3y7I012.jpg "title=" LV reduced. jpg "alt=" wkiol1peczrabfvoaalg_9d3y7i012.jpg "/>

To reduce the physical partition, use Lvreduce-l SIZE lv_device

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/3D/38/wKioL1PECoqi1qJgAAEIOeu1srg666.jpg "title=" Lvreduce.jpg "alt=" Wkiol1pecoqi1qjgaaeioeu1srg666.jpg "/>

After that, the mount is ready to use.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/3D/38/wKioL1PECyLyz7xkAAF-YVT4sbY477.jpg "title=" 1111111111.jpg "alt=" Wkiol1pecylyz7xkaaf-yvt4sby477.jpg "/>

At this point, the reduction work is completed.


Iii. Snapshots of LVM (Snapshat)

The snapshot of LVM is a backup of the LV at a certain point in time. An LVM snapshot is a logical volume that temporarily retains the original data of the changed logical volume. Snapshots provide a static view of the original volume, enabling them to back up their data in a consistent state.

1. The snapshot volume size is only sufficient to store the data that was changed during its existence.

2. If the amount of data change is greater than the snapshot storage capacity, the snapshot will automatically become unavailable. (the original volume remains intact, and you still need to manually remove the mount from the volume group and delete the unavailable snapshot.) )

Creation and use of snapshots:

Once the snapshot is created, it can be used directly, and no formatting is required.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/3D/39/wKiom1PEDerxKXc3AAIWf_Vb9xg617.jpg "title=" Snapshot.jpg "alt=" Wkiom1pederxkxc3aaiwf_vb9xg617.jpg "/>


This article is from the "Upstream Cold" blog, please be sure to keep this source http://guoting.blog.51cto.com/8886857/1438184

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.