{"id":10884,"date":"2025-06-12T02:00:00","date_gmt":"2025-06-12T06:00:00","guid":{"rendered":"https:\/\/www.both.org\/?p=10884"},"modified":"2025-06-04T20:07:23","modified_gmt":"2025-06-05T00:07:23","slug":"how-to-remove-a-stuck-kernel-from-grub","status":"publish","type":"post","link":"https:\/\/www.both.org\/?p=10884","title":{"rendered":"How to remove a stuck kernel from GRUB"},"content":{"rendered":"<div class=\"pld-like-dislike-wrap pld-template-1\">\r\n    <div class=\"pld-like-wrap  pld-common-wrap\">\r\n    <a href=\"javascript:void(0)\" class=\"pld-like-trigger pld-like-dislike-trigger  \" title=\"\" data-post-id=\"10884\" data-trigger-type=\"like\" data-restriction=\"cookie\" data-already-liked=\"0\">\r\n                        <i class=\"fas fa-thumbs-up\"><\/i>\r\n                <\/a>\r\n    <span class=\"pld-like-count-wrap pld-count-wrap\">    <\/span>\r\n<\/div><\/div>\n<p>Linux updates usually run without issue on my desktop system at home. Except for recently, when a kernel update didn\u2019t remove an older kernel from my GRUB boot menu. Maybe this was because <a href=\"https:\/\/www.both.org\/?p=10880\">my <code>\/boot<\/code> filesystem was full<\/a>, I\u2019m not sure. I just know the boot entry was still there in the menu, but it pointed to a nonexistent kernel.<\/p>\n\n\n\n<p>In these rare instances when something goes wrong, it\u2019s important to know how to <em>manually<\/em> remove a stuck kernel without breaking your boot manager. Here\u2019s how to remove a kernel entry from GRUB:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"list-all-kernels\">List all kernels<\/h2>\n\n\n\n<p>Let\u2019s start by looking at what kernels are defined in the GRUB menu. The <strong>grubby<\/strong> program is the command line interface to query and manage the GRUB boot manager. The most basic action is to list the kernels defined in GRUB. For that, use the <code>--info<\/code> option with the <code>ALL<\/code> argument:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># grubby --info ALL\nindex=0\nkernel=\"\/boot\/vmlinuz-0-rescue-ffffffffffffffffffffffffffffffff\"\nargs=\"ro ro\"\nroot=\"UUID=ab0c20c2-c002-42ed-903a-d92aeb83d7b4\"\ninitrd=\"\/boot\/initramfs-0-rescue-ffffffffffffffffffffffffffffffff.img\"\ntitle=\"Fedora Linux (0-rescue-ffffffffffffffffffffffffffffffff) 42 (Adams)\"\nid=\"ffffffffffffffffffffffffffffffff-0-rescue\"\nindex=1\nkernel=\"\/boot\/vmlinuz-6.14.8-300.fc42.aarch64\"\nargs=\"ro ro\"\nroot=\"UUID=ab0c20c2-c002-42ed-903a-d92aeb83d7b4\"\ninitrd=\"\/boot\/initramfs-6.14.8-300.fc42.aarch64.img\"\ntitle=\"Fedora Linux (6.14.8-300.fc42.aarch64) 42 (Adams)\"\nid=\"52e1582928754799aa40aab822f5eb19-6.14.8-300.fc42.aarch64\"\nindex=2\nkernel=\"\/boot\/vmlinuz-6.14.6-300.fc42.aarch64\"\nargs=\"ro ro\"\nroot=\"UUID=ab0c20c2-c002-42ed-903a-d92aeb83d7b4\"\ninitrd=\"\/boot\/initramfs-6.14.6-300.fc42.aarch64.img\"\ntitle=\"Fedora Linux (6.14.6-300.fc42.aarch64) 42 (Adams)\"\nid=\"52e1582928754799aa40aab822f5eb19-6.14.6-300.fc42.aarch64\"\nindex=3\nkernel=\"\/boot\/vmlinuz-0-rescue-52e1582928754799aa40aab822f5eb19\"\nargs=\"ro ro\"\nroot=\"UUID=ab0c20c2-c002-42ed-903a-d92aeb83d7b4\"\ninitrd=\"\/boot\/initramfs-0-rescue-52e1582928754799aa40aab822f5eb19.img\"\ntitle=\"Fedora Linux (0-rescue-52e1582928754799aa40aab822f5eb19) 42 (Adams)\"\nid=\"52e1582928754799aa40aab822f5eb19-0-rescue\"<\/code><\/pre>\n\n\n\n<p>On my Raspberry Pi, that\u2019s 4 entries, labeled from <code>index=0<\/code> to <code>index=3<\/code>. The first and last entries are rescue kernels. The two kernels in the middle are regular kernels (6.14.6-300 and 6.14.8-300) that I would use to boot my system.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"remove-a-kernel\">Remove a kernel<\/h2>\n\n\n\n<p>Let\u2019s remove one of those kernels. The oldest regular kernel is 6.14.6-300, so we can remove that one. I need to provide the full kernel path to <strong>grubby<\/strong>, but that\u2019s a long path that I\u2019m sure to mistype along the way. I\u2019d rather just insert the path automatically. Since I\u2019m running this system <a href=\"https:\/\/www.both.org\/?p=10813\">entirely at the command line<\/a>, I can\u2019t copy and paste text from a terminal; instead, I need to extract the kernel path using the command line. The <strong>grep<\/strong> command isolates all <strong>grubby<\/strong> entries that contain <code>kernel=<\/code> and the <strong>awk<\/strong> command picks apart that line to just print the contents between the quotes:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># grubby --info ALL | grep kernel= | grep 6.14.6 | awk -F\\\" '{print $2}' &gt; \/tmp\/k \n\n# cat \/tmp\/k\n\/boot\/vmlinuz-6.14.6-300.fc42.aarch64<\/code><\/pre>\n\n\n\n<p>The <code>--remove-kernel<\/code> option will delete a GRUB entry that matches a full kernel path, so we can use Bash expansion with <strong>grubby<\/strong> to remove that kernel version:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># grubby --remove-kernel=$(cat \/tmp\/k)<\/code><\/pre>\n\n\n\n<p>And one more <strong>grubby<\/strong> command will display all entries, to confirm that we\u2019ve removed the kernel from the GRUB menu:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># grubby --info ALL\nindex=0\nkernel=\"\/boot\/vmlinuz-0-rescue-ffffffffffffffffffffffffffffffff\"\nargs=\"ro ro\"\nroot=\"UUID=ab0c20c2-c002-42ed-903a-d92aeb83d7b4\"\ninitrd=\"\/boot\/initramfs-0-rescue-ffffffffffffffffffffffffffffffff.img\"\ntitle=\"Fedora Linux (0-rescue-ffffffffffffffffffffffffffffffff) 42 (Adams)\"\nid=\"ffffffffffffffffffffffffffffffff-0-rescue\"\nindex=1\nkernel=\"\/boot\/vmlinuz-6.14.8-300.fc42.aarch64\"\nargs=\"ro ro\"\nroot=\"UUID=ab0c20c2-c002-42ed-903a-d92aeb83d7b4\"\ninitrd=\"\/boot\/initramfs-6.14.8-300.fc42.aarch64.img\"\ntitle=\"Fedora Linux (6.14.8-300.fc42.aarch64) 42 (Adams)\"\nid=\"52e1582928754799aa40aab822f5eb19-6.14.8-300.fc42.aarch64\"\nindex=2\nkernel=\"\/boot\/vmlinuz-0-rescue-52e1582928754799aa40aab822f5eb19\"\nargs=\"ro ro\"\nroot=\"UUID=ab0c20c2-c002-42ed-903a-d92aeb83d7b4\"\ninitrd=\"\/boot\/initramfs-0-rescue-52e1582928754799aa40aab822f5eb19.img\"\ntitle=\"Fedora Linux (0-rescue-52e1582928754799aa40aab822f5eb19) 42 (Adams)\"\nid=\"52e1582928754799aa40aab822f5eb19-0-rescue\"<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"system-administration-from-the-command-line\">System administration from the command line<\/h2>\n\n\n\n<p>I don\u2019t always use a graphical desktop to do my work. It\u2019s good to know how to access the power of the command line to get things done, especially <em>system administration<\/em> tasks.<\/p>\n\n\n\n<p>Use <code>man grubby<\/code> to see a full list of what else you can do with <strong>grubby<\/strong> to manage your system. For example, you can also use <code>--set-default<\/code> to set the path to a new default kernel, or <code>--default-kernel<\/code> to display the current default kernel.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s how to fix the GRUB menu configuration from the command line.<\/p>\n","protected":false},"author":33,"featured_media":4599,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[375,570,5],"tags":[104,91,162],"class_list":["post-10884","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-grub","category-kernel","category-linux","tag-command-line","tag-linux","tag-problem-determination"],"modified_by":"Jim Hall","_links":{"self":[{"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/10884","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/users\/33"}],"replies":[{"embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10884"}],"version-history":[{"count":1,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/10884\/revisions"}],"predecessor-version":[{"id":10885,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/10884\/revisions\/10885"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/media\/4599"}],"wp:attachment":[{"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10884"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10884"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10884"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}