1,建立邏輯卷vim
查看物理磁盤: [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 擴容bash
[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, 刪除邏輯卷app
[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