一、扩容ext4文件
[root@centos8 ~]#vgdisplay 查看逻辑卷空间 [root@centos8 ~]#lvextend -l +50%free /dev/vg0/mysql 增加%50 [root@centos8 ~]#lvdisplay 查看是否增加了内存 [root@centos8 ~]#vim /etc/fstab 挂在配置文件路径 12 UUID=43f3ebf4-9fa1-42a4-9cb7-5127fc402eca / xfs defaults 0 0 13 UUID=911c0027-8903-4bdc-845d-1832ffc615e0 /boot ext4 defaults 1 2 14 UUID=e5239639-5c68-43eb-880c-636f74e42a38 /date xfs defaults 0 0 15 #UUID=5e79c323-2d71-47cf-a280-bda970e9a21c none swap defaults 0 0 16 #UUID=e9e3f824-5f2d-4aed-8335-e14f8c6d5d2f /date/mysql ext4 defaults 0 0 17 /dev/vg0/mysql /mnt/mysql ext4 defaults 0 0 18 #UUID=dfde1769-0d1a-424b-a229-e499b8588a3a none swap defaults 0 0 19 /date/swapfile none swap defaults 0 0 20 /dev/vg0/log /mnt/log xfs defaults 0 0 [root@centos8 ~]#mkdir /mnt/log 创建挂载文件目录 [root@centos8 ~]#mount -a 挂载文件 [root@centos8 ~]#resize2fs /dev/vg0/mysql 扩容完需要同步一下
二、扩容xfs文件类型
[root@centos8 ~]#lvextend -L +1G /dev/vg0/log xfs_growfs /mnt/log/
三、通用命令
[root@centos8 ~]#vextend -r -l +1G /dev/vg0/mysql
四、查看逻辑卷:lvs 物理卷:pvs
五、物理卷扩展
[root@centos8 ~]#fdisk /dev/sdb 剩余空间 [root@centos8 ~]#pvcreate /dev/sdb2 新建sdb2物理卷 [root@centos8 ~]#vgextend vg0 /dev/sdb2 增加新的物理卷扩容
六、缩容
注意:有风险,先备份,xfs文件系统不支持缩减
[root@centos8 ~]#umount /mnt/mysql 取消挂载 [root@centos8 ~]#e2fsck -f /dev/vg0/mysql 检查文件完整性 [root@centos8 ~]#resize2fs /dev/vg0/mysql 2G 缩减大小 [root@centos8 ~]#lvreduce -L 2G /dev/vg0/mysql 对文件进行缩减 [root@centos8 ~]#mount /dev/vg0/mysql 挂载
七、某一个硬盘需要更换逻辑卷中数据首先移动到别的逻辑卷中
[root@centos8 ~]#pvmove /dev/sdc 移动到别的逻辑卷中 [root@centos8 ~]#vgreduce vg0 /dev/sdc 删除所属vg0逻辑卷 [root@centos8 ~]#pvremove /dev/sdc 删除逻辑卷
八、快照
创建快照:ext4 [root@centos8 ~]#lvcreate -s -n mysql-snapshot -L 100M /dev/vg0/mysql 创建快照mysql的 [root@centos8 ~]#mkdir /mnt/snap 创建快照文件存放 [root@centos8 ~]#mount /dev/vg0/mysql-snapshot /mnt/snap/ 挂载 还原:ext4 取消挂载 [root@centos8 ~]#umount /mnt/snap [root@centos8 ~]#umount /mnt/mysql [root@centos8 ~]#lvconvert --merge /dev/vg0/mysql-snapshot 创建快照:xfs [root@centos8 ~]#cp /etc/fstab /mnt/log/a.txt [root@centos8 ~]#cp /etc/fstab /mnt/log/b.txt [root@centos8 ~]#cp /etc/fstab /mnt/log/c.txt [root@centos8 ~]#ls /mnt/log/ a.txt b.txt c.txt [root@centos8 ~]#lvcreate -s -n log-snapshot -L 100M /dev/vg0/log Logical volume "log-snapshot" created. [root@centos8 ~]#mount -o ro,nouuid /dev/vg0/log-snapshot /mnt/log/ [root@centos8 ~]#ls /mnt/log a.txt b.txt c.txt [root@centos8 ~]#ls /mnt/snap/ 还原:ext4 取消挂载 [root@centos8 ~]#umount /mnt/snap [root@centos8 ~]#umount /mnt/log [root@centos8 ~]#lvconvert --merge /dev/vg0/log-snapshot
删除逻辑卷和物理卷
[root@centos8 ~]#umount /mnt/mysql [root@centos8 ~]#umount /mnt/log [root@centos8 ~]#lvremove /dev/vg0/mysql [root@centos8 ~]#lvremove /dev/vg0/log [root@centos8 ~]#lvs [root@centos8 ~]#lvremove /dev/vg0/log [root@centos8 ~]#lvremove /dev/vg0/log-snapshot [root@centos8 ~]#lvs [root@centos8 ~]#lvremove /dev/vg0/log [root@centos8 ~]#lvs [root@centos8 ~]#lvremove /dev/vg0/log [root@centos8 ~]#umount /mnt/log [root@centos8 ~]#lvremove /dev/vg0/log [root@centos8 ~]#lvs [root@centos8 ~]#vgdisplay [root@centos8 ~]#vgremove vg0 [root@centos8 ~]#pvs [root@centos8 ~]#pvremove /dev/sd{c,b1,b2} [root@centos8 ~]#pvs
标签:逻辑,12,快照,log,vg0,mnt,dev,root,centos8 From: https://www.cnblogs.com/liujinxi/p/17399836.html