How to learn Linux in depth? Teach you LVM Logical Volume Manager

Source: Internet
Author: User

LVM Logical Volume Manager can be said to be one of the key knowledge of Linux operation and maintenance work, let Xxxlinux engineer training organization teacher to take you to learn it!

The following is a look at the LVM side of the noun (all initials, easy to remember)

PV (physical Volume) Physical volume

is essentially a hard disk, but if you want to use LVM to manage the disk, you need to set it to PV

VG (Volume Group) volume group

Has multiple PV components, which is a capacity pool for LVM partitioning capacity

LV (Logical Volume) Logical Volume

From VG, is a partition provided by the logical Volume Manager

PE (physical Extend) physical expansion

Composed of VG to small units, LVM to small units, the default size 4m,pe must be an integer, if insufficient, the system directly discard

1. Create a physical volume

Pvcreate Disk/partition path

Eg:pvcreate/dev/sdb1

2. Create a volume group

vgvreate [-S size] VG name PV Path (-s refers to the size of the PE, default is 4M, not specified is the default)

Eg:vgcreate-s 8M VG1/DEV/SDB1

3. Creating a Logical Volume

Lvcreate-l PE number-n LV name VG name

-L This LV size (l and-l usage is not the same, see clearly)

Eg:lvcreate-l 100-n Lv1 VG1

This makes the LV 1 of our LVM logical volume a success!

If you want to use it, then make a file system (format), Mount

Some of the commands for LVM viewing:

Pvdisplay PVs

Vgdisplay VGS

Lvdisplay LVS

We mentioned above that the advantage of using LVM is that we can dynamically manage our disks or partitions!

Let's look at the specific use:

One, the increase and decrease of VG

The increase and decrease of physical volumes is actually the process of adding or removing PV to physical volumes.

1. Increase of physical volume

Vgextend Volume Group name PV path

Eg:vgextend VG1/DEV/SDB2

2. Reduction of physical volume

(1), PV not used

Vgreduce Volume Group name PV path

Eg:vgreduce VG1/DEV/SDB1

(2), PV is in use (There are LV)

First Umount LV Path (unload logical volume)

Remove a PV in the specified volume group, vgreduce the volume group name PV path

Remove PV, pvmove PV path

Ii. the increase and decrease of LV

The increase and decrease of the logical volume is actually the increase and decrease of the number of PE in the logical volume

1, the increase of the logical volume

Allow mounts to grow, and the increase in LV does not destroy data

First step: Increase the LV

lvextend-l [+] number of LV paths

-l [+] Size

Step two: Increase the file system

Ext Series File System tuning command: path to RESIZE2FS LV

XFS Series File System tuning command: path to XFS_GROWFS LV

2, the reduction of the logical volume (LVM side of the LV reduction, for the file system can only be ext format)

Do not allow the decrease in mount, does not support the reduction of XFS file system, minus hours theoretically will not destroy the data

First step: Uninstall LV

Umount LV Path or mount point path

Step Two: File system check

E2fsck-f LV Path

Step three: Reduce the file system

RESIZE2FS LV Path size

Eg:resize2fs/dev/vg1/lv1 100M

Fourth step: Decrease LV

lvreduce-l [-] Number of LV paths

-l [-] size

Eg:lvreduce-l 100M/DEV/VG1/LV1

Fifth step: Re-mount

Mount or Vim/etc/fstab permanent mount

* Command lvresize can be used for both increment and decrement, using the same method as Lvextend and Lvreduce

? iii. deletion of logical volumes

1. Delete the LV

Lvremove LV Path

2. Delete VG

Vgremove VG Name

3. Remove PV

Pvremove PV Path

How to learn Linux in depth? Teach you LVM Logical Volume Manager

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.