no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | tech:linux:purge_linux_images [2016/08/17 11:26] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Purge Old Linux Headers/ | ||
+ | If there is limited space on /boot, this becomes a necessity. | ||
+ | <code bash> | ||
+ | dpkg -l linux-image-\* | grep ^ii | ||
+ | uname -a | ||
+ | </ | ||
+ | Sample output | ||
+ | < | ||
+ | ii linux-image-3.2.0-38-generic | ||
+ | ii linux-image-3.2.0-39-generic | ||
+ | ii linux-image-3.2.0-40-generic | ||
+ | ii linux-image-3.2.0-43-generic | ||
+ | ii linux-image-server | ||
+ | |||
+ | |||
+ | Linux ub4 3.2.0-43-generic #68-Ubuntu SMP Wed May 15 03:33:33 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux | ||
+ | </ | ||
+ | |||
+ | Considering that 3.2.0-43 is installed we can remove 3.2.0-38, | ||
+ | < | ||
+ | PACKAGE=" | ||
+ | aptitude search $PACKAGE | ||
+ | aptitude remove $PACKAGE | ||
+ | aptitude -y purge $PACKAGE | ||
+ | </ | ||
+ | |||
+ | Outputs | ||
+ | < | ||
+ | # aptitude search $PACKAGE | ||
+ | i A linux-image-3.2.0-40-generic | ||
+ | p | ||
+ | p | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | # aptitude search $PACKAGE | ||
+ | i A linux-image-3.2.0-40-generic | ||
+ | p | ||
+ | p | ||
+ | [07:49:46 AM][root@ub4]:/ | ||
+ | The following packages will be REMOVED: | ||
+ | linux-image-3.2.0-40-generic | ||
+ | 0 packages upgraded, 0 newly installed, 1 to remove and 78 not upgraded. | ||
+ | Need to get 0 B of archives. After unpacking 150 MB will be freed. | ||
+ | (Reading database ... 111084 files and directories currently installed.) | ||
+ | Removing linux-image-3.2.0-40-generic ... | ||
+ | Examining / | ||
+ | run-parts: executing / | ||
+ | update-initramfs: | ||
+ | run-parts: executing / | ||
+ | Generating grub.cfg ... | ||
+ | Found linux image: / | ||
+ | Found initrd image: / | ||
+ | Found linux image: / | ||
+ | Found initrd image: / | ||
+ | Found linux image: / | ||
+ | Found initrd image: / | ||
+ | Found memtest86+ image: / | ||
+ | done | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | # aptitude -y purge $PACKAGE | ||
+ | The following packages will be REMOVED: | ||
+ | linux-image-3.2.0-40-generic{p} | ||
+ | 0 packages upgraded, 0 newly installed, 1 to remove and 78 not upgraded. | ||
+ | Need to get 0 B of archives. After unpacking 0 B will be used. | ||
+ | (Reading database ... 106946 files and directories currently installed.) | ||
+ | Removing linux-image-3.2.0-40-generic ... | ||
+ | Purging configuration files for linux-image-3.2.0-40-generic ... | ||
+ | Examining / | ||
+ | run-parts: executing / | ||
+ | run-parts: executing / | ||
+ | </ | ||
+ | |||
+ | Repeat for 39 and 38 as well. I usually leave a few versions behind and not remove all of them. | ||
+ | |||
+ | ===== Update to Latest Kernel ===== | ||
+ | <code bash> | ||
+ | aptitude update | ||
+ | aptitude install linux-headers-generic | ||
+ | </ | ||
+ | |||
+ | ===== Script ===== | ||
+ | Create the list of existing images | ||
+ | <code bash> | ||
+ | dpkg -l linux-image-\* | grep ^ii | awk ' | ||
+ | chmod 755 / | ||
+ | </ | ||
+ | DELETE the last few lines before running to avoid deleting recent/ | ||
+ | |||
+ | Create file ''/ | ||
+ | <code bash> | ||
+ | #!/bin/bash | ||
+ | # | ||
+ | PACKAGE=$1 | ||
+ | aptitude -y remove $PACKAGE | ||
+ | aptitude -y purge $PACKAGE | ||
+ | # | ||
+ | exit | ||
+ | </ | ||
+ | Change permissions on ''/ | ||
+ | <code bash> | ||
+ | chmod 755 /tmp/pimage | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== References ===== | ||
+ | http:// | ||