mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-26 21:30:55 +08:00
commit
05e6e49542
@ -1,70 +0,0 @@
|
||||
translating----geekpi
|
||||
|
||||
Linux FAQs with Answers--How to remove unused old kernel images on Ubuntu
|
||||
================================================================================
|
||||
> **Question**: I have upgraded the kernel on my Ubuntu many times in the past. Now I would like to uninstall unused old kernel images to save some disk space. What is the easiest way to uninstall earlier versions of the Linux kernel on Ubuntu?
|
||||
|
||||
In Ubuntu environment, there are several ways for the kernel to get upgraded. On Ubuntu desktop, Software Updater allows you to check for and update to the latest kernel on a daily basis. On Ubuntu server, the unattended-upgrades package takes care of upgrading the kernel automatically as part of important security updates. Otherwise, you can manually upgrade the kernel using apt-get or aptitude command.
|
||||
|
||||
Over time, this ongoing kernel upgrade will leave you with a number of unused old kernel images accumulated on your system, wasting disk space. Each kernel image and associated modules/header files occupy 200-400MB of disk space, and so wasted space from unused kernel images will quickly add up.
|
||||
|
||||
![](https://farm1.staticflickr.com/636/21352725115_29ae7aab5f_c.jpg)
|
||||
|
||||
GRUB boot manager maintains GRUB entries for each old kernel, in case you want to boot into it.
|
||||
|
||||
![](https://farm6.staticflickr.com/5803/21164866468_07760fc23c_z.jpg)
|
||||
|
||||
As part of disk cleaning, you can consider removing old kernel images if you haven't used them for a while.
|
||||
|
||||
### How to Clean up Old Kernel Images ###
|
||||
|
||||
Before you remove old kernel images, remember that it is recommended to keep at least two kernel images (the latest one and an extra older version), in case the primary one goes wrong. That said, let's see how to uninstall old kernel images on Ubuntu platform.
|
||||
|
||||
In Ubuntu, kernel images consist of the following packages.
|
||||
|
||||
- **linux-image-<VERSION-NUMBER>**: kernel image
|
||||
- **linux-image-extra-<VERSION-NUMBER>**: extra kernel modules
|
||||
- **linux-headers-<VERSION-NUMBER>**: kernel header files
|
||||
|
||||
First, check what kernel image(s) are installed on your system.
|
||||
|
||||
$ dpkg --list | grep linux-image
|
||||
$ dpkg --list | grep linux-headers
|
||||
|
||||
Among the listed kernel images, you can remove a particular version (e.g., 3.19.0-15) as follows.
|
||||
|
||||
$ sudo apt-get purge linux-image-3.19.0-15
|
||||
$ sudo apt-get purge linux-headers-3.19.0-15
|
||||
|
||||
The above commands will remove the kernel image, and its associated kernel modules and header files.
|
||||
|
||||
Note that removing an old kernel will automatically trigger the installation of the latest Linux kernel image if you haven't upgraded to it yet. Also, after the old kernel is removed, GRUB configuration will automatically be updated to remove the corresponding GRUB entry from GRUB menu.
|
||||
|
||||
If you have many unused kernels, you can remove multiple of them in one shot using the following shell expansion syntax. Note that this brace expansion will work only for bash or any compatible shells.
|
||||
|
||||
$ sudo apt-get purge linux-image-3.19.0-{18,20,21,25}
|
||||
$ sudo apt-get purge linux-headers-3.19.0-{18,20,21,25}
|
||||
|
||||
![](https://farm6.staticflickr.com/5619/21352725355_39cc4fc2d0_c.jpg)
|
||||
|
||||
The above command will remove 4 kernel images: 3.19.0-18, 3.19.0-20, 3.19.0-21 and 3.19.0-25.
|
||||
|
||||
If GRUB configuration is not properly updated for whatever reason after old kernels are removed, you can try to update GRUB configuration manually with update-grub2 command.
|
||||
|
||||
$ sudo update-grub2
|
||||
|
||||
Now reboot and verify that your GRUB menu has been properly cleaned up.
|
||||
|
||||
![](https://farm1.staticflickr.com/593/20731623163_cccfeac854_z.jpg)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://ask.xmodulo.com/remove-kernel-images-ubuntu.html
|
||||
|
||||
作者:[Dan Nanni][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://ask.xmodulo.com/author/nanni
|
@ -0,0 +1,69 @@
|
||||
Linux有问必答--如何删除Ubuntu上不再使用的老内核
|
||||
================================================================================
|
||||
> **提问**:过去我已经在我的Ubuntu上升级了几次内核。现在我想要删除这些旧的内核镜像来节省我的磁盘空间。如何用最简单的方法删除Ubuntu上先前版本的内核?
|
||||
|
||||
在Ubuntu上,有几个方法来升级内核。在Ubuntu桌面中,软件更新允许你每天检查并更新到最新的内核上。在Ubuntu服务器上,一个无人值守的包会自动更新内核最为一项最要的安全更新。然而,你可以手动用apt-get或者aptitude命令来更新。
|
||||
|
||||
随着时间的流逝,持续的内核更新会在系统中积聚大量的不再使用的内核,浪费你的磁盘空间。每个内核镜像和其相关联的模块/头文件会占用200-400MB的磁盘空间,因此由不再使用的内核而浪费的磁盘空间会快速地增加。
|
||||
|
||||
![](https://farm1.staticflickr.com/636/21352725115_29ae7aab5f_c.jpg)
|
||||
|
||||
GRUB管理器为每个旧内核都维护了一个GRUB入口,防止你想要进入它们。
|
||||
|
||||
![](https://farm6.staticflickr.com/5803/21164866468_07760fc23c_z.jpg)
|
||||
|
||||
作为磁盘清理的一部分,如果你不再使用这些,你可以考虑清理掉这些镜像。
|
||||
|
||||
### 如何清理旧内核镜像 ###
|
||||
|
||||
在删除旧内核之前,记住最好留有2个最近的内核(最新的和上一个版本),以防主要的版本出错。现在就让我们看看如何在Ubuntu上清理旧内核。
|
||||
|
||||
在Ubuntu内核镜像包哈了以下的包。
|
||||
|
||||
- **linux-image-<VERSION-NUMBER>**: 内核镜像
|
||||
- **linux-image-extra-<VERSION-NUMBER>**: 额外的内核模块
|
||||
- **linux-headers-<VERSION-NUMBER>**: 内核头文件
|
||||
|
||||
首先检查系统中安装的内核镜像。
|
||||
|
||||
$ dpkg --list | grep linux-image
|
||||
$ dpkg --list | grep linux-headers
|
||||
|
||||
在列出的内核镜像中,你可以移除一个特定的版本(比如3.19.0-15)。
|
||||
|
||||
$ sudo apt-get purge linux-image-3.19.0-15
|
||||
$ sudo apt-get purge linux-headers-3.19.0-15
|
||||
|
||||
上面的命令会删除内核镜像和它相关联的内核模块和头文件。
|
||||
|
||||
updated to remove the corresponding GRUB entry from GRUB menu.
|
||||
注意如果你还没有升级内核那么删除旧内核会自动触发安装新内核。这样在删除旧内核之后,GRUB配置会自动升级来移除GRUB菜单中相关GRUB入口。
|
||||
|
||||
如果你有很多没用的内核,你可以用shell表达式来一次性地删除多个内核。注意这个括号表达式只在bash或者兼容的shell中才有效。
|
||||
|
||||
$ sudo apt-get purge linux-image-3.19.0-{18,20,21,25}
|
||||
$ sudo apt-get purge linux-headers-3.19.0-{18,20,21,25}
|
||||
|
||||
![](https://farm6.staticflickr.com/5619/21352725355_39cc4fc2d0_c.jpg)
|
||||
|
||||
上面的命令会删除4个内核镜像:3.19.0-18、3.19.0-20、3.19.0-21 和 3.19.0-25。
|
||||
|
||||
如果GRUB配置由于任何原因在删除旧内核后没有正确升级,你可以尝试手动用update-grub2命令来更新配置。
|
||||
|
||||
$ sudo update-grub2
|
||||
|
||||
现在就重启来验证GRUB菜单已经正确清理了。
|
||||
|
||||
![](https://farm1.staticflickr.com/593/20731623163_cccfeac854_z.jpg)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://ask.xmodulo.com/remove-kernel-images-ubuntu.html
|
||||
|
||||
作者:[Dan Nanni][a]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://ask.xmodulo.com/author/nanni
|
Loading…
Reference in New Issue
Block a user