---
title: "ubuntu 12.04  清理boot旧版本软件的牛X命令"
author: "comeon"
date: "2014-10-18T10:27:43Z"
tags: []
categories: ["操作系统"]
slug: "ubuntu-12-04-boot-x"
draft: false
lastmod: "2014-10-18T10:27:43Z"
id: 2144895
url: "https://comeon.iteye.com/blog/2144895"
---

http://askubuntu.com/questions/289869/ubuntu-12-10-i-cant-clean-up-space-in-boot-directory

It's probably because you have too many kernel packages installed (you can only run one at a time).

Check which kernel packages are installed:

```
dpkg -l 'linux-image*' | grep '^ii'
```

Check what your current kernel is:

 

```
uname -r


```

```
% ls -al /boot

```

And my currently running kernel is:

```
% uname -r
3.5.0-27-generic
```

Thus, in my case I could free up space in /boot by removing:

```
linux-image-3.5.0-26-generic
linux-image-3.5.0-28-generic
```

by running `apt-get remove <package_name>`

[up vote]()2[down vote]()

You can remove **ALL** the old kernels, and keep just the latest one. This will free up space on `/boot`. This is doable via multiple methods.

Refer [this link](http://askubuntu.com/questions/2793/how-do-i-to-remove-or-hide-old-kernel-versions-to-clean-up-the-boot-menu). User mikewhatever has provided an answer which can do this removal from one single command from command line.

Update: listing the command here itself, from the said link:

`sudo apt-get remove --purge $(dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d')`