Daily use commands and management of PV /VG/LV under linux

Basic theoretical knowledge of LVM

LVM daily use management commands

Experimental environment: local computer, virtual machine, linux, xshell to build a local experimental environment

Preparation before creation:

First add two hard disks respectively sdb and sdc

Log in to the linux system to check whether the hard disk is created successfully (the following picture shows the creation successfully)

Create pv

Create a vg and name the VG storage

Display the detailed configuration information of the created vg

Create lv and name it V0/V1

(Lvcreate /create-  n lvname /create lv name-  l size/ capacity storage /which volume group takes the capacity )

lvcreate -n v1 -l 38 storage ------------------152/4m=38 minimum PE = 4m must be an integer multiple

lvcreate -n v0 -L 152M storage--------------Uppercase L to create and directly enter the capacity

Check if the creation is successful

If the creation is successful, the following figure will be displayed (use ll to view)

(A directory storage with the same name as the volume group is automatically created under /dev)

Format the created lv

Create the mount directory lvm and mount it

Check if the file system is operating normally

-----dd if=/dev/zero of=/app/lv1/testfile bs=10 count=10

 

Expand LV capacity lvextend 

-------The calculation of expansion capacity must be an integral multiple of the minimum unit PE capacity

-------First increase the capacity of an integer multiple of 4M, and then check whether the expansion is successful

-------Expand lv first

-------Expand the file system again

Check whether the expansion is successful

------e2fsck -f expanded lv path

-------Reset capacity

------Check the capacity after expansion

Reduce LV capacity lvreduce

------Check the file system first

------Reduce lv again

------Shrink the file system first

------Reduce lv again

Delete lv and then delete vg 

------lvremove delete lv path name

----- vgremove delete vg path name

The use of LVM snap

------The snapshot volume capacity must be equal to the lvm capacity

------The snapshot is one-time, and it will be deleted after restoration

------lvcreate -s -n snap -L 45M /dev/storage/v0

-s stands for creating a snapshot

-n represents the snapshot name is snap

-L is the size of the capacity used to create the snapshot

path path is specified to the snapshot lvm

 

Guess you like

Origin blog.csdn.net/weixin_45448980/article/details/114261870