ubuntu20.04 service版本硬盘部分未挂载,实际容量不对。sda3部分未使用

news/2024/11/18 15:36:54/

现象:

在安装完ubuntu20.04的服务器版本以后,
发现一个固态被分成了3部分,并且一分部固态容量消失了!

root@mylinux:/dev# fdisk -l
Disk /dev/loop0: 63.24 MiB, 66301952 bytes, 129496 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/loop1: 63.28 MiB, 66347008 bytes, 129584 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/loop2: 91.85 MiB, 96292864 bytes, 188072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/loop3: 49.64 MiB, 52031488 bytes, 101624 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/loop4: 67.25 MiB, 70508544 bytes, 137712 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/sda: 111.81 GiB, 120034123776 bytes, 234441648 sectors
Disk model: KINGSTON SA400S3
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: BBF8C9A2-2432-46D4-A91A-02B5AB21DF03Device       Start       End   Sectors   Size Type
/dev/sda1     2048   2203647   2201600   1.1G EFI System
/dev/sda2  2203648   5349375   3145728   1.5G Linux filesystem
/dev/sda3  5349376 234438655 229089280 109.2G Linux filesystemDisk /dev/mapper/ubuntu--vg-ubuntu--lv: 54.63 GiB, 58644758528 bytes, 114540544 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

可以看到,三部分sda1,sda2,sda3
但是用指令df -h看到的实际容量不符合

root@mylinux:~# df -h
Filesystem                         Size  Used Avail Use% Mounted on
udev                               1.9G     0  1.9G   0% /dev
tmpfs                              384M  1.5M  383M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv   54G   15G   36G  30% /
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/loop1                          64M   64M     0 100% /snap/core20/1778
/dev/loop0                          64M   64M     0 100% /snap/core20/1738
/dev/loop2                          92M   92M     0 100% /snap/lxd/24061
/dev/loop3                          50M   50M     0 100% /snap/snapd/17883
/dev/sda2                          1.5G  205M  1.2G  15% /boot
/dev/loop4                          68M   68M     0 100% /snap/lxd/21835
/dev/sda1                          1.1G  5.3M  1.1G   1% /boot/efi
tmpfs                              384M     0  384M   0% /run/user/1000

我的固态是120G,明显少了几十G容量

继续输入命令:

root@mylinux:/dev# lsblk
NAME                      MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
loop0                       7:0    0  63.2M  1 loop /snap/core20/1738
loop1                       7:1    0  63.3M  1 loop /snap/core20/1778
loop2                       7:2    0  91.9M  1 loop /snap/lxd/24061
loop3                       7:3    0  49.6M  1 loop /snap/snapd/17883
loop4                       7:4    0  67.2M  1 loop /snap/lxd/21835
sda                         8:0    0 111.8G  0 disk
├─sda1                      8:1    0   1.1G  0 part /boot/efi
├─sda2                      8:2    0   1.5G  0 part /boot
└─sda3                      8:3    0 109.2G  0 part└─ubuntu--vg-ubuntu--lv 253:0    0  54.6G  0 lvm  /

OK,可以看到,sda3一共有109g,其中一部分被分成了ubuntu–vg-ubuntu–lv,逻辑卷,54G。
并且被挂载到了根目录下“/”,但是sda3并没有被完全使用,109-54=55G,没有被挂载到任何目录下
此时如果使用挂载指令

root@mylinux:/dev# mount /dev/sda3  /
mount: /: unknown filesystem type 'LVM2_member'.

会有mount: /: unknown filesystem type 'LVM2_member’的提示,其实就是因为部分被分成了逻辑卷,所以无法挂载,

解决方案:

我们可以选择直接增大逻辑卷的大小,将sda3完全占用即可
指令:lvextend -l +100%FREE /dev/mapper/ubuntu–vg-ubuntu–lv

root@mylinux:/dev# lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lvSize of logical volume ubuntu-vg/ubuntu-lv changed from <54.62 GiB (13982 extents) to 109.23 GiB (27964 extents).Logical volume ubuntu-vg/ubuntu-lv successfully resized.

然后刷新:resize2fs /dev/mapper/ubuntu–vg-ubuntu–lv

root@mylinux:/dev# 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
old_desc_blocks = 7, new_desc_blocks = 14
The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 28635136 (4k) blocks long.

现在用df -h查看硬盘使用情况:

root@mylinux:/dev# df -h
Filesystem                         Size  Used Avail Use% Mounted on
udev                               1.9G     0  1.9G   0% /dev
tmpfs                              384M  1.5M  383M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv  108G   15G   88G  15% /
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/loop1                          64M   64M     0 100% /snap/core20/1778
/dev/loop0                          64M   64M     0 100% /snap/core20/1738
/dev/loop2                          92M   92M     0 100% /snap/lxd/24061
/dev/loop3                          50M   50M     0 100% /snap/snapd/17883
/dev/sda2                          1.5G  205M  1.2G  15% /boot
/dev/loop4                          68M   68M     0 100% /snap/lxd/21835
/dev/sda1                          1.1G  5.3M  1.1G   1% /boot/efi
tmpfs                              384M     0  384M   0% /run/user/1000
root@mylinux:/dev# lsblk -l
NAME                  MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
loop0                   7:0    0  63.2M  1 loop /snap/core20/1738
loop1                   7:1    0  63.3M  1 loop /snap/core20/1778
loop2                   7:2    0  91.9M  1 loop /snap/lxd/24061
loop3                   7:3    0  49.6M  1 loop /snap/snapd/17883
loop4                   7:4    0  67.2M  1 loop /snap/lxd/21835
sda                     8:0    0 111.8G  0 disk
sda1                    8:1    0   1.1G  0 part /boot/efi
sda2                    8:2    0   1.5G  0 part /boot
sda3                    8:3    0 109.2G  0 part
ubuntu--vg-ubuntu--lv 253:0    0 109.2G  0 lvm  /

可以看到根目录下,硬盘大小恢复到了109G,解决!


http://www.ppmy.cn/news/336637.html

相关文章

无法完成安装:'Cannot access storage file '/

今天自己编译了spice-protocol spice-gtk spice qemu,然后想用virsh去创建一个虚机: # virsh define demo.xml 定义域 demo(从 demo.xml) # virsh start demo cannot access storage file (as uid:107, gid:107) permission denied 解决方法: Changing /etc…

Windows无法停用设备,原因是某个程序正在使用它...

有时候&#xff0c;当我们用完U盘需要弹出是&#xff0c;会出现“Windows无法停用设备&#xff0c;原因是某个程序正在使用它…”的黄色警告&#xff0c;很无奈。不过可以通过一些方法进行解决&#xff08;win10版&#xff09;&#xff1a; 1. 打开“文件资源管理器”&#xf…

python中多线程运行shell cmd,并且管理线程执行进度

问&#xff1a;如何在python3脚本中运行shell的命令? 答&#xff1a;subprocess import subprocess cmd"lsscsi" p subprocess.run(cmd,shellTrue,stdoutsubprocess.PIPE, stderrsubprocess.PIPE) print(p)看一下这个输出是什么 CompletedProcess(argslsscsi, re…

虚拟机linux ecap文件在,pve系统里配置虚拟机的网卡、硬盘直通

配置网卡、硬盘直通可以增加硬盘写入速度、网卡减小延迟、增加访问速度,避免因为虚拟化之后的资源浪费。如果没有配置好pve环境与BIOS,添加设备时会出现No IOMMU detected, please activate it.See Documentation for further information.的报错,启动虚拟机失败: 提示如下…

API REST com春季+ Testes com MockMVC +Documentaçãocom Swagger

Introduo REST API REST 100&#xff05;功能性PostgreSQL数据库&#xff0c;Spring数据JPA参数&#xff0c;作为咨询机构&#xff0c;DTO数据包&#xff0c;Duals数据集&#xff0c;dadas总线数据集&#xff0c; MockMVC和Swagger的形式化文档&#xff0c;集成了有效的Nossos…

小米fortnite_我如何仅用1,001美元(与我12岁的孩子)构建自己的Fortnite DIY游戏平台

小米fortnite So, my 12-year old decided that she needed a more powerful computer for her favorite video game, Fortnite. And I promised her, years ago, that we’d find a time to custom-build her own computer. 因此&#xff0c;我12岁的她决定为自己喜欢的视频游…

QQ再次被大规模盗号

我是卢松松&#xff0c;点点上面的头像&#xff0c;欢迎关注我哦&#xff01; QQ被大规模盗号已经不是一次两次了&#xff0c;感觉腾讯好像没有太好的解决办法。 昨天(周日)QQ又出下了大规模盗号情况&#xff1a;大量用户反馈称遇到了自己或是身边的朋友、家人、同事等被盗号…

教你如何找回被盗QQ的好友

现在QQ盗号让人防不胜防&#xff0c;一不小心QQ号就被盗了。号盗了没有什么&#xff0c;可以再申请一个(不过之前还可以试试把密码找回来&#xff0c;如果里面的朋友没了&#xff0c;那可怎么办呀&#xff1f;下面介绍如何让好友都回来的方法&#xff1a; 1.首先必须保证你的电…