10

linux分区未使用全部磁盘空间时的补救

 1 year ago
source link: https://blog.landon.li/2023/02/01/linux%E5%88%86%E5%8C%BA%E6%9C%AA%E4%BD%BF%E7%94%A8%E5%85%A8%E9%83%A8%E7%A3%81%E7%9B%98%E7%A9%BA%E9%97%B4%E6%97%B6%E7%9A%84%E8%A1%A5%E6%95%91/?amp%3Butm_medium=rss&%3Butm_campaign=linux%25e5%2588%2586%25e5%258c%25ba%25e6%259c%25aa%25e4%25bd%25bf%25e7%2594%25a8%25e5%2585%25a8%25e9%2583%25a8%25e7%25a3%2581%25e7%259b%2598%25e7%25a9%25ba%25e9%2597%25b4%25e6%2597%25b6%25e7%259a%2584%25e8%25a1%25a5%25e6%2595%2591
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

linux分区未使用全部磁盘空间时的补救 | Landon's Bloglinux分区未使用全部磁盘空间时的补救

2023-2-01 12:08

偶然发现之前在 pve 上创建的 vm 没有使用全部的磁盘空间

image-20230201224507232.png

pve 页面上分配的磁盘大小是 32G,而在 vm 中使用 df 命令看到的只有 17G 左右,缺少了 15G 的空间

image-20230201224617356-1024x191.png

使用命令 lsblk 可以看到,sda3 上还有 15G 的空间没有分配

sudo fdisk -l

经过一番探索,可以通过以下步骤增加逻辑卷的大小

先调整逻辑卷的大小,使用 sda3 的全部剩余空间

sudo lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv

再调整文件系统的大小

sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv

此时,可以看到之前未分配的空间被用上了

Reference: https://askubuntu.com/questions/1417938/ubuntu-does-not-use-full-disk-space-how-to-extend

本文作者: Landon Li
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议,转载请注明来源。

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK