虚拟机安装Ubuntu磁盘未全部利用问题处理

在VMware中安装Ubuntu虚拟机时,分配的磁盘空间为30GB。
虚拟机安装Ubuntu磁盘未全部利用问题处理_第1张图片
安装完毕进入系统查看文件系统空间时,发现挂载的磁盘空间仅为14GB。

root@localhost:~# df -h
Filesystem                         Size  Used Avail Use% Mounted on
tmpfs                              193M  3.8M  190M   2% /run
/dev/mapper/ubuntu--vg-ubuntu--lv   14G  4.8G  8.3G  37% /
tmpfs                              965M     0  965M   0% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
/dev/sda2                          2.0G  130M  1.7G   8% /boot
tmpfs                              193M  4.0K  193M   1% /run/user/1000
tmpfs                              193M  4.0K  193M   1% /run/user/0

通过vgdisplay命令查看还有14GB可用空间可以分配。

root@localhost:~# vgdisplay
  --- Volume group ---
  VG Name               ubuntu-vg
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  2
  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               <28.00 GiB
  PE Size               4.00 MiB
  Total PE              7167
  Alloc PE / Size       3583 / <14.00 GiB
  Free  PE / Size       3584 / 14.00 GiB
  VG UUID               ulmbny-bHHO-0scj-K85B-Q2Z8-I2k6-1CFaoj

按比例将剩余空间都分配给ubuntu--vg-ubuntu--lv

root@localhost:~# lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
  Size of logical volume ubuntu-vg/ubuntu-lv changed from <14.00 GiB (3583 extents) to <28.00 GiB (7167 extents).
  Logical volume ubuntu-vg/ubuntu-lv successfully resized.

接下来调整文件系统大小。

root@angkor:~# resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
resize2fs 1.46.5 (30-Dec-2021)
Filesystem at /dev/mapper/ubuntu--vg-ubuntu--lv is mounted on /; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 4
The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 7339008 (4k) blocks long.

现在再次查看磁盘空间,/dev/mapper/ubuntu--vg-ubuntu--lv的空间大小已经调整为28G了。

root@angkor:~# df -h
Filesystem                         Size  Used Avail Use% Mounted on
tmpfs                              193M  3.8M  190M   2% /run
/dev/mapper/ubuntu--vg-ubuntu--lv   28G  4.8G   22G  19% /
tmpfs                              965M     0  965M   0% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
/dev/sda2                          2.0G  130M  1.7G   8% /boot
tmpfs                              193M  4.0K  193M   1% /run/user/1000
tmpfs                              193M  4.0K  193M   1% /run/user/0

你可能感兴趣的:(ubuntu,ubuntu,linux,运维)