Child pages
  • Scripts

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Because you automatically upgrade your kernels, your VMs get clogged up with old kernels and headers. Example:

 

Code Block
bofh@webvisser@test-omega:~$ ls -la /lib/modules/
total 4432
drwxr-xr-x 11 8 root root 4096 JunMar 1415 06:3447 .
drwxr-xr-x 1921 root root 4096 MaySep  3 31 06:502014 ..
drwxr-xr-x  45 root root 4096 FebJan 16 8 0102:5850 3.213.0-3771-virtualgeneric
drwxr-xr-x  45 root root 4096 FebJan 2216 0602:5451 3.213.0-3874-virtualgeneric
drwxr-xr-x  45 root root 4096 MarJan 1920 06:4253 3.213.0-3976-virtualgeneric
drwxr-xr-x  45 root root 4096 AprFeb  92 06:4537 3.213.0-4077-virtualgeneric
drwxr-xr-x  45 root root 4096 MayFeb  223 06:4535 3.213.0-4179-virtualgeneric
drwxr-xr-x  45 root root 4096 MayMar 1615 06:5448 3.213.0-43-virtual
drwxr-xr-x  4 root root 4096 May 24 06:26 3.2.0-44-virtual
drwxr-xr-x  4 root root 4096 May 31 06:50 3.2.0-45-virtual
drwxr-xr-x  4 root root 4096 Jun 14 06:35 3.2.0-48-virtual

You should do some house cleaning, by removing all old kernels, headers, and manually compiled modules. Given that you run 48, and the oldest one is 37, this one liner does it for you:

Code Block
languagebash
for i in `seq 37 47`; do apt-get -yy purge linux-image-3.2.0-$i-virtual linux-headers-3.2.0-$i; rm -rfv /lib/modules/3.2.0-$i-virtual; done-83-generic

You should do some house cleaning by removing all old kernels, headers, and manually compiled modules. Make sure that you are running the latest kernel.

To list all installed kernels and accompanying headers:

Code Block
root@test-omega:~# apt-show-versions -b | grep -E 'linux-(headers|image(-extra)?)-[0-9]+'
linux-headers-3.13.0-71:all/trusty-security
linux-headers-3.13.0-71-generic:amd64/trusty-security
linux-headers-3.13.0-74:all/trusty-security
linux-headers-3.13.0-74-generic:amd64/trusty-security
linux-headers-3.13.0-76:all/trusty-security
linux-headers-3.13.0-76-generic:amd64/trusty-security
linux-headers-3.13.0-77:all/trusty-security
linux-headers-3.13.0-77-generic:amd64/trusty-security
linux-headers-3.13.0-79:all/trusty-security
linux-headers-3.13.0-79-generic:amd64/trusty-security
linux-headers-3.13.0-83:all/trusty-security
linux-headers-3.13.0-83-generic:amd64/trusty-security
linux-image-3.13.0-71-generic:amd64/trusty-security
linux-image-3.13.0-74-generic:amd64/trusty-security
linux-image-3.13.0-76-generic:amd64/trusty-security
linux-image-3.13.0-77-generic:amd64/trusty-security
linux-image-3.13.0-79-generic:amd64/trusty-security
linux-image-3.13.0-83-generic:amd64/trusty-security
linux-image-extra-3.13.0-71-generic:amd64/trusty-security
linux-image-extra-3.13.0-74-generic:amd64/trusty-security
linux-image-extra-3.13.0-76-generic:amd64/trusty-security
linux-image-extra-3.13.0-77-generic:amd64/trusty-security
linux-image-extra-3.13.0-79-generic:amd64/trusty-security
linux-image-extra-3.13.0-83-generic:amd64/trusty-security

You can't just purge all of these because you will trash your current kernel. So you need to exclude that, preferably using the uname command:

Code Block
visser@test-omega:~$ uname -r
3.13.0-83-generic

So this will yield:

Code Block
visser@test-omega:~$ apt-show-versions -b | grep -E 'linux-(headers|image(-extra)?)-[0-9]+' | grep -v `uname -r`
linux-headers-3.13.0-71:all/trusty-security
linux-headers-3.13.0-71-generic:amd64/trusty-security
linux-headers-3.13.0-74:all/trusty-security
linux-headers-3.13.0-74-generic:amd64/trusty-security
linux-headers-3.13.0-76:all/trusty-security
linux-headers-3.13.0-76-generic:amd64/trusty-security
linux-headers-3.13.0-77:all/trusty-security
linux-headers-3.13.0-77-generic:amd64/trusty-security
linux-headers-3.13.0-79:all/trusty-security
linux-headers-3.13.0-79-generic:amd64/trusty-security
linux-headers-3.13.0-83:all/trusty-security
linux-image-3.13.0-71-generic:amd64/trusty-security
linux-image-3.13.0-74-generic:amd64/trusty-security
linux-image-3.13.0-76-generic:amd64/trusty-security
linux-image-3.13.0-77-generic:amd64/trusty-security
linux-image-3.13.0-79-generic:amd64/trusty-security
linux-image-extra-3.13.0-71-generic:amd64/trusty-security
linux-image-extra-3.13.0-74-generic:amd64/trusty-security
linux-image-extra-3.13.0-76-generic:amd64/trusty-security
linux-image-extra-3.13.0-77-generic:amd64/trusty-security
linux-image-extra-3.13.0-79-generic:amd64/trusty-security

 

However this will also remove the headers of the current kernel, so we have to strip the -generic part from the uname output:

Code Block
visser@test-omega:~$ apt-show-versions -b | grep -E 'linux-(headers|image(-extra)?)-[0-9]+' | grep -v $(uname -r | sed -E 's/-[a-z]+$//')
linux-headers-3.13.0-71:all/trusty-security
linux-headers-3.13.0-71-generic:amd64/trusty-security
linux-headers-3.13.0-74:all/trusty-security
linux-headers-3.13.0-74-generic:amd64/trusty-security
linux-headers-3.13.0-76:all/trusty-security
linux-headers-3.13.0-76-generic:amd64/trusty-security
linux-headers-3.13.0-77:all/trusty-security
linux-headers-3.13.0-77-generic:amd64/trusty-security
linux-headers-3.13.0-79:all/trusty-security
linux-headers-3.13.0-79-generic:amd64/trusty-security
linux-image-3.13.0-71-generic:amd64/trusty-security
linux-image-3.13.0-74-generic:amd64/trusty-security
linux-image-3.13.0-76-generic:amd64/trusty-security
linux-image-3.13.0-77-generic:amd64/trusty-security
linux-image-3.13.0-79-generic:amd64/trusty-security
linux-image-extra-3.13.0-71-generic:amd64/trusty-security
linux-image-extra-3.13.0-74-generic:amd64/trusty-security
linux-image-extra-3.13.0-76-generic:amd64/trusty-security
linux-image-extra-3.13.0-77-generic:amd64/trusty-security
linux-image-extra-3.13.0-79-generic:amd64/trusty-security

 

This looks good. Now we can purge these packages:

 

Code Block
visser@test-omega:~$ sudo apt-get purge `apt-show-versions -b | grep -E 'linux-(headers|image(-extra)?)-[0-9]+' | grep -v $(uname -r | sed -E 's/-[a-z]+$//')`
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Selected version '3.13.0-71.114' (Ubuntu:14.04/trusty-updates [all]) for 'linux-headers-3.13.0-71'
Selected version '3.13.0-71.114' (Ubuntu:14.04/trusty-updates [amd64]) for 'linux-headers-3.13.0-71-generic'
Selected version '3.13.0-74.118' (Ubuntu:14.04/trusty-updates [all]) for 'linux-headers-3.13.0-74'
Selected version '3.13.0-74.118' (Ubuntu:14.04/trusty-updates [amd64]) for 'linux-headers-3.13.0-74-generic'
Selected version '3.13.0-76.120' (Ubuntu:14.04/trusty-updates [all]) for 'linux-headers-3.13.0-76'
Selected version '3.13.0-76.120' (Ubuntu:14.04/trusty-updates [amd64]) for 'linux-headers-3.13.0-76-generic'
Selected version '3.13.0-77.121' (Ubuntu:14.04/trusty-updates [all]) for 'linux-headers-3.13.0-77'
Selected version '3.13.0-77.121' (Ubuntu:14.04/trusty-updates [amd64]) for 'linux-headers-3.13.0-77-generic'
Selected version '3.13.0-79.123' (Ubuntu:14.04/trusty-updates [all]) for 'linux-headers-3.13.0-79'
Selected version '3.13.0-79.123' (Ubuntu:14.04/trusty-updates [amd64]) for 'linux-headers-3.13.0-79-generic'
Selected version '3.13.0-71.114' (Ubuntu:14.04/trusty-updates [amd64]) for 'linux-image-3.13.0-71-generic'
Selected version '3.13.0-74.118' (Ubuntu:14.04/trusty-updates [amd64]) for 'linux-image-3.13.0-74-generic'
Selected version '3.13.0-76.120' (Ubuntu:14.04/trusty-updates [amd64]) for 'linux-image-3.13.0-76-generic'
Selected version '3.13.0-77.121' (Ubuntu:14.04/trusty-updates [amd64]) for 'linux-image-3.13.0-77-generic'
Selected version '3.13.0-79.123' (Ubuntu:14.04/trusty-updates [amd64]) for 'linux-image-3.13.0-79-generic'
Selected version '3.13.0-71.114' (Ubuntu:14.04/trusty-updates [amd64]) for 'linux-image-extra-3.13.0-71-generic'
Selected version '3.13.0-74.118' (Ubuntu:14.04/trusty-updates [amd64]) for 'linux-image-extra-3.13.0-74-generic'
Selected version '3.13.0-76.120' (Ubuntu:14.04/trusty-updates [amd64]) for 'linux-image-extra-3.13.0-76-generic'
Selected version '3.13.0-77.121' (Ubuntu:14.04/trusty-updates [amd64]) for 'linux-image-extra-3.13.0-77-generic'
Selected version '3.13.0-79.123' (Ubuntu:14.04/trusty-updates [amd64]) for 'linux-image-extra-3.13.0-79-generic'
The following packages will be REMOVED:
  linux-headers-3.13.0-71* linux-headers-3.13.0-71-generic*
  linux-headers-3.13.0-74* linux-headers-3.13.0-74-generic*
  linux-headers-3.13.0-76* linux-headers-3.13.0-76-generic*
  linux-headers-3.13.0-77* linux-headers-3.13.0-77-generic*
  linux-headers-3.13.0-79* linux-headers-3.13.0-79-generic*
  linux-image-3.13.0-71-generic* linux-image-3.13.0-74-generic*
  linux-image-3.13.0-76-generic* linux-image-3.13.0-77-generic*
  linux-image-3.13.0-79-generic* linux-image-extra-3.13.0-71-generic*
  linux-image-extra-3.13.0-74-generic* linux-image-extra-3.13.0-76-generic*
  linux-image-extra-3.13.0-77-generic* linux-image-extra-3.13.0-79-generic*
0 upgraded, 0 newly installed, 20 to remove and 35 not upgraded.
After this operation, 1,357 MB disk space will be freed.
Do you want to continue? [Y/n] 

 

 

Removing set of e-mail address from another set of email address

List of address with optional names, separated by whitespace:

...