It is possible to configure GRUB2 in BIOS mode to boot from a partition without embedding into the area after the MBR, but there are some complications:
You must have /boot
on a plain partition (it may be a primary or logical partition, but must not use software RAID (md) or LVM). A separate partition for /boot
is not absolutely required, but if /boot
is stored on the root filesystem, the same partition restrictions will apply to the root filesystem partition.
The filesystem used for /boot
must support blocklist installation mode. Most commonly used Linux filesystems support this; important exceptions are btrfs
and xfs
(however, btrfs
has a large enough bootloader area to embed core.img
there, so installing GRUB2 there could still work). Again, if you do not have a separate partition for /boot
, these restrictions will apply to your root filesystem.
The blocklist installation mode is not recommended by GRUB2 developers, because in this mode core.img
is stored in the /boot
filesystem as a plain file, but actually it is accessed using sector numbers stored in the partition boot sector generated by GRUB (and in core.img
itself), therefore doing any file operation on this file may break booting. This is another reason to have separate /boot
partition when using this mode — there is less chance that you do some filesystem operation that will affect core.img
.
If /boot
is on a logical partition, you must have some means to start the bootloader code from the partition boot sector — many versions of MBR code support booting only from primary partitions. One solution is to use the MBR code from Syslinux, which supports booting even from logical partitions.
Suppose that your /boot
partition is /dev/sda2
; then you should install GRUB2 there with the following command:
grub-install --force /dev/sda2
You need to use the --force
option, because recent GRUB2 versions refuse to use the blocklist installation mode without it.
Then you should use fdisk /dev/sda
to mark the partition 2 active.
Finally, if you had some non-default boot code in the MBR (e.g., an older GRUB installation), you need to install code which loads the boot sector from the active partition — e.g., you can take mbr.bin
from Syslinux:
dd bs=440 count=1 conv=notrunc if=mbr.bin of=/dev/sda
When using a logical partition for /boot
, you may also consider using altmbr.bin
from Syslinux, which takes the boot partition number from a byte in MBR instead of looking for the active partition, so that any non-Linux operating system you have on the computer will not be confused by a logical partition marked as active.
seems like it should be possible. since grub can chainload grub, you might need to fully install grub to the partition boot sector; then you might get away with installing just the stage1 code to the MBR. not sure about this exactly, will need to research more. – quack quixote – 2010-02-10T05:48:54.980
What sort of application needs to address sectors outside a partition? Is it some sort of ridiculous DRM or antipiracy element to an app? – Alex – 2010-03-13T07:12:11.190
Putting any sort of code in the no-man's land preceding the 1st partition is just plain nuts, and certainly one of GRUB's biggest failings. – kreemoweet – 2012-04-22T04:24:28.267
@kreemoweet: Except that zone is "reserved for boot operations". This is also where TrueCrypt stores its encryption key. Any program which is not required to boot should not ever corrupt this area. – BatchyX – 2012-12-31T14:40:12.730