What to do when I get an "attempt to read or write outside of disk 'hd0'" error and Boot Repair does not solve the problem?
Locate the partition in which linux is present with the help of following technique
grub rescue > ls
(hd0) (hd0, msdos9)
grub rescue > ls (hd0,msdos9)/
grub rescue > ls (hd0,msdos8)/
grub rescue > ls (hd0,msdos5)/ # suppose this is root and bootloader of linux
grub rescue > ls (hd0,msdos5)/
grub rescue > set root=(hd0,msdos5)
grub rescue > set prefix=(hd0,msdos5)/boot/grub
grub rescue > insmod normal
grub rescue > normal
Now, system's boot menu appears. Boot into linux.
sudo update-grub
sudo grub-install /dev/sda # If the drive is hd0 the equivalent is sda, if it's hd1 then use sdb
This fixes boot loader.
For anyone else that has this issue:
This was happening to me where a new install or grub repair would work and reboot, but the next time I rebooted, it would get this same "attempt to read error". Most times I would get a kernel panic and the computer would need a hard restart.
I followed some advice and did a new install using the advanced options (don't use the "erase disk and install ubuntu") using these partition settings:
- Create a 1 GB (1024 MB) ext4 partition on the beginning of the disk; mounted in "/boot"
- Create your desired install space in ext4 mounted in "/" MINUS your swap area
- Use remaining space for swap. (ALL partitions will be primary)
- In the boot install dropdown menu, select your "/boot" partition. Not the defaulted drive root!
It can be easily solved through the Grub rescue prompt. The first answer isn't quite complete and I got the same error at first. Here is how it works:
1st we need to find the primary partition. This will be where the essential files needed for linux to boot will reside, so we enter this -
Grub> ls
You should now see a list comparable to (hd0) (hd0,msdos5) (hd0,msdos1). Note that you may have different partitions than myself, as well as multiple drives, but the process is the same.
Now search the partitions to find the primary -
Grub> ls (hd0)
Grub> ls (hd0,msdos5)
Grub> ls (hd0,msdos1)
Until grub outputs either a list of files on that partition or shows the filesystem type and date of last modification.
2nd we need to set up a few things once we've found our primary partition -
Grub> set prefix=(hd0,msdos1)/boot/grub
Grub> set root=(hd0,msdos1)
Grub> set
Once the last set command is executed Grub will output a list of different parameters. Now lets check that we've set the correct root and prefix -
Grub> ls /boot
Grub should output a list of files contained within /boot.
3rd we need to set the mount point and load the kernel -
Grub> linux /vmlinuz root=/dev/sda1
Grub> initrd /initrd.img
And lastly we boot the system -
Grub> boot
If you end up booting into the busybox shell, simply enter fsck /dev/sda1
. After that just enter exit
and your system will boot normally.