`
lucane
  • 浏览: 119138 次
  • 性别: Icon_minigender_1
  • 来自: 江湖
社区版块
存档分类
最新评论

删除Ubuntu旧版本内核

阅读更多
我也是在网上看了很多帖子才动手的,我的Ubuntu是10.10
觉得Ubuntu还是太脆弱,稍微胡整一下就葛屁了,虽然可以修复过来,但还是比较麻烦

下面就是我的记录
参见了:http://hi.baidu.com/luoziding/blog/item/7e293daa367299a1ca130c6c.html
http://www.linuxjia.com/banben/ubuntu/2010/1223/288.html

lucane@KNIGHT:~$ dpkg --get-selections|grep linux-image
linux-image-2.6.35-22-generic install
linux-image-2.6.35-23-generic install
linux-image-generic install

目前我在用的内核是
lucane@KNIGHT:~$ uname -a
Linux KNIGHT 2.6.35-23-generic #41-Ubuntu SMP Wed Nov 24 10:18:49 UTC 2010 i686 GNU/Linux


所以要把22版本的搞掉
$sudo apt-get remove linux-image-2.6.35-22-generic

实际上执行完这个之后,启动引导菜单已经自动帮我们修改好了,详见后面日志

重启之后外带执行这个,虽然我不知道是干啥的
$sudo apt-get remove linux-headers-2.6.35-22-generic

删完之后22内核已经处于deinstall状态,如下:
lucane@KNIGHT:~$ dpkg --get-selections|grep linux-
linux-firmware install
linux-generic install
linux-headers-2.6.35-22 install
linux-headers-2.6.35-23 install
linux-headers-2.6.35-23-generic install
linux-headers-generic install
linux-image-2.6.35-22-generic deinstall
linux-image-2.6.35-23-generic install
linux-image-generic install
linux-libc-dev install
linux-sound-base install
syslinux-common install

看看执行时生成的日志文件,就可以了解哪些工作是要我们手工做,哪些工作已经是自动完成了的

发现删除完了之后右上角关机那个小按钮消失了。只需要点『添加到面板』就可以把这些小程序找出来
当我再次重启发现,这些又恢复了,我只好把我加上去的又删掉



下面的这是在网上看别人写的东西,以及参看官方文档得出的东西,记录在这里准备用的,结果都没用到

最后修改引导启动菜单
sudo gedit /boot/grub/menu.lst

这个文件实际上在10之前已经修改为grub.cfg了,网上有一部分人还是写的这个文件,但是确实已经改了,到目录下看看就知道了
我打开这个文件的时候sudo gedit /boot/grub/menu.lst,是系统新建的一个文件,里面是空的

下面这个才是有内容的,参见https://help.ubuntu.com/community/Grub2
sudo gedit /boot/grub/grub.cfg

该文件上面有一行
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

足可以表明该文件不用手动改,可以通过某个工具生成,当然估计也可以手动改

官方文档上有一句
“grub.cfg is overwritten anytime there is an update, a kernel is added/removed, or the user runs update-grub.”

既然我手动删除了内核,那么系统应该自动会更改这个文件的内容,最坏的情况是我手动执行这个命令$sudo update-grub,让它去更改那个文件

等执行update-grub让他自动生成看有没有什么变化

或者自己手动改grub.cfg
打开,然后删除不要的内核的那两段就OK了
当然修改之前先cp备份一个出来,更保险

-----------------------我是华丽的分割线-----------------------

下面是执行日志

lucane@KNIGHT:~$ sudo apt-get remove linux-image-2.6.35-22-generic
正在读取软件包列表... 完成
正在分析软件包的依赖关系树      
正在读取状态信息... 完成      
下列软件包将被【卸载】:
  linux-image-2.6.35-22-generic
升级了 0 个软件包,新安装了 0 个软件包,要卸载 1 个软件包,有 0 个软件包未被升级。
解压缩后将会空出 107MB 的空间。
您希望继续执行吗?[Y/n]y
(正在读取数据库 ... 系统当前共安装有 150779 个文件和目录。)
正在卸载 linux-image-2.6.35-22-generic ...
Examining /etc/kernel/prerm.d.
run-parts: executing /etc/kernel/prerm.d/dkms 2.6.35-22-generic /boot/vmlinuz-2.6.35-22-generic
dkms: uninstalling: fglrx 8.780 (2.6.35-22-generic) (i686)

-------- Uninstall Beginning --------
Module:  fglrx
Version: 8.780
Kernel:  2.6.35-22-generic (i686)
-------------------------------------

Status: Before uninstall, this module version was ACTIVE on this kernel.

fglrx.ko:
- Uninstallation
   - Deleting from: /lib/modules/2.6.35-22-generic/updates/dkms/
- Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.
depmod.......

DKMS: uninstall Completed.
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 2.6.35-22-generic /boot/vmlinuz-2.6.35-22-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 2.6.35-22-generic /boot/vmlinuz-2.6.35-22-generic
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.35-23-generic
Found initrd image: /boot/initrd.img-2.6.35-23-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Microsoft Windows XP on /dev/sda1
done
The link /vmlinuz.old is a damaged link
Removing symbolic link vmlinuz.old
you may need to re-run your boot loader[grub]
The link /initrd.img.old is a damaged link
Removing symbolic link initrd.img.old
you may need to re-run your boot loader[grub]



lucane@KNIGHT:~$ sudo apt-get remove linux-headers-2.6.35-22-generic
[sudo] password for guohai:
正在读取软件包列表... 完成
正在分析软件包的依赖关系树      
正在读取状态信息... 完成      
下列软件包将被【卸载】:
  linux-headers-2.6.35-22-generic
升级了 0 个软件包,新安装了 0 个软件包,要卸载 1 个软件包,有 0 个软件包未被升级。
解压缩后将会空出 10.0MB 的空间。
您希望继续执行吗?[Y/n]y
(正在读取数据库 ... 系统当前共安装有 146974 个文件和目录。)
正在卸载 linux-headers-2.6.35-22-generic ...


附件是原始的一个grub.cfg和删除旧版内核后自动生成的一个grub.cfg
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics