手抄报 安全手抄报 手抄报内容 手抄报图片 英语手抄报 清明节手抄报 节约用水手抄报

No space left on device磁盘空间不足解决方法

时间:2024-10-11 22:02:42

1、模拟测试环境系统:centos 7.2,磁盘空间8G,CPU 4核,内存4G(最好给大点,创建文件需要大内存)[root@xm ~]# mkdir /test[root@xm ~]# echo /test/{1..6000000}.txt |xargs touch #创建的文件太多了,只能用这种方式创建。

2、当进入编辑cronta或者创建文件时,直接报错,提示磁盘空间不足[root@xm ~]# crontab -e/tmp/crontab.MApBTV: No space left on device[root@xm ~]# touch xmh.txttouch: cannot touch ‘xmh.txt’: No space left on device2.查看磁盘空间[root@xm ~]# df -hFilesystem Size Used Avail Use% Mounted on/dev/sda1 8.0G 3.2G 4.9G 39% / ##可以发现磁盘容量是空闲很多的devtmpfs 1.7G 0 1.7G 0% /devtmpfs 1.7G 0 1.7G 0% /dev/shmtmpfs 1.7G 8.7M 1.7G 1% /runtmpfs 1.7G 0 1.7G 0% /sys/fs/cgrouptmpfs 332M 0 332M 0% /run/user/03.查看inode空间[root@xmh ~]# df -iFilesystem Inodes IUsed IFree IUse% Mounted on/dev/sda1 4193792 4193792 0 100% / #但是inode空间已满了devtmpfs 422466 395 422071 1% /devtmpfs 424923 1 424922 1% /dev/shmtmpfs 424923 473 424450 1% /runtmpfs 424923 16 424907 1% /sys/fs/cgrouptmpfs 424923 1 424922 1% /run/user/0

3、解决方法:使用find命令查找大于10M的目录,可以从df -i看出是在 根 /下容量不足,那么就从 / 下开始排查。[root@xm ~]# find / -type d -size +10M |xargs ls -lhd #find查找drwxr-xr-x. 2 root root 97M Feb 15 14:00 /test[root@xm ~]# ls /test/ |wc -l #对该目录文件数量统计4168011#定位好目录后删除小文件[root@xm /]# rm -rf /test/* #直接 rm -rf * 的话是删除不了大量的小文件-bash: /usr/bin/rm: Argument list too long[root@xm /]# cd /test/[root@xm test]# ls |xargs rm -f#删除大量的小文件,使用该命令删除[root@xm /]# ls /test/ |wc -l #小文件已经删除了#再次查看inode容量[root@xm ~]# df -iFilesystem Inodes IUsed IFree IUse% Mounted on/dev/sda1 4193792 25973 4167819 1% / #inode容量已恢复正常devtmpfs 422466 395 422071 1% /devtmpfs 424923 1 424922 1% /dev/shmtmpfs 424923 473 424450 1% /runtmpfs 424923 16 424907 1% /sys/fs/cgrouptmpfs 424923 1 424922 1% /run/user/0#最后删除小文件所在的目录(删除时注意记录该目录的所属用户和权限)[root@xm/]# rm -rf /test/

© 手抄报圈