Management practices for detailed configuration of logical volume LVM in Linux

Source: Internet
Author: User
Before configuring logical volume management and configuration, we think about a problem. we all know that Linux is a multi-user mode. when our preliminary plan causes insufficient hard disk space, in general, we add a new hard disk, partition and format the disk, copy the data of the disk that is not properly planned, and then re-mount the disk to take effect. If we

Logical Volume management and configuration

Before configuration, we want to have a problem. we all know that Linux is a multi-user mode. when our preliminary plan causes insufficient hard disk space, in general, we add a new hard disk, partition and format the disk, copy the data of the disk that is not properly planned, and then re-mount the disk to take effect. If we do this many times, it will be especially troublesome for our system administrators. In this case, LVM was born.

What is LVM?

LVM Chinese translation logical volume management. The biggest advantage of LVM is that it can integrate multiple hard disks to make multiple hard disks look like an independent hard disk (VG ), then we can split this independent hard disk (VG) into a small block and a small block (LV) so that when we add or delete a hard disk, data integrity will not be affected.

LVM workflow:

First, we need to prepare physical media. at the bottom layer, we can use hard disks and RAID. then we are converting these hard disks into LVM solid reels (PVS ), then we format the PV and adjust its ID. The lvm id is "8e ". You can use "t" to view the fdisk. After PV is created, create VG. a simple understanding of VG is to combine multiple PVS. LVM uses a 4 mb pe block. LVM's LV can contain up to 64435 blocks. we need to remember that the PE block is the smallest storage block of LVM. After we create PV as the VG group, how can we use it?

We need to cut the VG group into a small part. can we specify the LV size as needed? Certainly not. we can use PE to specify the size, so the LV size is related to PE.

Two working mechanisms of LVM:

Linear mode:

The linear mode is working like this. if our VG has two disks A and B, disk B will be used only when disk A is used up, the linear type means that one disk is used when another disk is used up. By default, LVM adopts the linear read mode.

Staggered mode:

The staggered mode is easy to understand. one data is divided into two parts, one is written to disk A and one is written to disk B. This feature is fast, but there is no security, and A disk is broken, the other disk cannot work normally. Generally, LVM does not use many of these modes. RAID is recommended for this feature.

I. actual LVM operation process;

1. First, we add a new disk/dev/sdb, and then create four 1 GB disks with the ID 8e,

2. the disk meets our PV requirements. First, we use pvscan to check whether the system has an LVM disk. We use pvcreate to create a disk. Pvdisplay is the status of the PV, and pvremove is the property of the pv removal. Specific configuration;

3. after PV is configured, create VG. vgcreate is mainly used to create VG commands. Vgscan is used to check whether a VG exists on the system. Vgdisplay displays the status of the VG on the system. vgextend increases the PV in the VG, vgreduce removes the PV from the VG, vgchange sets whether the VG is activated, and vgremove deletes a VG. The commands used in the figure are described in detail and the specific operation configuration is as follows:

4. we have created four PVS, and once three PVS are made into VG, another one is not made into VG. next we will add the command used, vgextend.

5. create PV and VG to create LV.

Lvcreate: Create an LV partition,LvsCan view the LV and lvdisplay on the system: view the LV status. lvextend increases the LV capacity, and lvreduce reduces the LV capacity. lvremove deletes a lv. Lvrsize: adjust the LV capacity.

6. after creating the LV, we certainly cannot use the LV file system. how can we use it? First, format the LV and mount it on the mount to see if it is complete ,:

7. then the entire LVM logic is configured. let's test how to add a hard disk. First, add a hard disk/dev/sdb10 to the ID8e format, first, create a PV and then create a VG ,:

8. as shown in the figure, we can see the remaining 290 MB. then we can add 290M directly.

9. the capacity of the hard disk we added,

10. extend the lv capacity to the file system ,.

11. check the current PV and unmount the hard disk.

12. then we will first set the LV capacity. here we will remove the hard disk capacity of/dev/sdb6. The calculation is very simple, and we can do this by 992*4. Note that the decimal point cannot appear. The files in use cannot be removed online. After Umount, we can perform an online check "e2fsck ";

13. we are then using resize2fs to load it into the lv. Then we can view the Mount details.

14. then we will reduce the LV capacity.-62 here refers to the PE block of PV (which can be viewed through pvdisplay), and then specify the path of our vg and lv. There will be a warning here, we can press Y. Then we can check lvdisplay. The LV size is the size we just set,

15. Step 1: move the data above/dev/sdb6 to/dev/sdb10. Step 2: Remove/dev/sdb6 from the VG group. Step 3: remove/dev/sdb6 from the pv Group.

16. check whether the test is removed. The result is as follows:

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.