{"id":4729,"date":"2017-04-06T23:27:07","date_gmt":"2017-04-06T20:27:07","guid":{"rendered":"https:\/\/vaxxi.net\/log\/?p=4729"},"modified":"2017-04-06T23:34:23","modified_gmt":"2017-04-06T20:34:23","slug":"how-to-rescue-a-fedora-workstation-after-removing-all-available-kernels","status":"publish","type":"post","link":"https:\/\/vaxxi.net\/log\/how-to-rescue-a-fedora-workstation-after-removing-all-available-kernels\/","title":{"rendered":"how to rescue a fedora workstation after removing all available kernels"},"content":{"rendered":"<p>You know that feeling when everything goes well for a while &#8230; until it doesn&#8217;t ? been using Fedora Workstation 25 and quite satisfied with it, util one late evening when I decided to clean up old kernels and removed every last kernel available. Here&#8217;s how to restore a Fedora Workstation system after you&#8217;ve removed every kernel available \ud83d\ude42 this applies to a Fedora 25 on an EFI system and GRUB 2 &#8211; so 2017!<\/p>\n<p><!--more--><\/p>\n<p>Normally, at this stage you&#8217;d boot the borked system with an USB stick and simply reinstall the kernel packages. This works fine on a Debian\/Ubuntu system, but Fedora seems to be a bit more annoying &#8211; after chrooting I&#8217;d get:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n&#x5B;root@localhost-live ~]# yum -y --disablerepo='*' install kernel-*\r\nRedirecting to '\/usr\/bin\/dnf -y --disablerepo=* install kernel-4.10.8-200.fc25.x86_64.rpm kernel-core-4.10.8-200.fc25.x86_64.rpm kernel-headers-4.10.8-200.fc25.x86_64.rpm kernel-modules-4.10.8-200.fc25.x86_64.rpm' (see 'man yum2dnf')\r\n\r\nerror: Failed to initialize NSS library\r\nTraceback (most recent call last):\r\n  File &quot;\/usr\/bin\/dnf&quot;, line 57, in &lt;module&gt;\r\n    from dnf.cli import main\r\n  File &quot;\/usr\/lib\/python3.5\/site-packages\/dnf\/__init__.py&quot;, line 31, in &lt;module&gt;\r\n    import dnf.base\r\n  File &quot;\/usr\/lib\/python3.5\/site-packages\/dnf\/base.py&quot;, line 30, in &lt;module&gt;\r\n    from dnf.yum import history\r\n  File &quot;\/usr\/lib\/python3.5\/site-packages\/dnf\/yum\/history.py&quot;, line 31, in &lt;module&gt;\r\n    import dnf.rpm.miscutils\r\n  File &quot;\/usr\/lib\/python3.5\/site-packages\/dnf\/rpm\/__init__.py&quot;, line 22, in &lt;module&gt;\r\n    from . import transaction\r\n  File &quot;\/usr\/lib\/python3.5\/site-packages\/dnf\/rpm\/transaction.py&quot;, line 14, in &lt;module&gt;\r\n    import rpm\r\n  File &quot;\/usr\/lib64\/python3.5\/site-packages\/rpm\/__init__.py&quot;, line 39, in &lt;module&gt;\r\n    from rpm.transaction import *\r\n  File &quot;\/usr\/lib64\/python3.5\/site-packages\/rpm\/transaction.py&quot;, line 5, in &lt;module&gt;\r\n    from rpm._rpm import ts as TransactionSetCore\r\nImportError: cannot import name 'ts'\r\n<\/pre>\n<p>Well, f*** you, I don&#8217;t remember my package manager needing a ton of Python dependencies to work ! a few more straces and copious amounts of cursing later, here&#8217;s the step by step solution:<\/p>\n<p>1. Boot from a Fedora Workstation 25 Live USB stick. Make sure you click the &#8220;Try&#8221; option to get your live USB stick mounted read-write, otherwise you won&#8217;t be able to install packages on the live USB stick. Make sure the system has network connectivity.<\/p>\n<p>2. Install the nscd package and its dependencies:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n# sudo su\r\n# dnf -y install nscd\r\n<\/pre>\n<p>3. Start nscd (this is done in order to have the nscd socket available in chroot, rpm\/dnf won&#8217;t work without this &#8211; STUPID STUPID STUPID):<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n# systemctl start nscd\r\n<\/pre>\n<p>After this, a socket in \/var\/run\/named\/socket should exist.<\/p>\n<p>4. Prepare the chroot mount point and get inside the chroot:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n# mkdir \/mnt\/sysimage\r\n# mkdir \/mnt\/sysimage\/{boot,proc,run,sys,dev}\r\n# mount &#x5B;your root partition] \/mnt\/sysimage\r\n# mount &#x5B;your boot partition] \/mnt\/sysimage\/boot\r\n# mount --bind \/dev \/mnt\/sysimage\/dev\/\r\n# mount --bind \/sys \/mnt\/sysimage\/sys\/\r\n# mount --bind \/proc \/mnt\/sysimage\/proc\/\r\n# mount --bind \/var\/run \/mnt\/sysimage\/var\/run\r\n# cp \/etc\/resolv.conf \/mnt\/sysimage\/etc\/resolv.conf\r\n<\/pre>\n<p>5. Reinstall the packages by downloading the kernel-* RPMs with wget and installing them manually OR with a &#8220;dnf -y reinstall kernel-*&#8221; (didn&#8217;t tried this one).<\/p>\n<p>6. Your Grub is now broken too, so we need to rescue it as well. At the GRUB console find your boot and root partitions with &#8220;ls&#8221; and then:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n&gt; set prefix=(hdX,Y) \r\n&gt; set root=(hdX,Z)\r\n&gt; linuxefi \/boot\/vmlinuz-4.xxxxxx root=(hdX,Z)\r\n&gt; initramfs \/boot\/initramfs-4.xxxxxx\r\n&gt; boot\r\n<\/pre>\n<p>7. After booting successfully, update GRUB with:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n# grub2-mkconfig -o \/boot\/efi\/EFI\/fedora\/grub.cfg\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>You know that feeling when everything goes well for a while &#8230; until it doesn&#8217;t ? been using Fedora Workstation 25 and quite satisfied with it, util one late evening when I decided to clean up old kernels and removed every last kernel available. Here&#8217;s how to restore a Fedora Workstation system after you&#8217;ve removed<a class=\"continue-link\" href=\"https:\/\/vaxxi.net\/log\/how-to-rescue-a-fedora-workstation-after-removing-all-available-kernels\/\">&#8230;(Continue Reading)<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[188],"class_list":["post-4729","post","type-post","status-publish","format-standard","hentry","category-gadgets","tag-fedora"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>how to rescue a fedora workstation after removing all available kernels<\/title>\n<meta name=\"description\" content=\"How to rescue a Fedora Workstation 25 system after removing all kernel packages by mistake. Includes booting from a broken GRUB EFI configuration.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/vaxxi.net\/log\/how-to-rescue-a-fedora-workstation-after-removing-all-available-kernels\/\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"VAXXi\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/vaxxi.net\\\/log\\\/how-to-rescue-a-fedora-workstation-after-removing-all-available-kernels\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/vaxxi.net\\\/log\\\/how-to-rescue-a-fedora-workstation-after-removing-all-available-kernels\\\/\"},\"author\":{\"name\":\"VAXXi\",\"@id\":\"https:\\\/\\\/vaxxi.net\\\/log\\\/#\\\/schema\\\/person\\\/94a50a82939211f624b6bf7579d2f752\"},\"headline\":\"how to rescue a fedora workstation after removing all available kernels\",\"datePublished\":\"2017-04-06T20:27:07+00:00\",\"dateModified\":\"2017-04-06T20:34:23+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/vaxxi.net\\\/log\\\/how-to-rescue-a-fedora-workstation-after-removing-all-available-kernels\\\/\"},\"wordCount\":639,\"commentCount\":3,\"keywords\":[\"fedora\"],\"articleSection\":[\"gadgets\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/vaxxi.net\\\/log\\\/how-to-rescue-a-fedora-workstation-after-removing-all-available-kernels\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/vaxxi.net\\\/log\\\/how-to-rescue-a-fedora-workstation-after-removing-all-available-kernels\\\/\",\"url\":\"https:\\\/\\\/vaxxi.net\\\/log\\\/how-to-rescue-a-fedora-workstation-after-removing-all-available-kernels\\\/\",\"name\":\"how to rescue a fedora workstation after removing all available kernels\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/vaxxi.net\\\/log\\\/#website\"},\"datePublished\":\"2017-04-06T20:27:07+00:00\",\"dateModified\":\"2017-04-06T20:34:23+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/vaxxi.net\\\/log\\\/#\\\/schema\\\/person\\\/94a50a82939211f624b6bf7579d2f752\"},\"description\":\"How to rescue a Fedora Workstation 25 system after removing all kernel packages by mistake. Includes booting from a broken GRUB EFI configuration.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/vaxxi.net\\\/log\\\/how-to-rescue-a-fedora-workstation-after-removing-all-available-kernels\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/vaxxi.net\\\/log\\\/how-to-rescue-a-fedora-workstation-after-removing-all-available-kernels\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/vaxxi.net\\\/log\\\/how-to-rescue-a-fedora-workstation-after-removing-all-available-kernels\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"VAXXiNET\",\"item\":\"https:\\\/\\\/vaxxi.net\\\/log\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"how to rescue a fedora workstation after removing all available kernels\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/vaxxi.net\\\/log\\\/#website\",\"url\":\"https:\\\/\\\/vaxxi.net\\\/log\\\/\",\"name\":\"\",\"description\":\"There must be some way out of here\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/vaxxi.net\\\/log\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/vaxxi.net\\\/log\\\/#\\\/schema\\\/person\\\/94a50a82939211f624b6bf7579d2f752\",\"name\":\"VAXXi\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/133cb32f29e4500787dc50b17f325e4d69b66c0126b8fedd4c15a8e850f06b21?s=96&d=mm&r=x\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/133cb32f29e4500787dc50b17f325e4d69b66c0126b8fedd4c15a8e850f06b21?s=96&d=mm&r=x\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/133cb32f29e4500787dc50b17f325e4d69b66c0126b8fedd4c15a8e850f06b21?s=96&d=mm&r=x\",\"caption\":\"VAXXi\"},\"sameAs\":[\"http:\\\/\\\/vaxxi.net\\\/log\\\/\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"how to rescue a fedora workstation after removing all available kernels","description":"How to rescue a Fedora Workstation 25 system after removing all kernel packages by mistake. Includes booting from a broken GRUB EFI configuration.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/vaxxi.net\/log\/how-to-rescue-a-fedora-workstation-after-removing-all-available-kernels\/","twitter_misc":{"Written by":"VAXXi","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/vaxxi.net\/log\/how-to-rescue-a-fedora-workstation-after-removing-all-available-kernels\/#article","isPartOf":{"@id":"https:\/\/vaxxi.net\/log\/how-to-rescue-a-fedora-workstation-after-removing-all-available-kernels\/"},"author":{"name":"VAXXi","@id":"https:\/\/vaxxi.net\/log\/#\/schema\/person\/94a50a82939211f624b6bf7579d2f752"},"headline":"how to rescue a fedora workstation after removing all available kernels","datePublished":"2017-04-06T20:27:07+00:00","dateModified":"2017-04-06T20:34:23+00:00","mainEntityOfPage":{"@id":"https:\/\/vaxxi.net\/log\/how-to-rescue-a-fedora-workstation-after-removing-all-available-kernels\/"},"wordCount":639,"commentCount":3,"keywords":["fedora"],"articleSection":["gadgets"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/vaxxi.net\/log\/how-to-rescue-a-fedora-workstation-after-removing-all-available-kernels\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/vaxxi.net\/log\/how-to-rescue-a-fedora-workstation-after-removing-all-available-kernels\/","url":"https:\/\/vaxxi.net\/log\/how-to-rescue-a-fedora-workstation-after-removing-all-available-kernels\/","name":"how to rescue a fedora workstation after removing all available kernels","isPartOf":{"@id":"https:\/\/vaxxi.net\/log\/#website"},"datePublished":"2017-04-06T20:27:07+00:00","dateModified":"2017-04-06T20:34:23+00:00","author":{"@id":"https:\/\/vaxxi.net\/log\/#\/schema\/person\/94a50a82939211f624b6bf7579d2f752"},"description":"How to rescue a Fedora Workstation 25 system after removing all kernel packages by mistake. Includes booting from a broken GRUB EFI configuration.","breadcrumb":{"@id":"https:\/\/vaxxi.net\/log\/how-to-rescue-a-fedora-workstation-after-removing-all-available-kernels\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/vaxxi.net\/log\/how-to-rescue-a-fedora-workstation-after-removing-all-available-kernels\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/vaxxi.net\/log\/how-to-rescue-a-fedora-workstation-after-removing-all-available-kernels\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"VAXXiNET","item":"https:\/\/vaxxi.net\/log\/"},{"@type":"ListItem","position":2,"name":"how to rescue a fedora workstation after removing all available kernels"}]},{"@type":"WebSite","@id":"https:\/\/vaxxi.net\/log\/#website","url":"https:\/\/vaxxi.net\/log\/","name":"","description":"There must be some way out of here","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/vaxxi.net\/log\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/vaxxi.net\/log\/#\/schema\/person\/94a50a82939211f624b6bf7579d2f752","name":"VAXXi","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/133cb32f29e4500787dc50b17f325e4d69b66c0126b8fedd4c15a8e850f06b21?s=96&d=mm&r=x","url":"https:\/\/secure.gravatar.com\/avatar\/133cb32f29e4500787dc50b17f325e4d69b66c0126b8fedd4c15a8e850f06b21?s=96&d=mm&r=x","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/133cb32f29e4500787dc50b17f325e4d69b66c0126b8fedd4c15a8e850f06b21?s=96&d=mm&r=x","caption":"VAXXi"},"sameAs":["http:\/\/vaxxi.net\/log\/"]}]}},"_links":{"self":[{"href":"https:\/\/vaxxi.net\/log\/wp-json\/wp\/v2\/posts\/4729","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vaxxi.net\/log\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vaxxi.net\/log\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vaxxi.net\/log\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vaxxi.net\/log\/wp-json\/wp\/v2\/comments?post=4729"}],"version-history":[{"count":5,"href":"https:\/\/vaxxi.net\/log\/wp-json\/wp\/v2\/posts\/4729\/revisions"}],"predecessor-version":[{"id":4734,"href":"https:\/\/vaxxi.net\/log\/wp-json\/wp\/v2\/posts\/4729\/revisions\/4734"}],"wp:attachment":[{"href":"https:\/\/vaxxi.net\/log\/wp-json\/wp\/v2\/media?parent=4729"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vaxxi.net\/log\/wp-json\/wp\/v2\/categories?post=4729"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vaxxi.net\/log\/wp-json\/wp\/v2\/tags?post=4729"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}