{"id":621,"date":"2014-06-21T23:23:55","date_gmt":"2014-06-22T03:23:55","guid":{"rendered":"http:\/\/blog.fritzhardy.com\/?p=621"},"modified":"2014-06-24T11:26:40","modified_gmt":"2014-06-24T15:26:40","slug":"working-dracut","status":"publish","type":"post","link":"https:\/\/blog.fritzhardy.com\/?p=621","title":{"rendered":"Working Dracut"},"content":{"rendered":"<p>Dracut is an initramfs infrastructure, as well as the name of tool needed to create initramfs images.  It is also the name of the prompt\/environment made available at boot time by choice or by error, allowing for troubleshooting of boot-time problems.<\/p>\n<p><strong>Building Initramfs Images<\/strong><\/p>\n<p>It always pays to make backups:<\/p>\n<pre>\r\ncd \/boot\r\ncp -a initramfs-3.12.8-300.fc20.i686.img initramfs-3.12.8-300.fc20.i686.img.backup\r\n<\/pre>\n<p>The dracut tool is used to build initramfs images:<\/p>\n<pre>\r\ndracut -f \/boot\/initramfs-3.12.8-300.fc20.i686.img 3.12.8-300.fc20.i686\r\n<\/pre>\n<p>Images are best built from within the intended root of the Linux system, and the tool can be run on a live system with no issues. If the system is in a state where this is unattainable, it is possible to build a clean environment by assembling the necessary mounts in rescue mode. Do not select \u00e2\u20ac\u0153find drives automatically,\u00e2\u20ac\u009d we will do so manually:<\/p>\n<pre>\r\nmkdir \/mnt\/sysimage\r\nvgchange -ay\r\nmount \/dev\/mapper\/Volume00-root\r\nmount \/dev\/sda1 \/mnt\/sysimage\/boot\r\nmount --bind \/proc \/mnt\/sysimage\/proc\r\nmount --bind \/dev \/mnt\/sysimage\/dev\r\nmount --bind \/sys \/mnt\/sysimage\/sys\r\nchroot \/mnt\/sysimage\r\n<\/pre>\n<p>NOTE: Devices holding boot and root will vary from system to system.<\/p>\n<p>Now run dracut.<\/p>\n<p><strong>The Dracut Shell<\/strong><\/p>\n<p>If the boot process fails due to an issue with the initial ram disk, we will likely be dropped to the dracut shell (this may require adding rd.shell as a kernel argument).  <\/p>\n<p>For example, failure due to a missing volume:<\/p>\n<pre>\r\nWarning: Could not boot.\r\nWarning: \/dev\/mapper\/luks-cc7e78ee-87a9-4ad0-9c82-31de01389b34 does not exist\r\n<\/pre>\n<p>The beauty of the dracut prompt is that we have nearly the full flexibility of Linux at our disposal, with whatever tools exist in the initramfs image.<\/p>\n<p>This particular error is something I have commonly experienced when switching root, and is probably due to the systemd setup within the initramfs specifically looking for a device that did not exist when we created it (for instance, if we ran dracut while not within the final resting place of root).<\/p>\n<p>We can see what is actually contained within the initrams image:<\/p>\n<pre>\r\nlsinitrd \/boot\/initramfs-3.12.8-300.fc20.i686.img\r\n<\/pre>\n<p>If a volume cannot be found, it is likely there is no entry for it in etc\/systemd\/system\/initrd.target.wants.  We can attempt to urge things along manually:<\/p>\n<pre>\r\nlvm vgchange -ay\r\ncryptsetup luksOpen \/dev\/mapper\/Volume00-root luks-cc7e78ee-87a9-4ad0-9c82-31de01389b34\r\nEnter passphrase for \/dev\/mapper\/Volume00-root:\r\nexit\r\n<\/pre>\n<p>If this now boots the system, the path forward is to re-generate the initramfs image correctly, which usually entails doing so from within the appropriate root (as above).<\/p>\n<p>Finally, here is a tidbit showing what kinds of things can be done for gathering intelligence for later followup:<\/p>\n<pre>\r\ndebug=$(lvm pvdisplay; lvm vgdisplay; lvm lvdisplay; blkid; dmesg)\r\nlvm vgchange -a y\r\ncryptsetup luksOpen \/dev\/mapper\/Volume00-root luks-cc7e78ee-87a9-4ad0-9c82-31de01389b34\r\nEnter passphrase for \/dev\/mapper\/Volume00-root:\r\nmount \/dev\/mapper\/luks-cc7e78ee-87a9-4ad0-9c82-31de01389b34 \/mnt\r\necho \"$debug\" &gt; \/mnt\/dracut.debug\r\n<\/pre>\n<p>NOTE: All this does is set an environment variable &#8220;debug&#8221; to the output of a bunch of commands, then activate storage somewhere to store that output, in this case showing how it is even possible to use a crypto-volume.  Perhaps it is USB or simple volume instead.<\/p>\n<p><strong>Resources<\/strong><\/p>\n<ul>\n<li>http:\/\/wiki.centos.org\/TipsAndTricks\/CreateNewInitrd<\/li>\n<li>http:\/\/lists.centos.org\/pipermail\/centos\/2013-March\/133604.html<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Dracut is an initramfs infrastructure, as well as the name of tool needed to create initramfs images. It is also the name of the prompt\/environment made available at boot time by choice or by error, allowing for troubleshooting of boot-time problems. Building Initramfs Images It always pays to make backups: cd \/boot cp -a initramfs-3.12.8-300.fc20.i686.img [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-621","post","type-post","status-publish","format-standard","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/blog.fritzhardy.com\/index.php?rest_route=\/wp\/v2\/posts\/621","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.fritzhardy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.fritzhardy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.fritzhardy.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.fritzhardy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=621"}],"version-history":[{"count":8,"href":"https:\/\/blog.fritzhardy.com\/index.php?rest_route=\/wp\/v2\/posts\/621\/revisions"}],"predecessor-version":[{"id":645,"href":"https:\/\/blog.fritzhardy.com\/index.php?rest_route=\/wp\/v2\/posts\/621\/revisions\/645"}],"wp:attachment":[{"href":"https:\/\/blog.fritzhardy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=621"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.fritzhardy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=621"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.fritzhardy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=621"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}