环境:kvm
系统:CentOS7
故障描述:10g的ssd,可使用大小仅有2g
解决过程:
? ? 某次重装系统后,安装软件总提示磁盘空间不足,检查之下发现仅有2G空间,实则明明是10G的ssd,以下为排错过程:
1、df -h查看vda1大小为2.7G
#df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 2.7G 2.4G 236M 91% /
devtmpfs 234M 0 234M 0% /dev
tmpfs 244M 0 244M 0% /dev/shm
tmpfs 244M 4.5M 240M 2% /run
tmpfs 244M 0 244M 0% /sys/fs/cgroup
tmpfs 49M 0 49M 0% /run/user/0
2、fdisk查看vda1一共9959232个block,大小应为9959232KB=9.725.8GB
#fdisk -l
Disk /dev/vda: 10.7 GB, 10737418240 bytes, 20971520 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 label type: dos
Disk identifier: 0x000f3770
?? Device Boot????? Start???????? End????? Blocks?? Id? System
/dev/vda1?? *??????? 2048??? 19920511? ???9959232?? 83? Linux
/dev/vda2??????? 19920512??? 20969087????? 524288?? 82? Linux swap / Solaris
3、尝试能否通过新建分区解决的时候,发现了另一个bug,居然能看到主机的真实磁盘大小!
#fdisk /dev/vda
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): u
Changing display/entry units to cylinders (DEPRECATED!).
Command (m for help): n
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p): p
Partition number (3,4, default 3): 3
First cylinder (1306-20805, default 1306):
Using default value 1306
Last cylinder, +cylinders or +size{K,M,G} (1306-20805, default 20805):
Using default value 20805
Partition 3 of type Linux and of size 149.4 GiB is set? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
//剩余149.4G,加上我自己的10G,这块SSD的大小应该是160G的,当然仅此而已了,想要盗用还是不可能的,至少我办不到。囧
Command (m for help): q
fdisk -l? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
//虽然fdisk看到的vda3貌似很厉害的样子
Disk /dev/vda: 10.7 GB, 10737418240 bytes, 20971520 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 label type: dos
Disk identifier: 0x000f3770
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 19920511 9959232 83 Linux
/dev/vda2 19920512 20969087 524288 82 Linux swap / Solaris
/dev/vda3 20969088 334232324 156631618+ 83 Linux
4、partprobe的时候果然报错了哈哈哈
#partprobe
Error: Can‘t have a partition outside the disk!
5、fdisk看到的vda1大小正常,并且也没有多余的可用空间来新建分区,说明问题不是出在磁盘空间分配上,此路不通。
所以删除那个奇葩的vda3,尝试resize方法
#resize2fs /dev/vda1
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/vda1 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 2
The filesystem on /dev/vda1 is now 2489808 blocks long.
6、fdisk数据并无变化,但df显示磁盘空间终于正常了,安装程序也不会再提示磁盘空间不足,故障排除。
fdisk -l
Disk /dev/vda: 10.7 GB, 10737418240 bytes, 20971520 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 label type: dos
Disk identifier: 0x000f3770
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 19920511 9959232 83 Linux
/dev/vda2 19920512 20969087 524288 82 Linux swap / Solaris
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 9.3G 2.4G 6.6G 27% /
devtmpfs 234M 0 234M 0% /dev
tmpfs 244M 0 244M 0% /dev/shm
tmpfs 244M 4.5M 240M 2% /run
tmpfs 244M 0 244M 0% /sys/fs/cgroup
tmpfs 49M 0 49M 0% /run/user/0
个人blog:https://www.moonshadows.cn/
原文地址:http://blog.51cto.com/7308842/2299008
时间: 2024-11-05 16:04:23