Reese Knowledgebase

The file /boot/grub/stage1 not read correctly

View Kristian Reese's profile on LinkedIn


If you like this article, please +1 or Recommend via FB with the provided buttons above:

Article ID: 113
by: Reese K.
Posted: 02 Jul, 2013
Last updated: 02 Jul, 2013
Views: 27310

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:

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't work, I tried installing grub via the grub shell:

root@pxe:~# grub
 
    GNU GRUB  version 0.97  (640K lower / 3072K upper memory)
 
 [ Minimal BASH-like line editing is supported.  For the first word, TAB
   lists possible command completions.  Anywhere else TAB lists the possible
   completions of a device/filename.]
grub> root (hd0,0)
root (hd0,0)
 Filesystem type is ext2fs, partition type 0xfd
grub> setup (hd0)
setup (hd0)
 Checking if "/boot/grub/stage1" exists... no
 Checking if "/grub/stage1" exists... no
 
Error 2: Bad file or directory type
grub>

This 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:

The file /boot/grub/stage1 not read correctly

While attempting to install grub via the grub shell yielded:

Error 2: Bad file or directory type

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.

root@pxe:~# tune2fs -l /dev/sda1 | grep -i 'inode size'
Inode size:               256

The 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:

root@pxe:~# mke2fs -L / -I 128 -F -j -O dir_index /dev/sda1

Once recreating the file system with a defined inode size of 128, the grub-install command worked successfully.

root@pxe:~# tune2fs -l /dev/sda1 | grep -i 'inode size'
Inode size:               128

This article was:   Helpful | Not Helpful
Prev   Next
Extract contents of initrd     ip_conntrack: table full, dropping packet

Showing: 1-5 of 5  
Comments
Anonymous | 01 Oct, 2014 06:24 AM
I would never thought of that.
Thank you for the clear and concise explanation!
Jakub | 20 Oct, 2014 10:09 AM
Hello,
I have also encountered error "stage1 not read correctly". I have two disks /dev/sda & /dev/sdb. My native root is on /dev/sda6, and I want to move to /dev/sdb6 and boot from /dev/sdb. I managed to boot & login to /dev/sdb6 only once, then I have run command update-grub-from-legacy and then I couldn't login again. I get "GRUB Loading stage 1.5... Error 15". As per manpage of mke2fs, paramter -I (last sentence): "It is not possible to change this value after the filesystem is created." This requires me to format my partition which I don't want to do, especially where I have ext4 and would like to keep that way.
I know I have to install bootloader into /dev/sdb but either I cannot do this or don't know how to do this, becuase maybe I do it wrong.
ktreese | 21 Oct, 2014 10:49 AM
Jakub,

What does tune2fs show as the Inode size for your /dev/sdb6 partition? Also, if /dev/sda is still intact, you can compare tune2fs output between /dev/sda and /dev/sdb. If they are different, you can try formatting /dev/sdb with the appropriate Inode size, then use dd to copy /dev/sda to /dev/sdb.

Hope that helps
dave | 24 Apr, 2015 07:37 PM
The same GRUB failure can happen if you do a fresh OS install and let it pick the (fairly) new ext4 file system for the /boot partition. It appears the default ext4 inode size is not compatible...

I had to reformat the /boot partition as ext2 (or ext3) to get legacy GRUB to install and work.
Nuno Mourinho | 10 Oct, 2015 07:57 AM
3 years later, this article saved me and my server! Thank you very much (Nuno Mourinho, Portugal)
Prev   Next
Extract contents of initrd     ip_conntrack: table full, dropping packet

RSS