ubuntu 安装系统后,硬盘没有全部使用,修改命令

ubuntu server 20.04 安装时,使用的lvm-group功能。

步骤:

安装后使用df 命令查看磁盘没有全部利用:

$ df -hl
Filesystem                         Size  Used Avail Use% Mounted on
udev                               1.9G     0  1.9G   0% /dev
tmpfs                              383M  1.5M  381M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv   98G  6.3G   87G   7% /
tmpfs                              1.9G     0  1.9G   0% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
tmpfs                              1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/loop0                          56M   56M     0 100% /snap/core18/2128
/dev/loop2                          71M   71M     0 100% /snap/lxd/21029
/dev/loop1                          33M   33M     0 100% /snap/snapd/12704
/dev/sda2                          976M  108M  801M  12% /boot
tmpfs                              383M     0  383M   0% /run/user/1000

使用 fdisk 命令可以看到是500g硬盘

$ sudo fdisk -l
Disk /dev/loop0: 55.45 MiB, 58130432 bytes, 113536 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop1: 32.3 MiB, 33865728 bytes, 66144 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop2: 70.32 MiB, 73728000 bytes, 144000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sda: 465.78 GiB, 500107862016 bytes, 976773168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt

设置使用剩余磁盘:

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

此时,还没有生效,如果用df命令查询,还是原来的状态

# 没有生效
$ df -hl
Filesystem                         Size  Used Avail Use% Mounted on
udev                               1.9G     0  1.9G   0% /dev
tmpfs                              383M  1.5M  381M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv   98G  6.3G   87G   7% /
tmpfs                              1.9G     0  1.9G   0% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
tmpfs                              1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/loop0                          56M   56M     0 100% /snap/core18/2128
/dev/loop2                          71M   71M     0 100% /snap/lxd/21029
/dev/loop1                          33M   33M     0 100% /snap/snapd/12704
/dev/sda2                          976M  108M  801M  12% /boot
tmpfs                              383M     0  383M   0% /run/user/1000

重新计算大小

$ sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
resize2fs 1.45.5 (07-Jan-2020)
Filesystem at /dev/mapper/ubuntu--vg-ubuntu--lv is mounted on /; on-line resizing required

此时查看已经修改:

$ df -hl
Filesystem                         Size  Used Avail Use% Mounted on
udev                               1.9G     0  1.9G   0% /dev
tmpfs                              383M  1.5M  381M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv  457G  6.4G  432G   2% /
tmpfs                              1.9G     0  1.9G   0% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
tmpfs                              1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/loop0                          56M   56M     0 100% /snap/core18/2128
/dev/loop2                          71M   71M     0 100% /snap/lxd/21029
/dev/loop1                          33M   33M     0 100% /snap/snapd/12704
/dev/sda2                          976M  108M  801M  12% /boot
tmpfs                              383M     0  383M   0% /run/user/1000

参考:

LVM使用管理及逻辑卷磁盘空间扩展_菜鸟日记-CSDN博客

  • 11
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值