{"id":186,"date":"2013-11-04T01:49:31","date_gmt":"2013-11-04T01:49:31","guid":{"rendered":"http:\/\/blogs.gentoo.org\/lu_zero\/?p=186"},"modified":"2013-11-04T01:52:56","modified_gmt":"2013-11-04T01:52:56","slug":"early-boot-fun","status":"publish","type":"post","link":"https:\/\/blogs.gentoo.org\/lu_zero\/2013\/11\/04\/early-boot-fun\/","title":{"rendered":"Early boot fun"},"content":{"rendered":"<p>Just few notes spurted from a discussion with a friend regarding why he feels we suck badly.<\/p>\n<h3>Early boot<\/h3>\n<p>Let&#8217;s make a quite rough description on how booting could work:<\/p>\n<ul>\n<li>Imagine you are the kernel, you just found your rootfs, managed to run your init and you are happy. That&#8217;s probably the earliest we care.<\/li>\n<li>Init got called and starts running some scripts, maybe checking the rootfs consistency before remounting r\/w, maybe checking the other essential mount points before mounting them or maybe start the device manager first and then checking what is going to mount, assuming what is essential still requires some modules loaded and that the device manager will do.<\/li>\n<li>Move further and set up the network<\/li>\n<li>Maybe now mount the mount points that require the network (nfs?)<\/li>\n<li>Now get the other daemons up and running, maybe in parallel, maybe bring up some graphical login.<\/li>\n<\/ul>\n<p>Now let&#8217;s see who are the actors: <strong>rootfs<\/strong>, <strong>init<\/strong>, <strong>device-manager<\/strong> and maybe incidentally <strong>volume-manager <\/strong>and\u00a0<strong>networking<\/strong>.<\/p>\n<p>Ideally your rootfs should contain<\/p>\n<ul>\n<li>anything required by <strong>init<\/strong> to run, easy, <strong>init<\/strong> should be as small as possible to make sure this single point of failure really hard to fail.<\/li>\n<li>anything required by the <strong>device-manager<\/strong> to load modules, should be a no brainer, well, maybe if you want your modules compressed with some new or exotic compressor because it is &#8220;faster&#8221; that way, you have to fit it in the <strong>rootfs<\/strong>.<\/li>\n<li>If your essential mountpoints require a <strong>volume-manager<\/strong> the same applies, lvm can require something weird depending on the setup so either you link it statically or you have to put it again where it is reachable, same could be said for any kind of advanced crypto at volume leve.<\/li>\n<li>We discussed about mount and again we could have fuse-fs using a scripting language or other stuff that make issuing mount a little more complex that we would expect (and again fs-level crypto happening in the userspace)<\/li>\n<li>The network would just need some modules loaded right? Wrong, it might need some special daemons doing any kind of bizantine authentication, and if you are really looking for pain you could be willing to netmount those mentioned file systems or even do volume management over bizantine network (ok there is a limit in this kind of perversion and we are just halfway).<\/li>\n<li>Once everything is mounted the rest of the system can be brought up w\/out much qualms.<\/li>\n<\/ul>\n<p>So in the end your <strong>rootfs<\/strong> can be quite fat contain full copies of python so you can mount that funny file system, have lots of lovely brittle deps because you thought <strong>NetworkManager<\/strong> is the only way to get the network up and meanwhile that having some important stuff (e.g. \/var) netmounted is all the rage.<\/p>\n<h3>Fun (aka pain)<\/h3>\n<p>So in short your <strong>rootfs<\/strong> could be as big as a compact live distribution and have as many moving parts as one (or more), well it could be just your distribution if you do not keep everything in a separated mount point.<\/p>\n<p>Some years ago that was one of the suggested ways, you keep essential stuff in \/ and then every other root mountpoint would have its partition, maybe using some advanced stuff just because.<\/p>\n<p>Then you get told that the right place in which you have to fit all discussed above has to be something called initramfs and obviously tell the kernel about it.<\/p>\n<p>Probably nobody would be that crazy to end up with the far corner case, so the initramfs would have to copy just few (20+??) libraries and some (30+?!) binaries in the normal case and you have to keep it synced up properly (joy).<\/p>\n<p>Most people could live happy with just a statically linked lvm and udev living in a small partition easy to mount and that would be the start and the end for them, but certain wise guys will tell you that static linking is harmful, the whole concept is broken anyway since our bluetooth subsystem requires lots of userspace and then you&#8217;d be w\/out a keyboard in case something goes wrong (so you should shove bluez and happy deps in your initramfs\/rootfs?).<\/p>\n<h3>Summing up<\/h3>\n<p>There are easy, simple and working solution for just some realistic scenarios, but not covering everything that&#8217;s possible.<\/p>\n<p>There are more complex, brittle and error prone ones that might cover everything and more (and maybe still fail in some basic situations).<\/p>\n<p>The fact lots of lemmings flocks over the complex\/brittle because the guy with the largest mouth is the best speaker is sad, overly sad.<\/p>\n<p>That said if you were happily using since 10 years ago a lvm setup as described by our guides of the time and now you are afraid that your next userspace update your system will break horribly if you don&#8217;t go through the hoops of making an initramfs, that won&#8217;t work for you out of box and will force you to modify your bootloader or do some other time consuming work:<strong><\/strong><\/p>\n<p><strong>I&#8217;m sorry.<br \/>\n<\/strong><\/p>\n<p>(Luckily somebody prepared a portage hook to prevent some breakages https:\/\/gist.github.com\/mansr\/7289969 not all of them but the most glaring are covered)<\/p>\n<p>Incidentally, you can still pester us, help us getting better programs (e.g. contribute to eudev, kmod, lvm and everything else you use) and take an active part in the community and hopefully protect your simple and working solutions.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Just few notes spurted from a discussion with a friend regarding why he feels we suck badly. Early boot Let&#8217;s make a quite rough description on how booting could work: Imagine you are the kernel, you just found your rootfs, managed to run your init and you are happy. That&#8217;s probably the earliest we care. &hellip; <a href=\"https:\/\/blogs.gentoo.org\/lu_zero\/2013\/11\/04\/early-boot-fun\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Early boot fun<\/span><\/a><\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[3],"tags":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p1aGWH-30","_links":{"self":[{"href":"https:\/\/blogs.gentoo.org\/lu_zero\/wp-json\/wp\/v2\/posts\/186"}],"collection":[{"href":"https:\/\/blogs.gentoo.org\/lu_zero\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.gentoo.org\/lu_zero\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.gentoo.org\/lu_zero\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.gentoo.org\/lu_zero\/wp-json\/wp\/v2\/comments?post=186"}],"version-history":[{"count":1,"href":"https:\/\/blogs.gentoo.org\/lu_zero\/wp-json\/wp\/v2\/posts\/186\/revisions"}],"predecessor-version":[{"id":187,"href":"https:\/\/blogs.gentoo.org\/lu_zero\/wp-json\/wp\/v2\/posts\/186\/revisions\/187"}],"wp:attachment":[{"href":"https:\/\/blogs.gentoo.org\/lu_zero\/wp-json\/wp\/v2\/media?parent=186"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/lu_zero\/wp-json\/wp\/v2\/categories?post=186"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/lu_zero\/wp-json\/wp\/v2\/tags?post=186"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}