From c9ce9b47f47e3892949cccca34c7438958b2ed20 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 1 Jan 2018 21:02:13 +0800 Subject: [PATCH] =?UTF-8?q?translate=20done:=2020171115=20How=20to=20Fix?= =?UTF-8?q?=20the=20=E2=80=98No=20Space=20Left=20on=20Device-=20Error=20on?= =?UTF-8?q?=20Linux.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...€˜No Space Left on Device- Error on Linux.md | 93 ------------------- ...€˜No Space Left on Device- Error on Linux.md | 92 ++++++++++++++++++ 2 files changed, 92 insertions(+), 93 deletions(-) delete mode 100644 sources/tech/20171115 How to Fix the ‘No Space Left on Device- Error on Linux.md create mode 100644 translated/tech/20171115 How to Fix the ‘No Space Left on Device- Error on Linux.md diff --git a/sources/tech/20171115 How to Fix the ‘No Space Left on Device- Error on Linux.md b/sources/tech/20171115 How to Fix the ‘No Space Left on Device- Error on Linux.md deleted file mode 100644 index 0ab151e9d5..0000000000 --- a/sources/tech/20171115 How to Fix the ‘No Space Left on Device- Error on Linux.md +++ /dev/null @@ -1,93 +0,0 @@ -translating by lujun9972 -How to Fix the ‘No Space Left on Device’ Error on Linux -====== - -![](https://www.maketecheasier.com/assets/uploads/2017/10/no-space-feat.jpg) - -So your Linux system is telling you that you have no space left on your hard drive, but you know there is actually a lot of free space left. Why? This is one of those few frustratingly vague errors on Linux systems, but there are a few usual culprits. - -## Check du and df - -Before you go any further, it's a good idea to check that there really _is_ space left on the disk. While the tools in your desktop environment are good, it 's much better to use the direct ones from the command line. - -![Linux Filesystem du][1] - -Begin with `du`. Point it to the base directory on the drive that's having the problem. This guide is assuming it's the partition with root. -``` -sudo du -sh / -``` - -![Linux Filesystem df][2] - -It'll take some time to go through everything. Now, try with `df`. -``` -sudo df -h -``` - -Add root and the filesystems mounted under it. For example, if you have "/home" on a separate drive, add that in with the reading for root. The total should come out close to what you had with `du`. If not, that might point toward a deleted file being used by a process. - -Of course, the main concern here is whether or not the results of these commands come in under the size of the drive. If it did, there's obviously something wrong. - - **Related** : [Use Agedu to Analyze Hard Disk Space Usage in Linux][3] - -## Possible Causes - -There are a couple of main causes here. If you saw a discrepancy between `du` and `df` you can jump down to the first option here. Otherwise, start at the second one. - -### Deleted File Reserved by Process - -Occasionally, a file will be deleted, but a process is still using it. Linux won't release the storage associated with the file while the process is still running. You just need to find the process and restart it. - -![Check processes for deleted files][4] - -Try to locate the process. -``` -sudo lsof / | grep deleted -``` - -The problematic process should be listed, then just restart it. -``` -sudo systemctl restart service_name -``` - -### Not Enough Inodes - -![Linux check filesystem inodes][5] - -There is a set of metadata on filesystems called "inodes." Inodes track information about files. A lot of filesystems have a fixed amount of inodes, so it's very possible to fill the max allocation of inodes without filling the filesystem itself. You can use `df` to check. -``` -sudo df -i / -``` - -Compare the inodes used with the total inodes. If there's no more available, unfortunately, you can't get more. Delete some useless or out-of-date files to clear up inodes. - -### Bad Blocks - -The last common problem is bad filesystem blocks. Filesystems get corrupt and hard drives die. Your operating system will most likely see those blocks as usable unless they're otherwise marked. The best way to find and mark those blocks is by using `fsck` with the `-cc` flag. Remember that you can't use `fsck` from the same filesystem that you're testing. You'll probably need to use a live CD. -``` -sudo fsck -vcck /dev/sda2 -``` - -Obviously, replace the drive location with the drive that you want to check. Also, keep in mind that this will probably take a long time. - - **Related** : [Check and Repair Your Filesystem With fsck [Linux]][6] - -Hopefully, one of these solutions solved your problem. This issue isn't exactly easy to diagnose in every instance. With any luck, though, you can get it cleared up and have your hard drive working again as normal. - --------------------------------------------------------------------------------- - -via: https://www.maketecheasier.com/fix-linux-no-space-left-on-device-error/ - -作者:[Nick Congleton][a] -译者:[lujun9972](https://github.com/lujun9972) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) è£èª‰æŽ¨å‡º - -[a]:https://www.maketecheasier.com/author/nickcongleton/ -[1]:https://www.maketecheasier.com/assets/uploads/2017/10/no-space-du.jpg (Linux Filesystem du) -[2]:https://www.maketecheasier.com/assets/uploads/2017/10/no-space-df.jpg (Linux Filesystem df) -[3]:https://www.maketecheasier.com/agedu-analyze-hard-disk-space-usage-in-linux/ (Use Agedu to Analyze Hard Disk Space Usage in Linux) -[4]:https://www.maketecheasier.com/assets/uploads/2017/10/no-space-process.jpg (Check processes for deleted files) -[5]:https://www.maketecheasier.com/assets/uploads/2017/10/no-space-inode.jpg (Linux check filesystem inodes) -[6]:https://www.maketecheasier.com/check-repair-filesystem-fsck-linux/ (Check and Repair Your Filesystem With fsck [Linux]) diff --git a/translated/tech/20171115 How to Fix the ‘No Space Left on Device- Error on Linux.md b/translated/tech/20171115 How to Fix the ‘No Space Left on Device- Error on Linux.md new file mode 100644 index 0000000000..f6545ab846 --- /dev/null +++ b/translated/tech/20171115 How to Fix the ‘No Space Left on Device- Error on Linux.md @@ -0,0 +1,92 @@ +如何解决 Linux 中‘ç£ç›˜ç©ºé—´ä¸è¶³â€™çš„问题 +====== + +![](https://www.maketecheasier.com/assets/uploads/2017/10/no-space-feat.jpg) + +明明有很多剩余空间,但 Linux 系统ä¾ç„¶æ示没有空间剩余。为什么会这样呢?Linux å¶å°”会有一些令人沮丧的模糊错误出现,而这就是其中一ç§ã€‚ä¸è¿‡è¿™ç§é”™è¯¯é€šå¸¸éƒ½æ˜¯ç”±æŸå‡ ç§å› ç´ å¯¼è‡´çš„。 + +## 通过 du å’Œ df 检查ç£ç›˜ç©ºé—´ + +在开始行动å‰ï¼Œæœ€å¥½å…ˆæ£€æŸ¥ä¸€ä¸‹æ˜¯å¦ç£ç›˜ä¸Šæ˜¯å¦ç¡®å®žè¿˜æœ‰ç©ºé—´å‰©ä½™ã€‚虽然桌é¢çŽ¯å¢ƒçš„工具也很ä¸é”™ï¼Œä½†å‘½ä»¤è¡Œä¸Šçš„工具更直接,è¦å¥½çš„多。 + +![Linux Filesystem du][1] + +首先让我们看看 `du` 命令。用它æ¥æ£€æŸ¥é—®é¢˜ç£ç›˜æ‰€åœ¨çš„挂载点目录。本文å‡è®¾å‡ºé—®é¢˜çš„分区挂载点为根目录。 +``` +sudo du -sh / +``` + +![Linux Filesystem df][2] + +由于它è¦é历ç£ç›˜ä¸­çš„所有文件,因此需è¦èŠ±è´¹ä¸€ç‚¹æ—¶é—´ã€‚现在å†è®©æˆ‘们试试 `df`。 +``` +sudo df -h +``` + +把根目录和在其中挂载的文件系统加在这æ¡å‘½ä»¤çš„åŽé¢ã€‚比如,若你的有一个独立的ç£ç›˜æŒ‚载到 "/home",那么除了根目录之外,你也需è¦æŠŠå®ƒåŠ è¿›æ¥ã€‚使用空间的总和应该跟你 `du` 命令得到的结果接近。å¦åˆ™çš„è¯ï¼Œå°±è¯´æ˜Žå¯èƒ½æœ‰å·²åˆ é™¤æ–‡ä»¶çš„文件被进程å ç”¨ã€‚ + +当然,这里主è¦ä¸“注点在于这些命令的结果是å¦è¦å°äºŽç£ç›˜çš„大å°ã€‚如果确实å°äºŽç£ç›˜å¤§å°ï¼Œé‚£ä¹ˆå¾ˆæ˜Žæ˜¾æœ‰å¾ˆä¹ˆåœ°æ–¹ä¸å¯¹åŠ²ã€‚ + + **相关**:[使用 Agedu 分æžç¡¬ç›˜ç©ºé—´ä½¿ç”¨çŠ¶å†µ ][3] + +## å¯èƒ½çš„原因 + +这里列出了一些产生这ç§æƒ…况的主è¦åŽŸå› ã€‚若你å‘现 `du` å’Œ `df` 的结果之间有差别,那么å¯ä»¥ç›´æŽ¥æ£€æŸ¥ç¬¬ä¸€é¡¹åŽŸå› ã€‚å¦åˆ™ä»Žç¬¬äºŒé¡¹åŽŸå› å¼€å§‹æ£€æŸ¥ã€‚ + +### 已删除文件被进程所å ç”¨ + +有时,文件å¯èƒ½å·²ç»è¢«åˆ æŽ‰äº†ï¼Œä½†æœ‰è¿›ç¨‹ä¾ç„¶åœ¨ä½¿ç”¨å®ƒã€‚在进程è¿è¡ŒæœŸé—´ï¼ŒLinux ä¸ä¼šé‡Šæ”¾è¯¥æ–‡ä»¶çš„存储空间。你需è¦æ‰¾å‡ºè¿™ä¸ªè¿›ç¨‹ç„¶åŽé‡å¯è¿™ä¸ªè¿›ç¨‹ã€‚ + +![Check processes for deleted files][4] + +使用下é¢å‘½ä»¤æ¥å®šä½è¿›ç¨‹ã€‚ +``` +sudo lsof / | grep deleted +``` + +这应该会列出出问题的进程了,然åŽé‡å¯è¯¥è¿›ç¨‹ã€‚ +``` +sudo systemctl restart service_name +``` + +### i 节点ä¸å¤Ÿäº† + +![Linux check filesystem inodes][5] + +文件系统中有一些称为 "i 节点" 的元数æ®"。其用æ¥ä¿å­˜æ–‡ä»¶çš„相关信æ¯ã€‚很多文件系统中的 i 节点数é‡æ˜¯å›ºå®šçš„,因此很å¯èƒ½ i 节点已ç»è€—尽了而文件系统本身还没有用完。你å¯ä»¥ä½¿ç”¨ `df` æ¥æ£€æŸ¥ã€‚ +``` +sudo df -i / +``` + +比较一下已用的 i 节点和总共的 i 节点数é‡ã€‚如果没有å¯ç”¨çš„ i 节点了,那么很ä¸å¹¸ï¼Œä½ ä¹Ÿæ— æ³•æ‰©å…… i 节点。删除一些无用的和过期的文件æ¥é‡Šæ”¾ä¸€äº› i 节点å§ã€‚ + +### çŽ¯å— + +without 一个很常è§çš„问题就是å的文件系统å—。除éžå¦æœ‰æ ‡è®°ï¼Œå¦åˆ™æ“作系统很å¯èƒ½ä¼šè®¤ä¸ºè¿™äº›å—都是å¯ç”¨çš„,这会导致文件系统æŸå或者硬盘å死。最好是使用带 `-cc` 标志的 `fsck` æœç´¢å¹¶æ ‡è®°å‡ºè¿™äº›å—。记ä½ï¼Œä½ ä¸èƒ½ä½¿ç”¨æ­£åœ¨æµ‹è¯•çš„文件系统 (LCTT 注:å³åŒ…å«åå—的文件系统)中的 `fsck`。你应该会è¦ç”¨åˆ° live CD。 +``` +sudo fsck -vcck /dev/sda2 +``` + +很明显,这里需è¦ä½¿ç”¨ä½ æƒ³æ£€æŸ¥çš„ç£ç›˜è·¯å¾„å–代命令中的ç£ç›˜ä½ç½®ã€‚å¦å¤–,è¦æ³¨æ„,这æ怕会花上很长一段时间。 + + **相关**:[使用 fsck 检查并修å¤ä½ çš„文件系统 [Linux]][6] + +希望这些方案能解决你的问题。这ç§é—®é¢˜åœ¨ä»»ä½•æƒ…况下都ä¸æ˜¯é‚£ä¹ˆå®¹æ˜“诊断的。但是,在è¿æ°”好的情况下,你å¯ä»¥æŠŠæ–‡ä»¶ç³»ç»Ÿæ¸…ç†å¹²å‡€å¹¶è®©ä½ çš„硬盘å†æ¬¡æ­£å¸¸å·¥ä½œã€‚ + +-------------------------------------------------------------------------------- + +via: https://www.maketecheasier.com/fix-linux-no-space-left-on-device-error/ + +作者:[Nick Congleton][a] +译者:[lujun9972](https://github.com/lujun9972) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) è£èª‰æŽ¨å‡º + +[a]:https://www.maketecheasier.com/author/nickcongleton/ +[1]:https://www.maketecheasier.com/assets/uploads/2017/10/no-space-du.jpg (Linux Filesystem du) +[2]:https://www.maketecheasier.com/assets/uploads/2017/10/no-space-df.jpg (Linux Filesystem df) +[3]:https://www.maketecheasier.com/agedu-analyze-hard-disk-space-usage-in-linux/ (Use Agedu to Analyze Hard Disk Space Usage in Linux) +[4]:https://www.maketecheasier.com/assets/uploads/2017/10/no-space-process.jpg (Check processes for deleted files) +[5]:https://www.maketecheasier.com/assets/uploads/2017/10/no-space-inode.jpg (Linux check filesystem inodes) +[6]:https://www.maketecheasier.com/check-repair-filesystem-fsck-linux/ (Check and Repair Your Filesystem With fsck [Linux])