linux no space left on device 错误解决方法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xiao3404/article/details/86316755

今天在Ubuntu系统上编译vlc视频播放器,由于编译一直有问题,下载并编译了三四份,最后一次编译过程中,发现系统提示“no space left on device”. 第一眼还没看出这是什么情况,后面通过查资料发现这是系统磁盘空间不足的意思,这才焕然大悟是因为代码以及编译产生文件太多导致的。

好了,说明了背景,下面给出解决问题的过程和涉及的知识,整个解决过程不难,但对掌握linux很有收获。

df命令

命令:df = disk free

下面给是man给出的df命令功能说明:
Show information about the file system on which each FILE resides,or all file systems by default

常见参数有:

  • -T, --print-type print file system type
  • -h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G)
  • -B, --block-size=SIZE scale sizes by SIZE before printing them; e.g.,’-BM’ prints sizes in units of 1,048,576 bytes;

首先,使用df -hT命令查看当前文件系统信系,显示如下:
在这里插入图片描述


Filesystem type Size Used Avail Use% Mounted on
文件系统 类型 磁盘空间 已用空间 可用空间 使用率 挂载目录

当时系统环境显示 /dev/xvda1文件系统使用已经达到100%,所以需要进入该文件系统所挂载的目录进行具体分析。该路径是根目录\.

du命令

下面需要使用du命令进行磁盘文件分析,首先给出du命令功能和常见参数说明。

命令 du = disk usage

下面是man 上面 du命令功能说明:

Summarize disk usage of each FILE, recursively for directories.

翻译过来就是,用于查看每个文件磁盘大小,目录可以递归查询。

常见解释:

  • h print sizes in human readable format (e.g., 1K 234M 2G)
  • c produce a grand total 累计大小
  • d --max-depth=N print the total for a directory 目录深度

我们在输入如下命令

# cd /  切换根目录
# du -ch --max-depth=0 * | sort -h 查看对根目录下的文件大小并排序

执行效果如下:
(当下系统多余文件已被删除,所以使用了只有49%,但执行步骤相同)
在这里插入图片描述
执行完以上两条命令后,就好打印出根目录下个各个子目录文件大小。当前是home最大 达到5.1G .

我们可以使用同样的命令分析/home目录下的文件大小。遇到无用的文件,使用rm命令删除,次后再用df命令分析文件系统,即可解决问题。

好了,以上就是我在linux系统下遇到no space left on device错误提示的解决步骤了。希望大家linux玩耍愉快!!!

猜你喜欢

转载自blog.csdn.net/xiao3404/article/details/86316755