当前位置: 首页 > news >正文

(原)记一次CentOS7 磁盘空间大小异常的解决过程

环境: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/

转载于:https://blog.51cto.com/7308842/2299008

相关文章:

  • python里使用反斜杠转义遇到问题记录
  • AliOS Things 电源管理框架使用说明
  • python三级菜单实例(傻瓜版和进阶版)
  • linux之HTTP服务
  • 【原】戏说Java
  • WPF 获取鼠标屏幕位置、窗口位置、控件位置
  • 使用ABAP正则表达式解析HTML标签
  • 计算机英语学习笔记(六)
  • java多线程和长连接,三方转换通信的实践(1)——转换端程序
  • 【呆鸟译Py】这位老师的70个问题,100个数据分析师都想不全
  • 用Gmail做QQ邮件群发的一种方式
  • 机器人操作系统来到Windows
  • sublime text3
  • Spring Cloud 之 Consul 与 Consul 服务剔除
  • 阿里中间件开源组件:Sentinel 0.2.0正式发布
  • crontab执行失败的多种原因
  • Git初体验
  • Java精华积累:初学者都应该搞懂的问题
  • magento 货币换算
  • Redis字符串类型内部编码剖析
  • Spring Cloud Feign的两种使用姿势
  • Sublime Text 2/3 绑定Eclipse快捷键
  • vue从入门到进阶:计算属性computed与侦听器watch(三)
  • windows下mongoDB的环境配置
  • Zsh 开发指南(第十四篇 文件读写)
  • 纯 javascript 半自动式下滑一定高度,导航栏固定
  • 构造函数(constructor)与原型链(prototype)关系
  • 关于Flux,Vuex,Redux的思考
  • 软件开发学习的5大技巧,你知道吗?
  • 微信开放平台全网发布【失败】的几点排查方法
  • 小李飞刀:SQL题目刷起来!
  • 移动互联网+智能运营体系搭建=你家有金矿啊!
  • 应用生命周期终极 DevOps 工具包
  • 湖北分布式智能数据采集方法有哪些?
  • 昨天1024程序员节,我故意写了个死循环~
  • !$boo在php中什么意思,php前戏
  • #if #elif #endif
  • #LLM入门|Prompt#2.3_对查询任务进行分类|意图分析_Classification
  • #在线报价接单​再坚持一下 明天是真的周六.出现货 实单来谈
  • (2)nginx 安装、启停
  • (4)Elastix图像配准:3D图像
  • (C语言)字符分类函数
  • (办公)springboot配置aop处理请求.
  • (二)JAVA使用POI操作excel
  • (每日持续更新)jdk api之FileFilter基础、应用、实战
  • (每日持续更新)jdk api之FileReader基础、应用、实战
  • (一)UDP基本编程步骤
  • (转)关于多人操作数据的处理策略
  • (转)母版页和相对路径
  • (最优化理论与方法)第二章最优化所需基础知识-第三节:重要凸集举例
  • .Family_物联网
  • .NET Core MongoDB数据仓储和工作单元模式封装
  • .net core 微服务_.NET Core 3.0中用 Code-First 方式创建 gRPC 服务与客户端
  • .NET Core 中的路径问题
  • .NET/C# 编译期能确定的字符串会在字符串暂存池中不会被 GC 垃圾回收掉