天天看點

linux 顯示系統空間不足,linux下boot空間不足解決方法

在安裝linux的過程中都喜歡把boot挂單獨挂分區,一般設定500M,

可随着linux更新,往往會攢下好幾個核心,某一天系統會提示你更新失敗,空間不足了。。。

既然已經知道是boot空間不足了,那首先我們看看裡面都有神馬東西!!

[email protected]:~$ ls /boot

abi-2.6.35-25-generic memtest86+.bin

abi-2.6.35-27-generic memtest86+_multiboot.bin

abi-2.6.35-28-generic System.map-2.6.35-25-generic

config-2.6.35-25-generic System.map-2.6.35-27-generic

config-2.6.35-27-generic System.map-2.6.35-28-generic

config-2.6.35-28-generic vmcoreinfo-2.6.35-25-generic

grub vmcoreinfo-2.6.35-27-generic

initrd.img-2.6.35-25-generic vmcoreinfo-2.6.35-28-generic

initrd.img-2.6.35-27-generic vmlinuz-2.6.35-25-generic

initrd.img-2.6.35-28-generic vmlinuz-2.6.35-27-generic

lost+found vmlinuz-2.6.35-28-generic

我們可以看到都是一些核心啟動檔案,很明顯有些是我們不需要的,其實以上都還是我已經解除安裝了倆比較老的核心的情況了,沒商量,不需要的就當垃圾處理掉。

首先請用uname -a看下自己目前啟動的是哪個核心。

[email protected]:~$ uname -a

Linux expired 2.6.35-28-generic #49-Ubuntu SMP Tue Mar 1 14:39:03 UTC 2011 x86_64 GNU/Linux

從中可以看到我此刻啟動的是2.6.35-28-generic,再用dpkg指令看下你的機器上都有哪些核心檔案。

[email protected]:~$ dpkg -get-selections |grep linux-image

linux-image-2.6.35-22-generic deinstall

linux-image-2.6.35-24-generic deinstall

linux-image-2.6.35-25-generic install

linux-image-2.6.35-27-generic install

linux-image-2.6.35-28-generic install

linux-image-generic install

不少,理論上除正在用的都可以删除,但剛更新的東西可能不穩定,為保險起見,保留1-2個之前版本吧。

運作apt-get remove指令解除安裝不需要的核心。

[email protected]:~$ sudo apt-get remove linux-image-2.6.35-25-generic

The following packages will be REMOVED:

linux-image-2.6.35-25-generic

0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.

After this operation, 139MB disk space will be freed.

Do you want to continue [Y/n]? y

出現以上提示問是否繼續,按y或者直接回車繼續。完成後會有如下提示:

DKMS: uninstall Completed.

Examining /etc/kernel/postrm.d .

run-parts: executing /etc/kernel/postrm.d/initramfs-tools 2.6.35-25-generic /boot/vmlinuz-2.6.35-25-generic

run-parts: executing /etc/kernel/postrm.d/zz-update-grub 2.6.35-25-generic /boot/vmlinuz-2.6.35-25-generic

Generating grub.cfg …

Found linux image: /boot/vmlinuz-2.6.35-28-generic

Found initrd image: /boot/initrd.img-2.6.35-28-generic

Found linux image: /boot/vmlinuz-2.6.35-27-generic

Found initrd image: /boot/initrd.img-2.6.35-27-generic

Found memtest86+ image: /memtest86+.bin

Found Windows 7 (loader) on /dev/sda1

Found Windows Vista (loader) on /dev/sda4

done

現在的ubuntu會自動重建啟動菜單grub.cfg,是以就一步到位了。解除安裝完後可以用df指令看下boot分區的空間使用情況。

[email protected]:~$ df

Filesystem 1K-blocks Used Available Use% Mounted on

/dev/sda9 19223252 9429624 8817144 52% /

/dev/sda7 93207 53279 35116 61% /boot

ok,已經騰出35m空間了,現在可以運作sudo apt-get upgrade更新了。

再用dpkg看下還剩什麼東西。

[email protected]:~$ dpkg -get-selections | grep linux-image

linux-image-2.6.35-25-generic deinstall

linux-image-2.6.35-27-generic install

linux-image-2.6.35-28-generic install

linux-image-generic install

linux-image-2.6.35-25-generic 顯示deinstall,表示已經删除,也許你覺得留着這個也不好看,那就重新開機後再運作一次解除安裝指令就可以了:

[email protected]:~$apt-get remove linux-image-2.6.35-25-generic