Packages: Difference between revisions
revert edits to fix search where character encoding was a problem |
m Text replacement - "<(\/?)source" to "<$1syntaxhighlight" |
||
| Line 21: | Line 21: | ||
Kernels take up a lot of disk space. And once you've got a new one, the old ones really don't serve a purpose. <code>autoremove</code> is supposed to remove old kernels (keeping the currently running kernel plus the prior one or two for backups). | Kernels take up a lot of disk space. And once you've got a new one, the old ones really don't serve a purpose. <code>autoremove</code> is supposed to remove old kernels (keeping the currently running kernel plus the prior one or two for backups). | ||
< | <syntaxhighlight lang="bash"> | ||
sudo apt-get autoremove | sudo apt-get autoremove | ||
</ | </syntaxhighlight> | ||
But sometimes old kernels are left lying around. Maybe a lot of them. I'm not sure why, because normally you would only be left with 2 or 3 kernels if you run autoremove (perhaps this is because you have old virtualboxes?). | But sometimes old kernels are left lying around. Maybe a lot of them. I'm not sure why, because normally you would only be left with 2 or 3 kernels if you run autoremove (perhaps this is because you have old virtualboxes?). | ||
The post-install script <code>/etc/kernel/postinst.d/apt-auto-removal</code> is responsible for keeping track of what to preserve. And it writes a manifest to <code>/etc/apt/apt.conf.d/01autoremove-kernels</code>. | The post-install script <code>/etc/kernel/postinst.d/apt-auto-removal</code> is responsible for keeping track of what to preserve. And it writes a manifest to <code>/etc/apt/apt.conf.d/01autoremove-kernels</code>. | ||
< | <syntaxhighlight lang="bash"> | ||
# run the post-install script | # run the post-install script | ||
sudo /etc/kernel/postinst.d/apt-auto-removal | sudo /etc/kernel/postinst.d/apt-auto-removal | ||
# see what's reserved | # see what's reserved | ||
cat /etc/apt/apt.conf.d/01autoremove-kernels | cat /etc/apt/apt.conf.d/01autoremove-kernels | ||
</ | </syntaxhighlight> | ||
Let's use <code>dpkg</code> to see all the kernels that are currently installed. Note: there are other related packages like headers (<code>linux-headers-*</code>), but those are dependencies of the kernel images, and will be removed when we remove the images so we don't need to even look at them. | Let's use <code>dpkg</code> to see all the kernels that are currently installed. Note: there are other related packages like headers (<code>linux-headers-*</code>), but those are dependencies of the kernel images, and will be removed when we remove the images so we don't need to even look at them. | ||
< | <syntaxhighlight lang="bash"> | ||
# the last pipe uses a simple extended grep to take the meta package 'linux-image-generic' out of our list | # the last pipe uses a simple extended grep to take the meta package 'linux-image-generic' out of our list | ||
dpkg -l linux-image* | awk '/^ii/ { print $2 }' | grep -e [0-9] | dpkg -l linux-image* | awk '/^ii/ { print $2 }' | grep -e [0-9] | ||
# more complete perl-compatible regex to highlight the kernel release number | # more complete perl-compatible regex to highlight the kernel release number | ||
dpkg -l linux-image* | awk '/^ii/ { print $2 }' | grep -P '[0-9]+\.[0-9]+\.[0-9\-]+[0-9]+' | dpkg -l linux-image* | awk '/^ii/ { print $2 }' | grep -P '[0-9]+\.[0-9]+\.[0-9\-]+[0-9]+' | ||
</ | </syntaxhighlight> | ||
Manually compose an <code>apt-get purge</code> invocation of the kernels you don't want (keep the running kernel and the prior as a fallback). | Manually compose an <code>apt-get purge</code> invocation of the kernels you don't want (keep the running kernel and the prior as a fallback). | ||
< | <syntaxhighlight lang="bash"> | ||
sudo apt-get -y purge linux-image-3.13.0-44-generic linux-image-3.13.0-46-generic linux-image-3.13.0-48-generic linux-image-3.13.0-55-generic linux-image-3.13.0-71-generic linux-image-3.13.0-74-generic | sudo apt-get -y purge linux-image-3.13.0-44-generic linux-image-3.13.0-46-generic linux-image-3.13.0-48-generic linux-image-3.13.0-55-generic linux-image-3.13.0-71-generic linux-image-3.13.0-74-generic | ||
</ | </syntaxhighlight> | ||
== RedHat and derivatives == | == RedHat and derivatives == | ||