Web lists-archives.com

grub tries to read outside of a disk.


I am trying to install Debian on a 4TB external HDD, and want to be able to
boot it both on UEFI and BIOS systems. Using a simple BIOS/GPT configuration
(GPT partitioning with BIOS boot) didn't work out - after receiving some
important tips from this mailing list about problems that I had with this
configuration I succeeded to boot on BIOS system, but not on UEFI system.
Therefore I tried to combine BIOS+UEFI boots by creating both EFI and
BIOS boot partitions, and then installing grub into both. Here is how the
HDD was partitioned:

[root@arch]# parted /dev/sdb print
Model: WD Elements 25A1 (scsi)
Disk /dev/sdb: 4001GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system     Name  Flags
 1      1049kB  2097kB  1049kB                        bios_grub
 2      2097kB  202MB   200MB   fat32                 boot, esp
 3      202MB   714MB   512MB   ext4
 4      714MB   8714MB  8000MB  linux-swap(v1)
 5      8714MB  4001GB  3992GB  ext4

Partition 1 is intended for BIOS boot partition (for Stage 1.5 loader),
partition 2 is the EFI partition, partition 3 is intended for the /boot
(as was suggested previously on this mailing list) so that grub-related
files will be located inside the 2TB limit and therefore be accessible to
Stage 1.5 loader in BIOS mode, partition 4 is a swap, and 5 is the /.

I performed Debian installation on a UEFI machine, and after an installation
succeeded to boot the HDD. After that I installed grub into MBR:

grub-install --target=i386-pc --recheck /dev/sdb

Then I tried to boot on BIOS machine, and got the following error from grub:

"error: attempt to read or write outside of disk 'hd0'"

and was dropped into grub's rescue shell. I tried the following command:

ls (hd0,gpt3)/

which listed the expected contents of the /boot partition. Then:

set root=(hd0,gpt3)
set prefix=(hd0,gpt3)/grub
insmod normal

and again I get the error message

"error: attempt to read or write outside of disk 'hd0'"

As far as I could find, usually this kind of an error happens when
grub's files are located on a partition which is far from the
beginning of a disk, but in my case this is not so. And since grub
can list contents of a partition from a rescue shell, then it has
access to the file system. Then what is the problem here?