{"id":12926,"date":"2019-03-29T03:07:16","date_gmt":"2019-03-29T03:07:16","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=12926"},"modified":"2019-03-29T03:07:16","modified_gmt":"2019-03-29T03:07:16","slug":"how-to-delete-old-unused-kernels-in-debian-and-ubuntu","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/29\/how-to-delete-old-unused-kernels-in-debian-and-ubuntu\/","title":{"rendered":"How to Delete Old Unused Kernels in Debian and Ubuntu"},"content":{"rendered":"<p>In this article, we will explain how to delete old unused kernels in Debian and Ubuntu systems, but before moving further, you may want to install the latest version in order to take advantage of: security fixes, new kernel functions, updated drivers and so much more.<\/p>\n<p>To upgrade your kernel to latest version in Ubuntu and Debian, follow this guide:<\/p>\n<ol>\n<li><a href=\"https:\/\/www.tecmint.com\/upgrade-kernel-in-ubuntu\/\" target=\"_blank\" rel=\"noopener\">How to Upgrade Kernel to Latest Version in Ubuntu<\/a><\/li>\n<\/ol>\n<p><strong>Important<\/strong>: It is advisable to keep at least one or two old kernels to fall back to in case there is a problem with an update.<\/p>\n<p>To find out the\u00a0<a href=\"https:\/\/www.tecmint.com\/find-linux-kernel-version-distribution-name-version-number\/\" target=\"_blank\" rel=\"noopener\">current version of Linux kernel<\/a>\u00a0running on your system, use the following command.<\/p>\n<pre>$ uname -sr\r\n\r\n<strong>Linux 4.12.0-041200-generic<\/strong><\/pre>\n<p>To list all installed kernels on your system, issue this command.<\/p>\n<pre>$ dpkg -l | grep linux-image | awk '{print$2}'\r\n\r\n<strong>linux-image-4.12.0-041200-generic\r\nlinux-image-4.8.0-22-generic\r\nlinux-image-extra-4.8.0-22-generic\r\nlinux-image-generic<\/strong>\r\n<\/pre>\n<h3>Remove Old Unused Kernels on Debian and Ubuntu<\/h3>\n<p>Run the commands below to remove a particular\u00a0<strong>linux-image<\/strong>\u00a0along with its configuration files, then update\u00a0<strong>grub2<\/strong>\u00a0configuration, and lastly reboot the system.<\/p>\n<pre>$ sudo apt remove --purge linux-image-4.4.0-21-generic\r\n$ sudo update-grub2\r\n$ sudo reboot\r\n<\/pre>\n<div class=\"code-label\">Removing Old Kernel in Ubuntu<\/div>\n<pre>[sudo] password for tecmint: \r\nReading package lists... Done\r\nBuilding dependency tree       \r\nReading state information... Done\r\nThe following additional packages will be installed:\r\n  linux-generic linux-headers-4.8.0-59 linux-headers-4.8.0-59-generic linux-headers-generic linux-image-4.8.0-59-generic linux-image-extra-4.8.0-59-generic linux-image-generic\r\nSuggested packages:\r\n  fdutils linux-doc-4.8.0 | linux-source-4.8.0 linux-tools\r\nRecommended packages:\r\n  thermald\r\nThe following packages will be REMOVED:\r\n  linux-image-4.8.0-22-generic* linux-image-extra-4.8.0-22-generic*\r\nThe following NEW packages will be installed:\r\n  linux-headers-4.8.0-59 linux-headers-4.8.0-59-generic linux-image-4.8.0-59-generic linux-image-extra-4.8.0-59-generic\r\nThe following packages will be upgraded:\r\n  linux-generic linux-headers-generic linux-image-generic\r\n3 upgraded, 4 newly installed, 2 to remove and 182 not upgraded.\r\nNeed to get 72.0 MB of archives.\r\nAfter this operation, 81.7 MB of additional disk space will be used.\r\nDo you want to continue? [Y\/n] y\r\nGet:1 http:\/\/us.archive.ubuntu.com\/ubuntu yakkety-updates\/main amd64 linux-headers-4.8.0-59 all 4.8.0-59.64 [10.2 MB]\r\nGet:2 http:\/\/us.archive.ubuntu.com\/ubuntu yakkety-updates\/main amd64 linux-headers-4.8.0-59-generic amd64 4.8.0-59.64 [811 kB]                                                               \r\nGet:3 http:\/\/us.archive.ubuntu.com\/ubuntu yakkety-updates\/main amd64 linux-generic amd64 4.8.0.59.72 [1,782 B]                                                                               \r\nGet:4 http:\/\/us.archive.ubuntu.com\/ubuntu yakkety-updates\/main amd64 linux-headers-generic amd64 4.8.0.59.72 [2,320 B]                                                                       \r\nGet:5 http:\/\/us.archive.ubuntu.com\/ubuntu yakkety-updates\/main amd64 linux-image-4.8.0-59-generic amd64 4.8.0-59.64 [23.6 MB]                                                                \r\nGet:6 http:\/\/us.archive.ubuntu.com\/ubuntu yakkety-updates\/main amd64 linux-image-extra-4.8.0-59-generic amd64 4.8.0-59.64 [37.4 MB]                                                          \r\nGet:7 http:\/\/us.archive.ubuntu.com\/ubuntu yakkety-updates\/main amd64 linux-image-generic amd64 4.8.0.59.72 [2,348 B]                                                                         \r\nFetched 72.0 MB in 7min 12s (167 kB\/s)                                                                                                                                                       \r\nSelecting previously unselected package linux-headers-4.8.0-59.\r\n(Reading database ... 104895 files and directories currently installed.)\r\nPreparing to unpack ...\/0-linux-headers-4.8.0-59_4.8.0-59.64_all.deb ...\r\nUnpacking linux-headers-4.8.0-59 (4.8.0-59.64) ...\r\nSelecting previously unselected package linux-headers-4.8.0-59-generic.\r\nPreparing to unpack ...\/1-linux-headers-4.8.0-59-generic_4.8.0-59.64_amd64.deb ...\r\nUnpacking linux-headers-4.8.0-59-generic (4.8.0-59.64) ...\r\nPreparing to unpack ...\/2-linux-generic_4.8.0.59.72_amd64.deb ...\r\nUnpacking linux-generic (4.8.0.59.72) over (4.8.0.22.31) ...\r\nPreparing to unpack ...\/3-linux-headers-generic_4.8.0.59.72_amd64.deb ...\r\nUnpacking linux-headers-generic (4.8.0.59.72) over (4.8.0.22.31) ...\r\nSelecting previously unselected package linux-image-4.8.0-59-generic.\r\nPreparing to unpack ...\/4-linux-image-4.8.0-59-generic_4.8.0-59.64_amd64.deb ...\r\nDone.\r\nRemoving linux-image-4.8.0-22-generic (4.8.0-22.24) ...\r\nExamining \/etc\/kernel\/postrm.d .\r\nrun-parts: executing \/etc\/kernel\/postrm.d\/initramfs-tools 4.8.0-22-generic \/boot\/vmlinuz-4.8.0-22-generic\r\nupdate-initramfs: Deleting \/boot\/initrd.img-4.8.0-22-generic\r\nrun-parts: executing \/etc\/kernel\/postrm.d\/zz-update-grub 4.8.0-22-generic \/boot\/vmlinuz-4.8.0-22-generic\r\nGenerating grub configuration file ...\r\nFound linux image: \/boot\/vmlinuz-4.12.0-041200-generic\r\nFound initrd image: \/boot\/initrd.img-4.12.0-041200-generic\r\nFound linux image: \/boot\/vmlinuz-4.8.0-59-generic\r\ndone\r\n...\r\n<\/pre>\n<p>Although this method works just fine, it is more reliable and efficient to use a handy script called \u201c<strong>byobu<\/strong>\u201d that combines all the commands above into a single program with useful options such as specifying number of kernels to keep on the system.<\/p>\n<p>Install\u00a0<strong>byobu<\/strong>\u00a0script package which provides a program called\u00a0<strong>purge-old-kernels<\/strong>\u00a0used for removing old kernels and header packages from the system.<\/p>\n<pre>$ sudo apt install byobu\r\n<\/pre>\n<p>Then remove old kernels like so (the command below allows 2 kernels to be kept on the system).<\/p>\n<pre>$ sudo purge-old-kernels --keep 2\r\n<\/pre>\n<p>You may also like to read these following related articles on Linux kernel.<\/p>\n<ol>\n<li><a href=\"https:\/\/www.tecmint.com\/load-and-unload-kernel-modules-in-linux\/\" target=\"_blank\" rel=\"noopener\">How to Load and Unload Kernel Modules in Linux<\/a><\/li>\n<li><a href=\"https:\/\/www.tecmint.com\/change-modify-linux-kernel-runtime-parameters\/\" target=\"_blank\" rel=\"noopener\">How to Change Kernel Runtime Parameters in a Persistent and Non-Persistent Way<\/a><\/li>\n<\/ol>\n<p>In this article, we have described how to remove old unused kernel images on Ubuntu and Debian systems. You can share any thoughts via the feedback from below.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/remove-old-kernel-in-debian-and-ubuntu\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article, we will explain how to delete old unused kernels in Debian and Ubuntu systems, but before moving further, you may want to install the latest version in order to take advantage of: security fixes, new kernel functions, updated drivers and so much more. To upgrade your kernel to latest version in Ubuntu &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/29\/how-to-delete-old-unused-kernels-in-debian-and-ubuntu\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Delete Old Unused Kernels in Debian and Ubuntu&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-12926","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12926","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=12926"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12926\/revisions"}],"predecessor-version":[{"id":12927,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12926\/revisions\/12927"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=12926"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=12926"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=12926"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}