{"id":4146,"date":"2015-01-27T19:11:38","date_gmt":"2015-01-27T11:11:38","guid":{"rendered":"http:\/\/rmohan.com\/?p=4146"},"modified":"2015-01-27T19:12:01","modified_gmt":"2015-01-27T11:12:01","slug":"the-file-bootgrubstage1-not-read-correctly","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=4146","title":{"rendered":"The file \/boot\/grub\/stage1 not read correctly"},"content":{"rendered":"<p>The file \/boot\/grub\/stage1 not read correctly<br \/>\nAfter pxe booting a server and installing linux from a cpio archive, grub failed to load using the grub-install command.  The error presented was as follows:<\/p>\n<p>root@pxe:~# mkdir \/target<br \/>\nroot@pxe:~# mount \/dev\/sda1 \/target<br \/>\nroot@pxe:~# chroot \/target<br \/>\nroot@pxe:~# grub-install \/dev\/sda<br \/>\nThe file \/boot\/grub\/stage1 not read correctly.<br \/>\nSince command line didn&#8217;t work, I tried installing grub via the grub shell:<\/p>\n<p>root@pxe:~# grub<\/p>\n<p>    GNU GRUB  version 0.97  (640K lower \/ 3072K upper memory)<\/p>\n<p> [ Minimal BASH-like line editing is supported.  For the first word, TAB<br \/>\n   lists possible command completions.  Anywhere else TAB lists the possible<br \/>\n   completions of a device\/filename.]<br \/>\ngrub> root (hd0,0)<br \/>\nroot (hd0,0)<br \/>\n Filesystem type is ext2fs, partition type 0xfd<br \/>\ngrub> setup (hd0)<br \/>\nsetup (hd0)<br \/>\n Checking if &#8220;\/boot\/grub\/stage1&#8221; exists&#8230; no<br \/>\n Checking if &#8220;\/grub\/stage1&#8221; exists&#8230; no<\/p>\n<p>Error 2: Bad file or directory type<br \/>\ngrub><br \/>\nThis too failed, with a different error message.  You may have noticed the first error message given while attempting to install grub with the grub-install command yielded:<\/p>\n<p>The file \/boot\/grub\/stage1 not read correctly<\/p>\n<p>While attempting to install grub via the grub shell yielded:<\/p>\n<p>Error 2: Bad file or directory type<\/p>\n<p>After some research, grub only works on an inode size of 128, and the pxe system formatted the file system with an inode size of 256.<\/p>\n<p>root@pxe:~# tune2fs -l \/dev\/sda1 | grep -i &#8216;inode size&#8217;<br \/>\nInode size:               256<br \/>\nThe system being reimaged was an older legacy system, and the pxe system had been upgraded months prior.  Having remembered this, I compared versions of mke2fs and found that the upgraded version creates 256-byte inodes by default, where the older version was 128.  To correct this, I updated the pxe imaging scripts responsible for formatting the disks with the -I option as follows:<\/p>\n<p>root@pxe:~# mke2fs -L \/ -I 128 -F -j -O dir_index \/dev\/sda1<br \/>\nOnce recreating the file system with a defined inode size of 128, the grub-install command worked successfully.<\/p>\n<p>root@pxe:~# tune2fs -l \/dev\/sda1 | grep -i &#8216;inode size&#8217;<br \/>\nInode size:               128<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The file \/boot\/grub\/stage1 not read correctly After pxe booting a server and installing linux from a cpio archive, grub failed to load using the grub-install command. The error presented was as follows:<\/p>\n<p>root@pxe:~# mkdir \/target root@pxe:~# mount \/dev\/sda1 \/target root@pxe:~# chroot \/target root@pxe:~# grub-install \/dev\/sda The file \/boot\/grub\/stage1 not read correctly. Since command line didn&#8217;t [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,17],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/4146"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4146"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/4146\/revisions"}],"predecessor-version":[{"id":4147,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/4146\/revisions\/4147"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4146"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4146"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4146"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}