{"id":351,"date":"2009-04-30T14:55:31","date_gmt":"2009-04-30T09:25:31","guid":{"rendered":"http:\/\/brainstorms.in\/?p=351"},"modified":"2009-04-30T14:55:31","modified_gmt":"2009-04-30T09:25:31","slug":"remastering-ubuntu-cd-exploring-initrdgz","status":"publish","type":"post","link":"https:\/\/brainstorms.in\/?p=351","title":{"rendered":"Remastering Ubuntu CD : Exploring initrd.gz"},"content":{"rendered":"<p>( This document was written in connection with\u00a0 Ubuntu Re mastering workshop held at College of Engineering Attingal on 25th of April 2009 . See this <a href=\"http:\/\/brainstorms.in\/?p=272\">post<\/a> )<\/p>\n<p>On an Ubuntu CD kernel and the associated initrd.gz are found under casper directory.\u00a0 initrd.gz is an\u00a0 initial ram image\u00a0 which helps the kernel to boot the system and mount the squashfs image.<br \/>\nYou can\u00a0 tweak\u00a0 initrd.gz\u00a0\u00a0 with\u00a0 the \u00a0 following steps.<\/p>\n<p>Mount the ubuntu cdrom\/ iso image<\/p>\n<p># mount -o loop ubuntu.iso \/cdrom<\/p>\n<p>Create a temporary\u00a0 directory and change to it.<\/p>\n<p># mkdir\u00a0 initrd_remaster<\/p>\n<p># cd initrd_remaster<\/p>\n<p>2) Copy initrd.gz\u00a0\u00a0\u00a0 and unzip it<\/p>\n<p># cp \/cdrom\/casper\/initrd.gz \u00a0 .<\/p>\n<p>Unzip it<\/p>\n<p># gunzip initrd.gz<br \/>\nThe resulting file is a cpio archive<br \/>\nUncompressed it\u00a0 with the following command<br \/>\n# cpio -i\u00a0 &lt; initrd<\/p>\n<p>You will get several folders\u00a0 and a file named init\u00a0 after this.<\/p>\n<p>bin\u00a0 conf\u00a0 etc\u00a0 init\u00a0 lib\u00a0 sbin\u00a0 scripts\u00a0 usr\u00a0 var<\/p>\n<p>If you watch system start up carefully,\u00a0 you can\u00a0 see\u00a0\u00a0 initrd.gz getting uncompressed.\u00a0 The system starts executing the script named init immediately after that.\u00a0 This script will in turn\u00a0 find out\u00a0 the actual root \u00a0 file system (\/) a, mount it and then chroot to\u00a0 the actual file system.\u00a0You can open up init in an editor and tweak it. \u00a0\u00a0\u00a0 There are several\u00a0 other scripts which are\u00a0 called from init.<\/p>\n<p>Finally, you can use cpio and gzip to recreate initrd.gz<\/p>\n<p># find .\/ | cpio -H newc -o &gt; ..\/initrd<\/p>\n<p style=\"margin-bottom: 0cm;\"># cd ..<\/p>\n<p style=\"margin-bottom: 0cm;\"># gunzip intrd.gz<\/p>\n<p style=\"margin-bottom: 0cm;\">You can replace the original initrd.gz in Casper directory with the modified  initrd image<\/p>\n<p style=\"margin-bottom: 0cm;\">\n","protected":false},"excerpt":{"rendered":"<p>( This document was written in connection with\u00a0 Ubuntu Re mastering workshop held at College of Engineering Attingal on 25th of April 2009 . See this post ) On an Ubuntu CD kernel and the associated initrd.gz are found under casper directory.\u00a0 initrd.gz is an\u00a0 initial ram image\u00a0 which helps the kernel to boot the&hellip; <a href=\"https:\/\/brainstorms.in\/?p=351\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Remastering Ubuntu CD : Exploring initrd.gz<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-351","post","type-post","status-publish","format-standard","hentry","category-gnulinux"],"_links":{"self":[{"href":"https:\/\/brainstorms.in\/index.php?rest_route=\/wp\/v2\/posts\/351","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/brainstorms.in\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/brainstorms.in\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/brainstorms.in\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/brainstorms.in\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=351"}],"version-history":[{"count":4,"href":"https:\/\/brainstorms.in\/index.php?rest_route=\/wp\/v2\/posts\/351\/revisions"}],"predecessor-version":[{"id":355,"href":"https:\/\/brainstorms.in\/index.php?rest_route=\/wp\/v2\/posts\/351\/revisions\/355"}],"wp:attachment":[{"href":"https:\/\/brainstorms.in\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=351"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/brainstorms.in\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=351"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/brainstorms.in\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=351"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}