45

I tried to install Xubuntu 13.10 on an older computer. I noticed some difficulties during installation that may be relevant to my problems. Notably:

  1. The screen resolution was extremely low. The windows were much larger than the screen and I had to move them around to get to the "Next" button.

  2. The mouse cursor was a blur of colours that was flashing all the time.

The installation finished and I tried to reboot the computer. Immediately I got:

error: attempt to read or write outside of disk 'hd0'. 
Entering rescue mode... 
grub rescue>

I made a Boot Repair USB disk, booted it and chose the default repair. The application told me that the problem is repaired and that If this does not solve my problem I should show this link to someone who can help me.

What should I do next? I already tried to install Ubuntu and Xubuntu, both with no success.

EDIT:

I found a workaround.

  1. Insert the Xubuntu live USB
  2. Select "try Xubuntu"
  3. In the settings menu select "install Xubuntu"

This fixed the problem for me. Since it is solved I cannot test the answer.

Zanna
  • 70,465
  • (near-)duplicate of http://askubuntu.com/questions/229715/booting-ubuntu-failure-error-attempt-to-read-or-write-outside-of-disk-hd0 – Reinier Post Oct 27 '16 at 12:25

9 Answers9

40

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.

vikrant
  • 807
user223882
  • 663
  • 8
  • 10
  • 19
    I don't see what this should do. You specifiy a hell of a lot of commands, none of which makes any sense to me. Please add a little bit more explaining text! Why do you "count down" from msdos9 to 5? How do you see that "this is linux"?? In my case it shows (hd0,msdos1)! I cannot "count down" - and once I set root and prefix and do "insmod normal" I get exactly the same error message as before. Sorry. This is not an answer anybody could work with. :( – Zordid Aug 23 '14 at 11:50
  • 26
    As soon as I type insmod normal I get the message again: "error: attempt to read or write outside of partition." – user643722 Nov 11 '14 at 22:12
  • 3
    you say "suppose this is linux" without saying how I can tell which one linux is. Whenever I type insmod normal, I get back "error: unknown filesystem", this is not working for me. Also, can you explain why this happens in the first place? – msknapp Jan 04 '15 at 21:30
  • I feel like having my Ubuntu and bootloader stored on my solid state drive, and having my swap and other partitions on a mag drive caused this (on a windows update) but simply using insmod normal and then normal brought back up my boot menu and allowed normal operation. – Gus Crawford Mar 29 '15 at 13:49
  • 1
    The best I've gotten is another grub prompt. The menu never pops up. – jbo5112 May 23 '15 at 23:45
  • 2
    I agree with @Zordid - just a list of cryptic commands without an explanation of what these commands do is not only not sufficient, it could be potentially dangerous. – jpp1 Jul 05 '16 at 10:42
  • I didn't understand how the commands here worked to help resolve this issue. Also, there's no explanation given so I avoided using this to fix my problem as I'm not sure what the above is doing. – rayryeng Jul 27 '16 at 01:24
  • to find out which one is linux, just add a "/" after the commands, like this: ls (hd0,1)/ , also you don't need to write msdos(or gpt). but examining the output of ls command, you can tell which partition is linux, and which partition contains grub boot loader etc. also note that the swap partition might say "unknown file system" – vikrant Nov 23 '17 at 14:53
  • 1
    also note that if you have created separate partitions for root and boot, then you will have to assign root to the correct partition. the partition which contains the files like var, etc, is the root partition, and the partition which contains the file "grub" is the one you have to assign to prefix. also make sure the path is correct, you might have to omit "boot" which setting the prefix path here: "set prefix=(hd0,msdos5)/boot/grub". i have tried this solution and it worked for me, i restored my laptop when neither windows not linux was loading. – vikrant Nov 23 '17 at 15:21
  • these are the commands which i used: ls, ls (hd0,1)/, ls (hd0,2), ls (hd0,3). after that i examined the output, msdos1 was bootloader which contained grub, and msdos 3 was root. also msdos 2 was swap partitio. so i used following commands: set root=(hd0,msdos3), set prefix=(hd0,msdos1)/grub, insmod normal, normal. after that ubuntu loaded fine, and then i opened a terminal and typed:sudo update-grub, sudo grub-install /dev/sda – vikrant Nov 23 '17 at 15:25
  • I find the discussion in the comments here quite unhelpful. grub rescue > is obviously a prompt. There's not a "hell of a lot of commands" here - there are three: ls, set, insmod. The other one, normal, is loaded by insmod... vikrant didn't say this was a copy-paste guide - he said it was a technique. It doesn't seem like anyone even TRIED to follow along with what was going on. He gave you a technique and not a set of instructions because it is likely going to be different on all of your machines. – nevelis Oct 17 '18 at 08:01
  • 1
    Sure, don't use a solution if you don't understand it. But if you think about things for a minute, this isn't that complicated. List through the permissions (you know what ls does, right?), look at its output until you see your Linux filesystem root in the output (boot, bin, etc, usr, tmp, var etc etc...), boot normally, and re-install grub to the beginning of /dev/sda. Quick and clean, and unlike the other answer, doesn't require you to reinstall. This happened during an upgrade for me (because the boot loader got moved). So it is indeed an answer that someone could work with. Thanks. – nevelis Oct 17 '18 at 08:05
  • This fixes my issue every time, but i think this is caused by an underlying issue with installing linux on older machines, specifically an issue with older BIOS. Roughly 50% of the time i boot my older laptop installed with linux mint cinnamon I get this error. Still trying to tackle this root cause, but i am using this solution in the meantime. – a25bedc5-3d09-41b8-82fb-ea6c353d75ae Feb 21 '20 at 14:12
  • Tried, doesn't work, got the same error back, also not explained well. – Pablo Pazos May 26 '20 at 17:45
31

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:

  1. Create a 1 GB (1024 MB) ext4 partition on the beginning of the disk; mounted in "/boot"
  2. Create your desired install space in ext4 mounted in "/" MINUS your swap area
  3. Use remaining space for swap. (ALL partitions will be primary)
  4. In the boot install dropdown menu, select your "/boot" partition. Not the defaulted drive root!
Andrew
  • 311
  • 2
  • 3
  • This worked for me when the commands in the accepted answer were getting "Filesystem is unrecognised". I ended up using the same set of file systems, but this small dedicated /boot partition was what fixed my problem. Thanks. – GregHNZ Feb 04 '15 at 01:53
  • 1
    It seems this also works if /boot is the only primary partition. – Aaron Mason Jun 15 '16 at 06:59
  • Joined this site just to say that this also worked for me. The small boot partition was what I needed to get this to work when placing Ubuntu on an external HDD. Thanks! – rayryeng Jul 27 '16 at 01:25
  • 1
    It helped me: I had a big(>5TB) / partition, adding small /boot partition fixed the issue – neutrinus Oct 04 '16 at 15:26
  • 1
    Can one do this without deleting the existing partition? I have a large partition with all of my data starting at the beginning of the disk. – pir May 21 '17 at 23:24
  • This is the answer! You saved me more red eyes. Cheers!!! – droid-zilla Nov 01 '18 at 02:32
  • When I do this, it says I have no EFI system partition and cannot continue. – Scorb Nov 01 '23 at 15:36
10

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.

muru
  • 197,895
  • 55
  • 485
  • 740
  • 2
    When I type "linux /vmlinuz root=/dev/sda1" I receive the following error: Unknown command "linux". I've also tried specifying /vmlinuz-5.8.0-63-generic. – Tmanok Jul 29 '21 at 04:59
  • 2
    same Unknown command 'linux' – ulkas Aug 15 '21 at 17:00
  • 1
    my command prompt states grub rescue> instead of the above Grub> – ulkas Aug 15 '21 at 17:04
  • I haven't had the issue with unknown command but I also used insmod linux first. However I again get the error "attempt to read or write outside of disk 'hd0' on the Linux command. – Alexander Taubenkorb Jul 21 '23 at 08:04
4

I had this issue when trying to install Ubuntu 18 Server and Xubuntu 18 on a Dell server. Selecting UEFI instead of Legacy in the BIOS menu fixed it.

arzach84
  • 161
  • That did the trick for me on a Dell R710 with Linux Mint 20. Did not need to do any of the "ls (hd0)" type of things shown in other posts. (Which did not work for me) So this was so much easier! – Klom Dark Aug 25 '20 at 00:05
  • Instead I'm brought to a yellow EFI shell. Perhaps I will reinstall with UEFI enabled. – Tmanok Jul 29 '21 at 04:59
3

After searching lots of hours I tried this solution and it works well, to reinstall the kernel:

sudo dpkg --configure -a
sudo apt-get install --reinstall linux-image-$(uname -r)
wjandrea
  • 14,236
  • 4
  • 48
  • 98
Zeyad Assem
  • 159
  • 2
3

I solved this problem by moving my Linux partition close to begining of hard disk. When linux partition was at the end of my 120 Gb HDD (40 Gb from end) I got this problem. No one solution didn't work. After moving linux partition to space from 40Gb to 80Gb problem disappeared.

John
  • 31
  • 1
1

This is random problem.

In this case better solution is to create /boot folder in its own partition

Details are here

Eugen Konkov
  • 796
  • 9
  • 18
0

I am achieving this issue when I has used vmdk disk from OVA virtual machine package in virt-manager/QEMU/KVM. The virtual machine was failing with this error message.

Solution was to convert vmdk into qcow2:

qemu-img convert -O qcow2 MyAppliance-disk1.vmdk MyAppliance.qcow2

And to use converted image in virt-manager instead.

Tharok
  • 334
  • 2
  • 8
0

I used @Andrew answer to recover an existing system.

In my case I had the following system:

  • /sda1 primary ntfs Windows Boot
  • /sda2 primary ntfs Windows System
  • /sda5 extended ext4 Old Ubuntu Root
  • /sda6 extended swap

Basically I installed a new ubuntu besides the old one with an independent /boot partition, then remapped the old ubuntu to use the new /boot.

  1. Start Installing new ubuntu from live CD, go to advanced.

  2. Make space for a /boot partition (permanent) and a root partition (temporary) for the new ubuntu.

I resized an ntfs partition to make a 4gb /boot primary partition and deleted the swap partition to make the new root (/) partition. /boot might not need to be primary, and everything could be done inside the repurposed swap without resizing. This was my partition table after this:

  • /sda1 primary ntfs (Windows Boot)
  • /sda2 primary ntfs (Windows System) (shrinked)
  • /sda4 primary ext4 /boot
  • /sda5 extended ext4 / (Old Ubuntu Root)
  • /sda6 extended ext4 / (New Ubuntu Root)
  1. After installing you might access the old ubuntu at grub menu below the memtest (it's recognized automatically like if it was a windows partition). Boot it.

  2. Edit /etc/fstab to mount the new /boot, ie

UUID=2d7611ad-0547-4d7c-a595-3f4103ff0b0e /boot ext4 defaults 0 2

  1. Add your old kernel to the new boot partition:
  • Option 1 (tested) Mount the new /boot and reinstall all linux-images

    mount /boot

    apt-get install $(apt list --installed | grep linux-image | cut -d / -f -i)

  • Option 2 (not tested) Copy everything from your old /boot to the new one, except the grub folder

    cp -dR /boot /tmp

    rm -r /tmp/boot/grub

    mount /boot

    cp /tmp/boot/* /boot

  1. Delete the new ubuntu partition and recreate the swap partition. Use gparted for graphic ui. This is my partition table after this
  • /sda1 primary ntfs (Windows Boot)
  • /sda2 primary ntfs (Windows System) (shrinked)
  • /sda4 primary ext4 /boot
  • /sda5 extended ext4 / (Old Ubuntu Root)
  • /sda6 extended swap
  1. Use blkid to find the UUID of your new swap partition, update fstab with the new UUID

  2. Update Grub with update-grub and reboot.

  3. If everything is still working, umount /boot. delete everything inside your old /boot and remount it.

xvan
  • 168