欢迎光临
我们一直在努力

解决Ubuntu 提示boot分区空间不足办法

首先请用uname -a看下自己当前启动的是哪个内核。

~$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命令看下你的机器上都有哪些内核文件。

~$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命令卸载不需要的内核。

~$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分区的空间使用情况。

~$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看下还剩什么东西。

~$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  //表示已经删除,也许你觉得留着这个也不好看,那就试试下面的命令:
~$sudodpkg-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这个参数一步到位地卸载,即:

~$sudoapt-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

再次看下运行后的结果

~$dpkg--get-selections|grep linux-image

linux-image-3.2.0-32-generic install
linux-image-generic install
~$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,刚才的残留已经删除了。

赞(0) 打赏
未经允许不得转载:NixonLi博客 » 解决Ubuntu 提示boot分区空间不足办法

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏