不少同窗都是在本身的機器上安裝雙系統,也就是說用來裝linux的空間不會不少。在裝的過程當中都喜歡把boot掛單獨掛分區,通常設置100M, linux
可隨着linux升級,每每會攢下好幾個內核,某一天系統會提示你升級失敗,空間不足了。。。 數據庫
更改boot分區大大小不曉得可不能夠作到,貌似linux下尚未無損分區的概念。 ubuntu
既然已經知道是boot空間不足了,那首先咱們看看裏面都有神馬東西!! post
expired@expired:~$ ls /boot ui
abi-2.6.35-25-generic memtest86+.bin this
abi-2.6.35-27-generic memtest86+_multiboot.bin spa
abi-2.6.35-28-generic System.map-2.6.35-25-generic orm
config-2.6.35-25-generic System.map-2.6.35-27-generic rem
config-2.6.35-27-generic System.map-2.6.35-28-generic get
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看下本身當前啓動的是哪一個內核。
expired@expired:~$ 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命令看下你的機器上都有哪些內核文件。
expired@expired:~$ 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命令卸載不須要的內核。
expired@expired:~$ 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分區的空間使用狀況。
expired@expired:~$ 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看下還剩什麼東西。
expired@expired:~$ 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,表示已經刪除,也許你以爲留着這個也很差看,那就試試下面的命令:
expired@expired:~$sudo dpkg -P linux-image-2.6.35-25-generic
(Reading database ... 286964 files and directories currently installed.)
Removing linux-image-2.6.35-25-generic ...
Purging configuration files for linux-image-2.6.35-25-generic ...
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
呵呵,其實打一開始就能夠用purge這個參數一步到位地卸載,即:
expired@expired:~$sudo apt-get purge linux-image-3.2.0-26-generic
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
linux-image-3.2.0-26-generic*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 0 B of additional disk space will be used.
Do you want to continue [Y/n]? y
(Reading database ... 286964 files and directories currently installed.)
Removing linux-image-3.2.0-26-generic ...
Purging configuration files for linux-image-3.2.0-26-generic ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 3.2.0-26-generic /boot/vmlinuz-3.2.0-26-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 3.2.0-26-generic /boot/vmlinuz-3.2.0-26-generic
由於以前已經remove過了,因此只留下個配置在數據庫記錄中,再purge時無空間釋放。
0 B of additional disk space will be used
再次看下運行後的結果
expired@expired:~$ dpkg --get-selections | grep linux-image
linux-image-3.2.0-32-generic install
linux-image-generic install
expired@expired:~$ dpkg -l | grep linux-image
ii linux-image-3.2.0-32-generic 3.2.0-32.51 Linux kernel image for version 3.2.0 on 64 bit x86 SMP
ii linux-image-generic 3.2.0.32.35 Generic Linux kernel image
ok,剛纔的殘留已經刪除了。