1,创建逻辑卷
查看物理磁盘: [root@localhost ~]# parted -l | grep 'Disk /dev/s' #如果分区表是GPT [root@localhost ~]# fdisk -l | grep 'Disk /dev/s' #如果分区表是MBR Disk /dev/sda: 214.7 GB, 214748364800 bytes, 419430400 sectors Disk /dev/sdc: 21.5 GB, 21474836480 bytes, 41943040 sectors Disk /dev/sdd: 21.5 GB, 21474836480 bytes, 41943040 sectors Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors [root@localhost ~]# 如果分区小于2T,建议转换为MBR分区表 [root@localhost ~]# parted -s /dev/sdb mklabel msdos [root@localhost ~]# parted -s /dev/sdc mklabel msdos [root@localhost ~]# parted -s /dev/sdd mklabel msdos [root@localhost ~]# dd if=/dev/zero of=/dev/sdb bs=512K count=1 [root@localhost ~]# dd if=/dev/zero of=/dev/sdc bs=512K count=1 [root@localhost ~]# dd if=/dev/zero of=/dev/sdd bs=512K count=1 在空闲磁盘上创建PV [root@localhost ~]# pvcreate /dev/sdb [root@localhost ~]# pvcreate /dev/sdc [root@localhost ~]# pvcreate /dev/sdd [root@localhost ~]# pvdisplay #验证上述结果 基于PV上创建VG [root@localhost ~]# vgcreate VG_chunli /dev/sdb /dev/sdc /dev/sdd #创建名为'VG_chunli'的卷组 [root@localhost ~]# vgdisplay #验证上述结果 [root@localhost ~]# vgs #验证上述结果 VG #PV #LV #SN Attr VSize VFree VG_chunli 3 0 0 wz--n- 59.99g 59.99g [root@localhost ~]# 基于VG创建逻辑卷: [root@localhost ~]# lvcreate --name Logic_chunli --size 59G VG_chunli [root@localhost ~]# lvdisplay 开机自动挂载: [root@localhost ~]# mkfs.ext4 /dev/VG_chunli/Logic_chunli [root@localhost ~]# mkdir /mnt/mount [root@localhost ~]# blkid /dev/VG_chunli/Logic_chunli /dev/VG_chunli/Logic_chunli: UUID="739588df-466a-41c2-a703-8860fe849134" TYPE="ext4" [root@localhost ~]# vim /etc/fstab #在尾行追加 UUID="739588df-466a-41c2-a703-8860fe849134" /mnt/mount ext4 defaults 1 2 [root@localhost ~]# mount -a [root@localhost ~]# df -hT #查看挂载信息 Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/VG_chunli-Logic_chunli ext4 58G 53M 55G 1% /mnt/mount [root@localhost ~]# [root@localhost ~]# vgs #查看剩余的VG VG #PV #LV #SN Attr VSize VFree VG_chunli 3 1 0 wz--n- 59.99g 1012.00m [root@localhost ~]# [root@localhost ~]# pvs #查看剩余的PV PV VG Fmt Attr PSize PFree /dev/sdb VG_chunli lvm2 a-- 20.00g 0 /dev/sdc VG_chunli lvm2 a-- 20.00g 0 /dev/sdd VG_chunli lvm2 a-- 20.00g 1012.00m [root@localhost ~]#
2,LVM 扩容
[root@localhost ~]# fdisk -l | grep '/dev/s' Disk /dev/sdc: 21.5 GB, 21474836480 bytes, 41943040 sectors Disk /dev/sda: 214.7 GB, 214748364800 bytes, 419430400 sectors /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 419430399 208665600 8e Linux LVM Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors Disk /dev/sdd: 21.5 GB, 21474836480 bytes, 41943040 sectors Disk /dev/sde: 161.1 GB, 161061273600 bytes, 314572800 sectors [root@localhost ~]# pvcreate /dev/sde [root@localhost ~]# vgs #查看已经存在的VG VG #PV #LV #SN Attr VSize VFree VG_chunli 3 1 0 wz--n- 59.99g 1012.00m cl 1 3 0 wz--n- 199.00g 4.00m [root@localhost ~]# [root@localhost ~]# vgextend cl /dev/sde #扩展cl [root@localhost ~]# lvextend --size 200G /dev/cl/home [root@localhost ~]# df -hT /dev/mapper/cl-home xfs 150G 33M 150G 1% /home [root@localhost ~]# xfs_growfs /dev/cl/home [root@localhost ~]# df -hT /dev/mapper/cl-home xfs 200G 33M 200G 1% /home [root@localhost ~]#
3, 删除逻辑卷
[root@localhost ~]# umount /dev/VG_chunli/LV_chunli [root@localhost ~]# lvremove /dev/VG_chunli/LV_chunli [root@localhost ~]# vgremove VG_chunli [root@localhost ~]# pvremove /dev/sdb
转载于:https://blog.51cto.com/990487026/1974390