天天看點

linux no space left on device 錯誤解決方法

今天在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

指令檢視目前檔案系統信系,顯示如下:

linux no space left on device 錯誤解決方法
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%,但執行步驟相同)

linux no space left on device 錯誤解決方法

執行完以上兩條指令後,就好列印出根目錄下個各個子目錄檔案大小。目前是home最大 達到5.1G .

我們可以使用同樣的指令分析/home目錄下的檔案大小。遇到無用的檔案,使用rm指令删除,次後再用

df

指令分析檔案系統,即可解決問題。

好了,以上就是我在linux系統下遇到

no space left on device

錯誤提示的解決步驟了。希望大家linux玩耍愉快!!!

繼續閱讀