Solving the problem with ‘error: attempt to read or write outside of disk «hd0″’
After installing Linux at the first boot you may encounter the error mentioned in the subject.
To understand the reason, literally a couple of words about the boot process. It all starts with the fact that the BIOS initializes the devices, including hard drives; after that, the BIOS transmits control to the GRUB booter, indicating the place on the disk where it should read the configuration file and other files necessary for it.
BIOS is a rather old invention and it has a number of limitations. For example, no BIOS is able to work with disks over 2 terabytes. Therefore, if you installed the system on such a disk, then it is quite possible that the BIOS will not cope with loading the operating system.
But this is not all – some BIOSes has especially poor design – they cannot point GRUB to files that are too far from the beginning of the disk – not necessarily beyond 2 Terabytes, perhaps much closer.
How is the recording on the disc performed
This seems counterintuitive, but the information is not recorded to the disk sequentially – that is, if 10% of the disk space is occupied, this does not mean that the first 10% are occupied – the information can be scattered randomly. Smart disks specifically record information in different areas – so that the disc degrades evenly.
Therefore, when you install the operating system, the /boot folder can be anywhere — even at the end of the disk.
error: attempt to read or write outside of disk «hd0″
So, as a result of the confluence of a number of circumstances:
- BIOS is used (not EFI)
- large disk size
- poor BIOS design
- folder /boot is written too far from the beginning of the disk
can get the error:
error: attempt to read or write outside of disk «hd0″
From that facts the conclusions follow:
- when installing on the same disk, the error may or may not occur (depending on the location of the /boot folder on the disk)
- Reinstalling GRUB, which is advised on some websites, may or may not help - again, depending on where the /boot folder is overwritten
- if your computer supports EFI, then you will never encounter this error
- the problem disk may well boot on another computer (there are nuances - on another computer there may be EFI or also poorly designed BIOS)
And the most important conclusion – if the /boot folder is written to a separate partition and the partition is located at the beginning of the disk, then this will almost certainly solve the problem.
How to put the /boot folder on a separate section.
I will show the example of Debian and derivatives (Kali Linux, for example). With other distributions, the actions are similar – but you need to look in advance for information on how to put the /boot folder in a separate section during the installation process.
I would especially note that if your computer supports EFI (and this is the majority of computers manufactured in the last 8-10 years), then you will not encounter this problem and you do not need to worry.
So, at the beginning of the installation is performed as usual.
Then, when you get to the disk layout – select ‘Manual’:
Select the disk to partition:
Select FREE SPACE:
Create a new partition:
We do not very big size – 1 Gigabyte is enough for more than. In fact, less than 100 megabytes will be used. In any case it is better to allocate more than 200 megabytes:
Be sure to select ‘Beginning’ - otherwise everything what we do now is meaningless:
Go to Mount Point:
Select /boot - static files of the boot loader:
Set Bootable flag to on. Select Done setting up the partition:
Now go to the FREE SPACE and create another section:
Further, as with the first partition – set the size. Select a logical partition.
The mount point should be / - this character means the root filesystem:
By the way, for the main partition you can use not all the free space - you can save space on the disk for other needs. You can also allocate 10 Gigabytes for SWAP partition – swap area (used when there is not enough RAM). To do this, when you set the properties of the disk, select ‘Use as’, and there select the ‘swap area’.
Next, the installation of the operating system again continues as usual.
The problem can arise both with an internal hard drive, and with an external USB drive. The problem may arise suddenly – even on a disk that previously worked fine – it's all about “luck” - where exactly the /boot folder will be written. The method shown in this article will allow you not to rely on luck, but to completely prevent this problem.
By the way, if you’ve got into manual disk partitioning anyway, it is recommended to create another partition and select it to mount the /home folder. The result will be that the system will be on one partition, and the /home folder, in which user files are located, on another. Therefore, the next time you reinstall the operating system, the files in the /home folder will not be deleted (unless you do this manually). And you can re-connect this partition to mount as /home. That is, it turns out that you have a new system, and all user files are in the same place as before the reinstallation.
- How to install Kali Linux in VirtualBox (63.4%)
- Kali Linux web server shows blank pages (SOLVED) (59.8%)
- Error in Kali Linux ‘The following signatures were invalid’ (SOLVED) (59.8%)
- Kali Linux updating troubleshooting (59.8%)
- VirtualBox Guest Additions do not work in Kali Linux anymore (small screen, no shared clipboard) (SOLVED) (55.3%)
- How to use zcat to concatenate compressed and plain text files (RANDOM - 16.3%)