LVM logical volume management + vdo virtual data optimizer

The establishment of lvm

Establish an experimental environment and monitor with monitoring commands

mkdir /weixindata
watch -n 1 "df -h /weixindata;echo ===;pvs;echo =====;vgs;echo ===;lvs"
fdisk /dev/sdb Divide 3 primary partitions, and 2, 3 partition label is written as 8e (sticker lvm label) wq exit save
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

pvcreate /dev/sdb2
pvcreate /dev/sdb3 Create physical partition

vgcreate westos_vg0 /dev/sdb3 Pour orange juice into a large container

lvcreate -L 200M -n westos_
lv0 westos_vg0
mkfs.xfs /dev/westos_vg0/westos_lv0

mount /dev/westos_vg0/westos_lv0 /weixindata/ format the separated lvm logical volume to mount
Insert picture description here

Stretch a logical volume lvm

lvextend -L 500M /dev/westos_vg0/westos_lv0 stretch the size of lvm

xfs_growfs /weixindata/ The size of the synchronized file system
Insert picture description here

When the divided primary partition /dev/vdb1 is not enough (I want to stretch the lvm to 2500M), first divide a primary partition out of /dev/vdb2, and then stretch

pvcreate /dev/sdb2

vgextend westos_vg0 /dev/sdb2

lvextend -L 2500M /dev/westos_vg0/westos_lv0

xfs_growfs /weixindata/
Insert picture description here

Stretch and shrink the devices of the ext4 file system

1. Stretch

umount /weixindata

mkfs.ext4 /dev/westos_vg0/westos_lv0 format the device as ext4 file system
Insert picture description here

mount /dev/westos_vg0/westos_lv0 /weixindata/ mount

lvextend -L 2800M /dev/westos_vg0/westos_lv0 stretch

resize2fs /dev/westos_vg0/westos_lv0 stretch the file system
Insert picture description here

2. Reduce

umount /weixindata

e2fsck -f /dev/westos_vg0/westos_lv0 Scan the contents of this device, otherwise direct reduction will cause damage
Insert picture description here

resize2fs /dev/westos_vg0/westos_lv0 1500M Reduce file system

lvreduce -L 1500M /dev/westos_vg0/westos_lv0 Reduce the lvm device
Insert picture description here

mount /dev/westos_vg0/westos_lv0 /weixindata/

pvmove /dev/sdb3 /dev/sdb2 Move the things under /dev/vdb3 to /dev/vdb2, and then free /dev/vdb3

vgreduce westos_vg0 /dev/sdb3

pvremove /dev/sdb3
Insert picture description here

Create a snapshot of lvm

mount /dev/westos_vg0/westos_lv0 /weixindata/

touch /weixindata/file{1…10}

ls /weixindata/

umount /weixindata Unmount first and then take snapshot

ls /weixindata/
Insert picture description here

lvcreate -L 50M -n westos_lv0.bak -s /dev/westos_vg0/westos_lv0 take a snapshot

mount /dev/westos_vg0/westos_lv0.bak /weixindata/ mount snapshot

cd /weixindata/

ls

rm -fr *
Insert picture description here

umount /weixindata

lvremove /dev/westos_vg0/westos_lv0.bak

lvcreate -L 50M -n westos_lv0.bak -s /dev/westos_vg0/westos_lv0 Then take the photo again, remount the file to restore

mount /dev/westos_vg0/westos_lv0.bak /weixindata/

ls /weixindata/
Insert picture description here

How to delete lvm device failure

pvcreate /dev/sdb3

vgextend westos_vg0 /dev/sdb3
Insert picture description here

fdisk /dev/sdb
Insert picture description here
Insert picture description here

vgdisplay ​​​​​​
Insert picture description here

pvs

vgreduce --removemissing westos_vg0

vgs

pvs
Insert picture description here

Deletion of LVM

umount /weixindata

lvremove /dev/westos_vg0/westos_lv0

vgremove westos_vg0

pvremove /dev/sdb2
Insert picture description here

fdisk /dev/sdb
Insert picture description here

partprobe
Insert picture description here

vdo virtual data optimizer

vdo build

vdo create --name=westos_vdo1 --device=/dev/sdb

vdo status --name=westos_vdo1 | less
Insert picture description here

Deduplication: enabled vdo to detect and delete duplicate data is enabled
Insert picture description here

Compression: enabled vdo data compression function is enabled
Insert picture description here

Use vdo device

mkfs.xfs -K /dev/mapper/westos_vdo1

mkdir /westos_vdo

mount /dev/mapper/westos_vdo1 /westos_vdo/
Insert picture description here

Test vdo performance

cp /westos/images/install.img / westos_vdo /

vdostats --human-readable

cp /westos/images/install.img /westos_vdo/install.img.1

vdostats --human-readable
Insert picture description here

Delete vdo

vdo remove --name=westos_vdo1

Insert picture description here

Guess you like

Origin blog.csdn.net/qq_42958401/article/details/107945262