HackWare.ru
Этичный хакинг и тестирование на проникновение, информационная безопасность
Решение проблемы с «error: attempt to read or write outside of disk «hd0″»
После установки Linux при первой загрузке вы можете столкнуться с упомянутой в теме ошибкой.
Чтобы понять причину, буквально пара слов о процессе загрузки. Всё начинается с того, что БИОС инициализирует устройства, в том числе жёсткие диски; после этого БИОС передаёт управление загрузчику GRUB, указывая место на диске, где тот должен прочитать конфигурационный файл и другие необходимые для него файлы.
БИОС — довольно старое изобретение и у него есть ряд ограничений. Например, ни один БИОС не способен работать с дисками более 2 Терабайт. Поэтому если вы установили систему на такой диск, то вполне возможно, что БИОС не справится с загрузкой операционной системы.
Но это не всё — некоторые БИОСы сделаны особенно неудачными — они не могут указать GRUB на файлы, которые расположены слишком далеко от начала диска — необязательно за пределами 2 Терабайт, возможно, намного ближе.
Как происходит запись на диск
Это кажется контринтуитивным, но информация на диск не записывается последоватльно — то есть если на диске занято 10% места, это не означает, что заняты именно первые 10% — информация может быть разбросана как угодно. Умные диски специально записывают информацию в разные области — чтобы диск изнашивался равномерно.
Поэтому, когда вы делаете установку операционной системы, то папка /boot может оказаться в любом месте — даже ближе к концу диска.
Ошибка «попытка записи за пределами диска «hd0″»
Итак, в результате стечения ряда обстоятельств:
- используется БИОС (а не EFI)
- большой размер диска
- неудачный БИОС
- папка /boot записалась слишком далеко от начала диска
можно получить ошибку:
error: attempt to read or write outside of disk "hd0"
Отсюда следуют выводы:
- при установке на один и тот же диск ошибка может возникнуть, а может и не возникнуть (в зависимости от того, на какое место на диске записана папка /boot)
- переустановка GRUB, которую советуют на некоторых сайтах, может помочь, а может и не помочь — опять же, в зависимости от того, куда будет перезаписана папка /boot
- если ваш компьютер поддерживает EFI, то вы с этой ошибкой никогда не столкнётесь
- проблемный диск вполне может загрузиться на другом компьютере (есть нюансы — на другом компьютере может быть EFI или такой же неудачный БИОС)
И самый главный вывод — если папку /boot записать на отдельный раздел и расположить этот раздел в начале диска, то это почти наверняка разрешит проблему.
Как разместить папку /boot на отдельном разделе.
Я покажу на примере Debian и производных (Kali Linux, например). С другими дистрибутивами действия сходные — но вам нужно предварительно поискать информацию, как в процессе установки вынести папку /boot в отдельный раздел.
Особо отмечу, если у вас компьютер поддерживает EFI (а этом большинство компьютеров, выпущенных за последние лет 8-10), то с этой проблемой вы не столкнётесь и вам не нужно беспокоиться.
Итак, в начале установка выполняется как обычно.
Затем, когда вы дойдёте до разметки диска — выберите «Ручную разметку»:
Выберите диск для разметки:
Выбираем Да:
Выберите Свободное место:
Создаём новый раздел:
Делаем не очень большой размер — 1 Гигабайта хватит более чем. На самом деле, будет использовано менее 100 Мегабайт. На всякий случай лучше выделить более 200 Мегабайт:
Первичный:
Обязательно Начало — иначе бессмысленно:
Перейдите на Точку монтирования:
Выберите /boot — статические файлы системного загрузчика:
Поставьте метку Загрузочный. Выбираем Настройка раздела закончена:
Теперь переходим на свободное место и создаём ещё один раздел:
Далее как с первым размером — установите размер. Выберите Логический раздел.
В качестве точки монтирования должен быть указан / — этот символ означает корневую файловую систему:
Кстати, под основной раздел вы можете использовать не всё свободное место — можете оставить место на диске под другие нужды. Также вы можете выделить Гигабайт 10 под SWAP — раздел подкачки (используется когда не хватает оперативной памяти). Для этого, когда устанавливаете свойства диска, выберите «Использовать как», а там «раздел подкачки».
Далее установка операционной системы вновь продолжается в обычном режиме.
Заключение
Проблема может возникнуть как с внутренним жёстким диском, так и с внешним USB диском. Проблема может возникнуть внезапно — даже на диске, который до этого работал нормально — всё дело в «везении» — куда именно будет записана папка /boot. Показанный в этой заметке способ позволит не полагаться на везение, а полностью предотвратить эту проблему.
Кстати, если вы уже всё равно залезли в ручную разметку диска, то рекомендуется выделить ещё один раздел и выбрать его для монтирования папки /home. В результате получится, что система будет на одном разделе, а папка /home, в которой размещены файлы пользователей — на другом. Поэтому при следующей переустановке системы файлы из папки /home не будут удалены (если вы не сделаете это вручную). И вы вновь сможете подключить этот раздел для монтирования в качестве /home. То есть получится, что система у вас новая, а все пользовательские файлы на том же самом месте — как и до переустановки.
Связанные статьи:
- Решение проблемы: Live USB флэшка с Linux не загружается, ошибка «A start job is running for live-config contains the components that configure a live system during the boot process (late userspace)» (96.5%)
- Как установить Kali Linux (пошаговая инструкция) (92.6%)
- Как изменить параметры загрузки Linux в UEFI (66.6%)
- Kali Linux не загружается – решение проблем (61.3%)
- WSL (подсистема Windows для Linux): подсказки, инструкции, решения проблем (61.3%)
- IP адрес (RANDOM — 50%)
факультете информационной безопасности от GeekBrains? Комплексная годовая программа практического обучения с охватом всех основных тем, а также с дополнительными курсами в подарок. По итогам обучения выдаётся свидетельство установленного образца и сертификат. По этой ссылке специальная скидка на любые факультеты и курсы!
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?
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.
I found a workaround.
- Insert the Xubuntu live USB
- Select «try Xubuntu»
- In the settings menu select «install Xubuntu»
This fixed the problem for me. Since it is solved I cannot test the answer.
69.6k 56 56 gold badges 217 217 silver badges 328 328 bronze badges
asked Dec 30, 2013 at 2:36
Martin Drozdik Martin Drozdik
3,125 6 6 gold badges 29 29 silver badges 35 35 bronze badges
(near-)duplicate of askubuntu.com/questions/229715/…
Oct 27, 2016 at 12:25
9 Answers 9
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.
729 1 1 gold badge 8 8 silver badges 16 16 bronze badges
answered Dec 30, 2013 at 6:02
user223882 user223882
645 8 8 silver badges 10 10 bronze badges
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. 🙁
Aug 23, 2014 at 11:50
As soon as I type insmod normal I get the message again: «error: attempt to read or write outside of partition.»
Nov 11, 2014 at 22:12
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?
Jan 4, 2015 at 21:30
The best I’ve gotten is another grub prompt. The menu never pops up.
May 23, 2015 at 23:45
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.
Jul 5, 2016 at 10:42
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!
answered Jan 2, 2014 at 6:11
311 2 2 silver badges 3 3 bronze badges
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.
Feb 4, 2015 at 1:53
It seems this also works if /boot is the only primary partition.
Jun 15, 2016 at 6: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!
Jul 27, 2016 at 1:25
It helped me: I had a big(>5TB) / partition, adding small /boot partition fixed the issue
Oct 4, 2016 at 15:26
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.
May 21, 2017 at 23:24
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.
195k 53 53 gold badges 476 476 silver badges 729 729 bronze badges
answered Oct 31, 2018 at 1:55
Zach Parker Zach Parker
131 1 1 silver badge 2 2 bronze badges
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.
Jul 29, 2021 at 4:59
same Unknown command ‘linux’
Aug 15, 2021 at 17:00
my command prompt states grub rescue> instead of the above Grub>
Aug 15, 2021 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.
Jul 21 at 8:04
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.
answered Feb 6, 2019 at 10:49
161 1 1 gold badge 1 1 silver badge 5 5 bronze badges
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!
Aug 25, 2020 at 0:05
Instead I’m brought to a yellow EFI shell. Perhaps I will reinstall with UEFI enabled.
Jul 29, 2021 at 4:59
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.
answered Oct 16, 2014 at 18:39
31 1 1 bronze badge
How does one move the Linux partition to the beginning of the disk?
May 21, 2017 at 23:23
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)
14.1k 4 4 gold badges 48 48 silver badges 98 98 bronze badges
answered Apr 8, 2014 at 12:46
Zeyad Assem Zeyad Assem
159 2 2 bronze badges
It worked for me (using Proxmox). Maybe the kernel was corrupted. Thanks.
Jun 5, 2021 at 17:25
This is random problem.
In this case better solution is to create /boot folder in its own partition
answered Sep 4, 2020 at 18:48
Eugen Konkov Eugen Konkov
786 9 9 silver badges 18 18 bronze badges
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.
answered Jul 8, 2018 at 20:48
334 2 2 silver badges 8 8 bronze badges
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.
- Start Installing new ubuntu from live CD, go to advanced.
- 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)
- 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.
- Edit /etc/fstab to mount the new /boot, ie
UUID=2d7611ad-0547-4d7c-a595-3f4103ff0b0e /boot ext4 defaults 0 2
- Add your old kernel to the new boot partition:
mount /boot apt-get install $(apt list —installed | grep linux-image | cut -d / -f -i)
cp -dR /boot /tmp rm -r /tmp/boot/grub mount /boot cp /tmp/boot/* /boot
- 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
- Use blkid to find the UUID of your new swap partition, update fstab with the new UUID
- Update Grub with update-grub and reboot.
- If everything is still working, umount /boot. delete everything inside your old /boot and remount it.
Форум русскоязычного сообщества Ubuntu
Страница сгенерирована за 0.043 секунд. Запросов: 25.
- Сайт
- Об Ubuntu
- Скачать Ubuntu
- Семейство Ubuntu
- Новости
- Форум
- Помощь
- Правила
- Документация
- Пользовательская документация
- Официальная документация
- Семейство Ubuntu
- Материалы для загрузки
- Совместимость с оборудованием
- RSS лента
- Сообщество
- Наши проекты
- Местные сообщества
- Перевод Ubuntu
- Тестирование
- RSS лента
© 2012 Ubuntu-ru — Русскоязычное сообщество Ubuntu Linux.
© 2012 Canonical Ltd. Ubuntu и Canonical являются зарегистрированными торговыми знаками Canonical Ltd.
Ошибка после установки Ubuntu 16.04 LTS error:attempt to read or write outside of disk ‘hd0’
Я поставил новый жесткий диск.Поставил винду,не мог работать потому-что постоянно повреждался файл,по моему,BCD,отвозили в ремонт диск,сказали что все в ним в порядке,все сектора целы,списал на бзики винды,установил
Ubuntu 16.04 LTS,установилось нормально,при первом запуске вылезла эта ошибка:
1 2 3
error:attempt to read or write outside of disk 'hd0'. Entering rescue mode. grub rescue>
Как решить проблему?
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
Ответы с готовыми решениями:

Ошибка в конце установки Windows: «A disk read error occurred»
Всем привет! Возникла следующая трудность, есть ноутбук Asus k50c, на нем стояла семерка, очень.
Ошибка при добавлении в файл. Ошибка 101: Ошибка записи на диск (Error 101: Disk write error).
Здравствуйте, возникла проблема такого плана. Нужно произвести добавление записи в файл, но после.
Ошибка Error 100: Disk read error
Что это за ошибка? program test; uses crt; const n = 100; var a: array of real;
Ошибка Error 100: Disk read error
Program pr2122; Uses Dos, crt; Type stip = record pr: string; gr: string; st.