Skip to main content

Ubuntu扩展 /dev/mapper/ubuntu--vg-ubuntu--lv空间

Ubuntu扩展 /dev/mapper/ubuntu--vg-ubuntu--lv空间

1. 查看磁盘空间

root@root:~# df -h
Filesystem                         Size  Used Avail Use% Mounted on
udev                               1.9G     0  1.9G   0% /dev
tmpfs                              393M  2.1M  391M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv   14G  4.4G  8.8G  34% /
tmpfs                              2.0G     0  2.0G   0% /dev/shm
tmpfs                              5.0M  4.0K  5.0M   1% /run/lock
tmpfs                              2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/loop0                          90M   90M     0 100% /snap/core/8268
/dev/sda2                          976M   82M  828M   9% /boot
tmpfs                              393M   20K  393M   1% /run/user/125
tmpfs                              393M   56K  393M   1% /run/user/1000

查看vg

root@root:~# vgdisplay
  --- Volume group ---
  VG Name               ubuntu-vg
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <79.00 GiB
  PE Size               4.00 MiB
  Total PE              20223
  Alloc PE / Size       3584 / 14.00 GiB
  Free  PE / Size       16639 / <65.00 GiB
  VG UUID               mg1Zau-atla-jy56-ycyN-e6dS-UJC9-1ErQU7

扩展

lvextend -L 120G /dev/mapper/ubuntu--vg-ubuntu--lv     //增大至120G
lvextend -L +20G /dev/mapper/ubuntu--vg-ubuntu--lv     //增加20G
lvreduce -L 50G /dev/mapper/ubuntu--vg-ubuntu--lv      //减小至50G
lvreduce -L -8G /dev/mapper/ubuntu--vg-ubuntu--lv      //减小8G
lvresize -L  30G /dev/mapper/ubuntu--vg-ubuntu--lv     //调整为30G

调整

resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv            //执行调整