I've written a new post that shows a bash one-liner command that will remove the old kernels from your system in one step. You can check it out here .
我写了一篇文章,显示一个一行的bash命令,教你用一步删除您系统旧的内核。你可以看看这里 。

If you've been using Ubuntu Linux for a while, then you probably have a number of Linux kernel updates that have been installed on your system. (I've got a total of 3 kernels in my Karmic system already.) In all likelihood, these updates get installed and you boot into the latest kernel, never to use the older kernels again. But these old kernels are still hanging around on your system, cluttering up your grub boot screen and taking up space on your hard drive. 
如果你已经使用了一段时间的Ubuntu Linux,那么您可能有在更新的时候在你的系统上安装了好几个Linux内核里(在我的Karmic版本我都有总共三个内核版本了)。有很大的可能性, 这些更新的Linux版内核自从安装到你的电脑上,你永远不会再用旧的内核了。但是这些旧内核仍然徘徊在你的系统,搞乱你的grub开机画面并且占用了您 的硬盘驱动器空间。

There have been attempts made to create an automatic tool to clean these up for you along with much discussion on the Ubuntu Forums , but so far there's nothing officially in the repositories.
目前在Ubuntu论坛大量讨论尝试制作一个自动的工具来清洁这些,但至今还没有什么正式的仓库。

In the past, I've gone into Synaptic and searched for the older kernels and related packages and manually marked them for removal. This method works fine, but the search process is a little slow in Synaptic and you have to run a few searches to catch all of the packages to remove. I decided to come up with a way to do this from the terminal and hopefully save some time. The commands I'm going to use can be a bit daunting, so just copy and paste.
在过去,我总是进入新立得搜索和手动标记为删除旧的内核和相关的包。此方法效果很好,但是搜索过程是一个漫长的过程,你必须运行少量搜索,捕捉所有的软件 包删除。我决定想出一个办法做到这一点,希望节省一些时间。我使用的这些令可能会有点吓人,所以只要复制并粘贴就可以了。

Warning

Don't follow this process unless you're sure you don't need to boot into the older kernels. If you're not sure, just leave things alone. Also, it is possible to remove all of the kernels from your system and make it unbootable. I suggest leaving the latest kernel and one version previous to that. You can find out the kernel version that you're currently running with
除非你确定你不需要到老内核启动,否则别这样做。如果你不太确定,最好也别接下来的操作。此外,它可以从系统中删除所有的内核,使之无法启动。我强烈建议你保留最新版本的内核和一个最新的版本的前一个版本。你可以通过下边的命令找到你电脑上的内核的版本信息

uname -r

Find and remove old kernels

The first step is to figure out what kernels are installed. The following command will do the job.

第一步是配置出什么内核需要安装,运行下边的命令

ls /boot | grep vmlinuz | cut -d'-' -f2,3

Your result should look something like this.

运行之后你的结果可能是这样的

2.6.28-15
2.6.28-16
2.6.28-17

This is the list of kernels installed on your system. Now you want to find out which packages are installed relative to the kernel you want to remove. For my example I'm going to remove the oldest one, 2.6.28-15.

这个列表列出的是你的系统中安装的内横,现在你就应该找到你想删除的内核的关联包了,例如我想删除最老的版本2.6.28-15。

dpkg -l | grep ^ii | grep 2.6.28-15 | awk -F' ' '{ print $2 }'

On my system, (Jaunty) the resulting list is:

在我的系统上,出现这样的结果

linux-headers-2.6.28-15
linux-headers-2.6.28-15-generic
linux-image-2.6.28-15-gener
linux-restricted-modules-2.6.28-15-generic

Now that we know what packages to remove we can remove them with dpkg, apt-get or aptitude.

现在我们知道我们要上出的包了,并且用命令dpkg,apt-get或者aptitude。

sudo aptitude remove linux-headers-2.6.28-15 linux-headers-2.6.28-15-generic linux-image-2.6.28-15-generic linux-restricted-modules-2.6.28-15-generic

That's it. You've removed an old kernel and related packages. Now you can keep your system as clean as it is right after you install Ubuntu. The commands are a bit complex, so maybe I'll write up a bash script when I have some time. Proceed with caution!

就是这样的,你已经删除里老的内核还有关联的包资源了,现在你就可以保持 你的 干净的系统 ,因为它是 你 安装唯一的Ubuntu 。 该 命令是 有点复杂 , 所以如果 我有 时间 也许 我会写 了一个 bash脚本 时 。 谨慎行事 !

下边是我删除内核的shell文字

txlong@txlong-K40AB:~$ sudo -s
[sudo] password for txlong:
root@txlong-K40AB:~# aptitude remove linux-image-2.6.35-22-generic
下列软件包将被“删除”:           linux-image-2.6.35-22-generic
0 个软件包被升级,新安装 0 个, 1 个将被删除, 同时 0 个将不升级。
需要获取 0B 的存档。 解包后将释放 107MB。
(正在读取数据库 ... 系统当前共安装有 129056 个文件和目录。)
正在卸载 linux-image-2.6.35-22-generic ...
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-28-generic
Found initrd image: /boot/initrd.img-2.6.35-28-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Windows 7 (loader) on /dev/sda2
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]root@txlong-K40AB:~# 

使用Ubuntu一段时间后,就会发觉由于自动升级,系统里安装了很多内核。
像我,竟然安装了下面那么多,这个造成了漫长的启动列表。必须删掉一些不用的。

首先就是使用如下命令,列出所有安装的内核,下表中,带有image的就是内核文件。
从中选择要卸载的包,用apt-get来卸载

[tc@ibm:~]$ dpkg --get-selections|grep linux
libselinux1 install
linux-386 install
linux-image-2.6.15-23-386 install
linux-image-2.6.15-27-386 install
linux-image-2.6.15-27-686 install
linux-image-2.6.15-28-386 install
linux-image-2.6.15-28-686 deinstall
linux-image-386 install
linux-kernel-headers install
linux-restricted-modules-2.6.15-23-386 install
linux-restricted-modules-2.6.15-27-386 install
linux-restricted-modules-2.6.15-27-686 install
linux-restricted-modules-2.6.15-28-386 install
linux-restricted-modules-2.6.15-28-686 deinstall
linux-restricted-modules-386 install
linux-restricted-modules-common install
linux-sound-base install
util-linux install 

具体的卸载方法为

sudo apt-get remove linux-image-2.6.15-23-386 

这样就可以实现自动删除内核文件了,还可以释放磁盘空间。

另外还要记录一个命令。

uname -a

使用这个命令可以查看当前系统使用的内核。

【译】Remove Old Kernels in Ubuntu手动删除Ubuntu旧的内核相关推荐

  1. 双系统gpt卸载linux,UEFI双系统下手动删除Ubuntu引导

    准备换电脑,把手上这台给我爸玩了,然后想着把Ubuntu删除掉只留个windows.删除双系统里的ubuntu,肯定要先解决引导的问题,然后再在磁盘管理里删除该系统所在卷了,但是操作过程中发现我的ub ...

  2. 双系统(xp+ubuntu)删除ubuntu(好用)

    我的电脑安装了双系统,Windows和Linux,不过由于Linux在最近一段时间内不会使用,所以我打算删除Linux.    删除Linux最需要注意的地方,就是MBR(Master Boot Re ...

  3. Ubuntu手动删除mysql,再重新使用apt-get安装

    由于在阿里云上自己安装的mysql被攻击并勒索,作为新时代的技术人员,我怎么可能妥协付款,所以忍痛直接重新安装mysql mysql> mysql> select * from READM ...

  4. Ubuntu: 删除ubuntu桌面的两个图标

    1. 安装ubuntu桌面配置优化工具 gnome-tweaks sudo apt-get install gnome-tweaks 2. 安装完成后按Alt + F2 打开命令终端 输入gnome- ...

  5. 清理 linux 内核版本,grub2 - 如何删除旧的内核版本以清理引导菜单? - Ubuntu问答...

    问题描述 每次安装新的Linux内核时,它都会留在grub_config中,从而使引导菜单每次都更长. 我知道我可以手动搜索已安装的软件包并将其删除. Ubuntu是否提供任何更简便的方法来清理它们或 ...

  6. 【Linux】删除旧版本内核

    需求介绍 在用Fedora, 小版本更新的很快, 可能一个月就能在引导里面看到四五个启动项, 这个时候就需要手动删除一下旧版本的kernel. 每次删除都靠百度, 死活记不下来, 这次自己动手总结一下 ...

  7. 在Win10删除Ubuntu时直接删除分区后,如何删除启动项(EFI)

    亲测可用 [[一开始我是按照网上教程先在第二个盘压缩个分区来装,此时我的第二个盘不是GPT格式,不知道后来进不去ubuntu是不是与这个有关,装完后发现第二个磁盘有ubuntu的引导项,可是进不去:我 ...

  8. 删除Ubuntu旧内核的几种方法,这下grub菜单看起来清爽多了!

    方法一: 使用Ubuntu一段时间后,就会发觉由于自动升级,系统里安装了很多内核.像我,竟然安装了下面那么多,这个造成了漫长的启动列表.必须删掉一些不用的. 首先就是使用如下命令,列出所有安装的内核, ...

  9. win10+ubuntu双系统之三步彻底删除ubuntu系统

    电脑型号:联想小新pro13 一.把开机启动项设为默认Windows启动 按F2进入BIOS界面. 进入[BOOT]选项.调整Ubuntu和win10选项的前后顺序. 二.使用磁盘管理软件 DiskG ...

最新文章

  1. 禅道项目管理软件介绍
  2. werkzeug源码阅读笔记(二) 下
  3. 【Codeforces Round #430 (Div. 2) D】Vitya and Strange Lesson
  4. Toolbar+DrawerLayout
  5. 全国计算机一级d类考试内容,全国计算机一级考试WPS office复习题及答案2017
  6. 你是不是在混日子,看着一点就知道了
  7. jQuery编程规范与最佳实践(附带一些个人的笔记)
  8. fastscript传递参数
  9. Nginx 限制单个IP的并发连接数及对每个连接速度(限速)
  10. 谈对阿里应用分层的思考
  11. 如何修改maven默认仓库(即repository)的路径
  12. 解码H264帧要注意的两个问题
  13. fiddler的设置与简单使用
  14. Unity 如何实现批量修改图片格式
  15. Android 系统源码——下载到编译
  16. 一文彻底搞懂Mybatis系列(二)之mybatis事务管理机制深度剖析
  17. Excel 6位数字与MD5对照表 100000-999999
  18. 高德地图api接口免费查询天气实战案例,axios请求查询天气,js版,【接上一篇微信测试号推送纪念日】
  19. linux下磁盘情况查询命令
  20. 手把手教你解决宏基笔记本wifi开关故障(超详细)

热门文章

  1. PS切图和标注的一些效率工具
  2. “Google 软件开发代理商计划” 中国地区正式开启报名
  3. 函数论_E.C.Tichmarsh_Page 4 例题 iii 狄利克雷级数一致收敛
  4. sqlite的缺点和限制
  5. eja变送器故障代码al01_横河eja变送器常见故障_横河eja故障解答
  6. 集合元素为什么不能是可变数据类型
  7. 天空卫士入选2021德勤·亦庄明日之星
  8. sqlserver数据库不离线清空ldf日志
  9. 三年级计算机绘画第二课堂教案,美术第二课堂活动的总结.docx
  10. 以太宇宙(ETU)可能颠覆OK、火币、币安现有格局,降维打击!