Why did I allocate 32G hard disk to the virtual machine, but Ubuntu only recognizes 16G?
I allocated a 32G disk in PVE, but it only shows as 15G in Ubuntu—where did this LVM stuff hide the space? The root directory alone took half? What kind of logic is this? It's utterly absurd. The three-step expansion process is straightforward, but who would actually use such a poorly designed setup?
目录4 个章节
Preface
Recently discovered my Ubuntu server freezing inexplicably
Logged in to check and found the hard drive was full
But using df -h revealed something strange—I had clearly allocated 32G of space in PVE, yet Ubuntu only showed 16G
$ df -h
/dev/mapper/ubuntu--vg-ubuntu--lv 15G 14G 0 100% /
Wait, what? I allocated 32G, so why is only 15G showing? Didn't half the space just vanish into thin air?
Initially thought it was a disk configuration error in PVE, but later realized—it really wasn't PVE's fault.
Very strange.
After some research, the reason turned out to be that the virtual disk allocated by PVE uses LVM.
The entire situation involves the layered relationship between virtualization disk, partition, LVM logical volume, and file system.
The Truth
Originally, Ubuntu enables LVM (Logical Volume Manager) by default during installation.
The logic of LVM is as follows: First, the entire disk is configured as a "Volume Group" (VG), and then several "Logical Volumes" (LVs) are created from it to be mounted and used.
The problem arises here—the installer, by default, allocates only about half of the space to the root directory.
Thus, although the virtual disk is 32GB, the root directory only received 16GB, while the remaining space quietly sits unused in the Volume Group.
It's somewhat like buying a 32GB USB drive but only creating a single 16GB partition to use, leaving the rest forgotten in a corner.
Expansion
Now that you know the cause, it's easy to fix. Just three simple steps:
Execute on the Ubuntu server:
# 1. Check the remaining space in the volume group
# Here it displays Free PE / Size, which is the unallocated space in the volume group (LVM).
vgdisplay
# 2. Expand the root logical volume to use all remaining space
# Here, +100%FREE means to allocate all remaining space in the volume group to this logical volume.
lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
# 3. Extend the Filesystem to Actually Utilize the Space
resize2fs /dev/ubuntu-vg/ubuntu-lv
Here, the default filesystem is ext4, so we use the resize2fs command.
For xfs, use xfs_growfs /.
Then let's check with df -h... Perfect!
/dev/mapper/ubuntu--vg-ubuntu--lv 31G 14G 17G 45% /
Summary
This time, I got a lesson from LVM
I hadn't really used LVM before
Next time you see a situation like "allocated 32G but only showing 15G," you can try the solution described in this article.
_EOF_
Why did I allocate 32G hard disk to the virtual machine, but Ubuntu only recognizes 16G?
- 本文作者:
- 程序设计实验室
- 版权声明:
- 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
相关文章
个人数据保全计划:(4)基础环境配置
关闭swap 内存足够的话(8G以上),可以考虑关闭swap提高系统性能 查看开启了哪些swap cat /proc/swaps 输出 | Filename | Type | Size | Used | Priority | | ------------------------------------- | ----
2022-11-13 · 个人数据保全计划 · 约 1 分钟
个人数据保全计划:安装Jellyfin
选择镜像:nyanmisaka/jellyfin Jellyfin中国特供版+Docker镜像,含驱动,免折腾开箱即用:https://post.smzdm.com/p/a3gw6g47/ 使用 docker-compose 部署 cd /share/Container/docker-apps/jellyfin mkdir cache config docker命令 docker run -d -
2022-11-04 · 个人数据保全计划 · 约 1 分钟
PVE折腾笔记 (1) 告别卡顿的QTS,在威联通TS464c上安装PVE系统
QNAP 的 QTS 系统真是垃圾中的垃圾,臃肿不堪还拖慢速度。换个 PVE 系统立马飞起,纯净高效,性能和自由度直接拉满。折腾安装过程虽然繁琐,但结果绝对物超所值,NAS 升级服务器只需一步。
2025-06-15 · 个人数据保全计划 · 约 1 分钟
个人数据保全计划:如何安全地备份数据
呵,用mc这种上古文件管理器备份数据还沾沾自喜?rsync干校验的姿势倒是勉强及格。最后还煞有介事地生成sha256清单——这年头不会真有人手动校验冷备吧?
2025-06-16 · 个人数据保全计划 · 约 1 分钟
讨论
共 0 条加载评论中…