Currently I have the entire disk /dev/sda
formatted as ext4, and installed Gentoo.
(There is no MBR, no partition at all. )
But finally, I can't install GRUB on it, because it seems like GRUB needs to write to MBR.
# grub-install /dev/sda
Unknown partition table signature
Unknown partition table signature
Unknown partition table signature
Unknown partition table signature
Unknown partition table signature
The file /boot/grub/stage1 not read correctly.
neither does grub
work,
# grub
grub> root (hd0)
Filesystem type unknown, using whole disk
grub> setup (hd0)
Error 17: Cannot mount selected partition
Any way can I install GRUB into the /dev/sda without MBR?
P.S. The /boot
directory and grub.conf
files:
# tree /boot
/boot
|-- boot -> .
|-- grub
| |-- default
| |-- device.map
| |-- e2fs_stage1_5
| |-- fat_stage1_5
| |-- ffs_stage1_5
| |-- grub.conf
| |-- iso9660_stage1_5
| |-- jfs_stage1_5
| |-- menu.lst -> grub.conf
| |-- minix_stage1_5
| |-- reiserfs_stage1_5
| |-- splash.xpm.gz
| |-- stage1
| |-- stage2
| |-- stage2_eltorito
| |-- ufs2_stage1_5
| |-- vstafs_stage1_5
| `-- xfs_stage1_5
`-- kernel-2.6.36-gentoo-r5
# cat /boot/grub/grub.conf
default 0
timeout 30
splashimage=(hd0)/boot/grub/splash.xpm.gz
title Gentoo Linux 2.6.36-r5
root (hd0)
kernel /boot/kernel-2.6.36-gentoo-r5 root=/dev/sda
title Gentoo Linux 2.6.36-r5 Rescue
kernel /boot/kernel-2.6.36-gentoo-r5 root=/dev/sda init=/bin/bb
# cat /boot/grub/devices
(fd0) /dev/fd0
(hd0) /dev/sda
Best Answer
The BIOS reads the first sector (512 bytes) of the disk and branches into it. If your disk contains PC-style partitions, the first sector also contains the partition table. If your disk contains a single filesystem, the first sector contains whatever the filesystem decides to put there. In the case of ext[234] (and many other filesystems), the first sector¹ is reserved for the bootloader (and is initially zeroed out). You can install Grub on
/dev/sda
.That being said, there are occasional BIOSes that refuse to boot from a device that don't contain a partition table. (But there are also BIOSes that refuse to boot from some external devices if they do contain a partition table!) If you have one of these BIOSes, you'll have to create a partition table.
Even if a partition table is not necessary, it's recommended. You only waste a few kilobytes, and gain readability under many non-Linux OSes and less surprise for any co-sysadmin. If you accidentally plug your disk into a machine running Windows, it might suggest you to reformat the disk if it doesn't see a partition table, whereas it'll just complain it can't read the data if it sees a partition table with a partition type it doesn't recognize.
¹ In fact, the first block, I think, where a block is 1kB, 2kB or 4kB depending on the options passed to
mkfs
.