lvm基本操作
阿新 • • 發佈:2022-03-22
安裝
$ yum install -y lvm2
建立
建立pv並檢視
$ pvcreate /dev/sda3 Physical volume "/dev/sda3" successfully created. $ pvdisplay /dev/sda3 "/dev/sda3" is a new physical volume of "<206.38 GiB" --- NEW Physical volume --- PV Name /dev/sda3 VG Name PV Size <206.38 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID OKDd2t-4iMt-J2T3-hzN4-Z3YX-TXFJ-jMOMoh
提前建立好分割槽
建立vg並檢視
$ vgcreate vg01 /dev/sda3 Volume group "vg01" successfully created $ vgdisplay vg01 --- Volume group --- VG Name vg01 System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 1 VG Access read/write VG Status resizable MAX LV 0 Cur LV 0 Open LV 0 Max PV 0 Cur PV 1 Act PV 1 VG Size <206.38 GiB PE Size 4.00 MiB Total PE 52832 Alloc PE / Size 0 / 0 Free PE / Size 52832 / <206.38 GiB VG UUID zTQM1F-oEK0-NxbR-bNCP-je4K-cY2q-QsbnC1
建立lv並檢視
$ lvcreate -L +16G -n app vg01 Logical volume "app" created. $ lvdisplay /dev/vg01/app --- Logical volume --- LV Path /dev/vg01/app LV Name app VG Name vg01 LV UUID 5QKnpz-ozqJ-C51c-oB6A-jJ4O-oDeq-yyAQTW LV Write Access read/write LV Creation host, time kvm.ecloud.com, 2022-03-21 16:57:46 +0800 LV Status available $ open 0 LV Size 16.00 GiB Current LE 4096 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:2
掛載
$ mkfs.xfs -f /dev/vg01/app
meta-data=/dev/vg01/app isize=512 agcount=4, agsize=1048576 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=4194304, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
$ mkdir /app
$ cat << EOF | sudo tee -a /etc/fstab > /dev/null
/dev/vg01/app /app xfs defaults 0 0
EOF
$ mount -a
擴容
確認掛載點的檔案系統
$ df -Th
xfs檔案系統
etx4檔案系統
縮容
etx4檔案系統