ProxmoxVE(PVE) 减小缩减虚拟机硬盘设置的空间大小


ProxmoxVE(PVE) 减小缩减虚拟机硬盘设置的空间大小

Proxmox VE WEB UI上调整虚拟机磁盘大小只能增加,不能减小。
如果想减小空间设置,需要通过命令行调整
即是调整LV的大小,命令操作如下

以下命令需在节点得Shell中执行

查看虚拟机硬盘大小

先通过 lvs 命令查看虚拟机所设置的空间大小

root@pve:~# lvs
  LV                              VG  Attr       LSize   Pool Origin                  Data%  Meta%  Move Log Cpy%Sync Convert
  data                            pve twi-aotz-- <10.77t                              0.72   0.63                            
  root                            pve -wi-ao----  96.00g                                                                     
  snap_vm-100-disk-0_Init         pve Vri-a-tz-k 100.00g data vm-100-disk-0           4.82                                   
  snap_vm-101-disk-0_Init         pve Vri---tz-k 500.00g data vm-101-disk-0                                                  
  snap_vm-102-disk-0_Docker       pve Vri-a-tz-k 500.00g data vm-102-disk-0           1.99                                   
  snap_vm-102-disk-0_Init         pve Vri-a-tz-k 500.00g data vm-102-disk-0           1.89                                   
  snap_vm-102-disk-0_set_timezone pve Vri---tz-k 500.00g data vm-102-disk-0                                                  
  snap_vm-103-disk-0_Init         pve Vri---tz-k 500.00g data                                                                
  snap_vm-103-disk-0_MariaDB      pve Vri---tz-k 500.00g data vm-103-disk-0                                                  
  snap_vm-105-disk-0_Init         pve Vri---tz-k   1.00t data vm-105-disk-0                                                  
  snap_vm-106-disk-0_Docker       pve Vri---tz-k 100.00g data vm-106-disk-0                                                  
  snap_vm-106-disk-0_Init         pve Vri-a-tz-k 100.00g data vm-106-disk-0           2.28                                   
  snap_vm-107-disk-0_Rancher      pve Vri---tz-k 100.00g data vm-107-disk-0                                                  
  snap_vm-108-disk-0_Init         pve Vri---tz-k  10.00g data vm-108-disk-0                                                  
  snap_vm-108-disk-1_Init         pve Vri---tz-k  52.00m data vm-108-disk-1                                                  
  snap_vm-108-disk-2_Init         pve Vri---tz-k   4.00t data vm-108-disk-2                                                  
  snap_vm-108-disk-3_Init         pve Vri---tz-k   4.00t data vm-108-disk-3                                                  
  snap_vm-108-disk-4_Init         pve Vri---tz-k   4.00t data vm-108-disk-4                                                  
  swap                            pve -wi-ao----   8.00g                                                                     
  vm-100-disk-0                   pve Vwi-a-tz-- 100.00g data                         4.82                                   
  vm-101-disk-0                   pve Vwi-a-tz-- 500.00g data                         1.71                                   
  vm-102-disk-0                   pve Vwi-a-tz-- 500.00g data                         1.99                                   
  vm-103-disk-0                   pve Vwi-aotz-- 500.00g data snap_vm-103-disk-0_Init 2.02                                   
  vm-105-disk-0                   pve Vwi-aotz-- 924.00g data                         0.71                                   
  vm-106-disk-0                   pve Vwi-a-tz-- 100.00g data                         2.69                                   
  vm-106-state-Docker             pve Vwi-a-tz-- <16.49g data                         9.09                                   
  vm-107-disk-0                   pve Vwi-aotz-- 100.00g data                         7.46                                   
  vm-107-state-Rancher            pve Vwi-a-tz-- <16.49g data                         33.82                                  
  vm-108-disk-0                   pve Vwi-aotz--  10.00g data                         16.56                                  
  vm-108-disk-1                   pve Vwi-aotz--  52.00m data                         62.74                                  
  vm-108-disk-2                   pve Vwi-aotz--   4.00t data                         0.15                                   
  vm-108-disk-3                   pve Vwi-aotz--   4.00t data                         0.15                                   
  vm-108-disk-4                   pve Vwi-aotz--   4.00t data                         0.15                                   
  vm-108-state-Init               pve Vwi-a-tz-- <16.49g data                         3.89               

查看硬盘路径

然后执行 lvdisplay 来查看具体路径,我这个的路径是 /dev/pve/vm-105-disk-0

root@pve:~# lvdisplay
 
  --- Logical volume ---
  LV Path                /dev/pve/vm-105-disk-0
  LV Name                vm-105-disk-0
  VG Name                pve
  LV UUID                NC8FS6-aT32-vKvd-Die0-LgDr-FHgS-16UVXd
  LV Write Access        read/write
  LV Creation host, time pve, 2021-09-24 12:03:00 +0800
  LV Pool name           data
  LV Status              available
  # open                 1
  LV Size                924.00 GiB
  Mapped size            0.87%
  Current LE             236544
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:24
   
  --- Logical volume ---
  LV Path                /dev/pve/snap_vm-105-disk-0_Init
  LV Name                snap_vm-105-disk-0_Init
  VG Name                pve
  LV UUID                v5cCKU-Alrq-WnwA-L8dL-jaQp-7D5T-tUz4AA
  LV Write Access        read only
  LV Creation host, time pve, 2021-09-24 12:07:48 +0800
  LV Pool name           data
  LV Thin origin name    vm-105-disk-0
  LV Status              NOT available
  LV Size                1.00 TiB
  Current LE             262144
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto

缩减虚拟硬盘容量

执行下边的命令将空间大小减小100G

root@pve:~#  lvreduce -L -100G /dev/pve/vm-105-disk-0
  WARNING: Reducing active and open logical volume to 824.00 GiB.
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce pve/vm-105-disk-0? [y/n]: y
  Size of logical volume pve/vm-105-disk-0 changed from 924.00 GiB (236544 extents) to 824.00 GiB (210944 extents).
  Logical volume pve/vm-105-disk-0 successfully resized.

声明:初心|版权所有,违者必究|如未注明,均为原创|本网站采用BY-NC-SA协议进行授权

转载:转载请注明原文链接 - ProxmoxVE(PVE) 减小缩减虚拟机硬盘设置的空间大小


愿你勿忘初心,并从一而终