`

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

阅读更多

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 

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

分享到:
评论

相关推荐

    Ubuntu10.04编译内核时所需要的软件包

    7. **清理旧内核**:在编译完成后,旧内核可能需要被清理以释放磁盘空间,`purge-old-kernels`脚本可以帮助完成这个任务,但首先需要`dpkg`和`perl`。 8. **调试工具**:如果计划对内核进行调试,`kgdb`和`kernel-...

    ubuntu_unused_kernels

    识别可以从 Ubuntu 机器中删除的旧内核包。 它将忽略当前正在运行的内核以及在机器重新启动时将使用的最新内核。 安装 将此行添加到应用程序的 Gemfile 中: gem 'ubuntu_unused_kernels' 然后执行: $ bundle ...

    ubuntu下的ltsp配置

    ### Ubuntu下的LTSP配置 #### 一、简介 LTSP(Linux Terminal Server Project)是一种将计算机作为终端使用的技术,能够使这些终端通过网络访问运行在服务器上的Linux桌面环境。这通常用于构建无盘工作站网络,即...

    learning with kernels

    In the 1990s, a new type of learning algorithm was developed, based on results from statistical learning theory: the Support Vector Machine (SVM). This gave rise to a new class of theoretically ...

    Anykernel和Rump内核的设计和实现,第二版The Design and Implementation of the Anykernel and Rump Kernels, 2nd Edition

    - **安全可靠**:Anykernel确保了内核更新过程中数据的安全性,减少了因手动操作失误导致的风险。 #### 四、Rump Kernel的关键技术 ##### 4.1 设计理念 Rump Kernel的设计重点在于提供一个高度可配置和可扩展的...

    Fast Interrupt Priority Management in OS Kernels

    Fast Interrupt Priority Management in OS Kernels

    How to Port a Driver from 2.4 to 2.6 Kernels

    本文档详细介绍了如何将旧版驱动程序从Linux 2.4内核移植到2.6内核,并尝试将其合并到上游/mainline内核中的过程。作者Mark Gross根据自身经验,提供了一个简单的示例,即从2.4到2.6内核的移植过程,以及最终如何...

    Python库 | cpm_kernels-1.0.0a15-py3-none-any.whl

    `cpm_kernels-1.0.0a15-py3-none-any.whl` 是一个针对Python开发的库,名为 `cpm_kernels` 的特定版本,版本号为 `1.0.0a15`。这个文件是用Python 3编写的,因为文件名中的 `py3` 表明它是兼容Python 3.x版本的。`...

    PyPI 官网下载 | spyder-kernels-1.9.4.tar.gz

    **PyPI 官网下载 | spyder-kernels-1.9.4.tar.gz** `PyPI`(Python Package Index)是Python社区中最主要的软件包仓库,它为开发者提供了发布和下载Python模块的地方。资源`spyder-kernels-1.9.4.tar.gz`是从PyPI...

    Kernels for Vector-Valued Functions A Review

    Kernel methods are among the most popular techniques in machine learning. From a regularization perspec- tive they play a central role in regularization theory as they provide a natural choice for the...

    An Introduction to Laplacian Spectral Distances and Kernels

    In geometry processing and shape analysis, several applications have been addressed through the properties of the Laplacian spectral kernels and distances, such as commute time, biharmonic, diffusion,...

    Haswell-10.10.3 XCPM防重启Kernels

    标题中的“Haswell-10.10.3 XCPM防重启Kernels”指的是针对Intel Haswell架构处理器的特定版本苹果操作系统(Mac OS X)内核补丁,旨在解决在10.10.3(Yosemite)系统升级或安装过程中可能出现的无限重启问题。...

    optimization on submanifolds of convolution kernels in cnns--2016.pdf

    本文标题为“在卷积神经网络中的卷积核子流形上的优化”,发表于2016年,作者为Mete Ozay和Takayuki Okatani,来自日本东北大学信息科学研究生院。文档讨论了如何在卷积神经网络(CNNs)中通过卷积核的子流形进行...

    Learning with Kernels

    《Learning with Kernels》这本书是人工智能领域的一部经典著作,主要涵盖了支持向量机(Support Vector Machines, SVMs)、正则化(Regularization)以及优化(Optimization)等多个关键主题。这些知识点在现代机器...

    Supervised Hashing with Kernels

    在《Supervised Hashing with Kernels》这篇发表于2012年计算机视觉与模式识别会议(CVPR2012)的文章中,作者提出了一种新颖的基于核函数(kernel-based)的监督式哈希模型。 这种模型的独特之处在于它仅需要有限...

    kernels-service:通过 HTTP 启动 Jupyter 内核

    直接发射kernels.py 启动一个 Tornado Web 服务器,它启动单个内核并提供启动更多内核的能力。 在这里,我们将 IPython API 的基本路径设置为从/jupyter/开始: $ python kernels.py --base-path=jupyter[I 150113 ...

    Supervised Hashing with Kernels 代码

    Supervised Hashing with Kernels CVPR2012 作者的源代码

    Python库 | spyder-kernels-2.0.3.tar.gz

    资源分类:Python库 所属语言:Python 资源全名:spyder-kernels-2.0.3.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059

Global site tag (gtag.js) - Google Analytics