Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
share|improve this question
    
It will be helpful if you can include the command that you used and the error message that you got when trying to install. For example, have you tried grub-install /dev/sda? –  phunehehe Dec 27 '10 at 13:05
    
I have already recreated the disk layout with MBR, and copied the raw file system into the single partition of the disk. Though, I'll retry a new Gento installation and paste the error message some time later. Thanks –  Xiè Jìléi Dec 27 '10 at 16:51
    
EDIT I've added the error message. –  Xiè Jìléi Dec 28 '10 at 3:34
add comment

3 Answers

up vote 3 down vote accepted

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.

share|improve this answer
3  
It's used by the guest Gentoo OS in VirtualBox. I have created a .vmdk virtual disk which back-end by a raw image.ext4. The reason I use the entire disk for one file system is that, I want to mount the volume directly in the host OS, without the tricky partition offset like -o loop,offset=1048576 . –  Xiè Jìléi Dec 27 '10 at 13:56
add comment

Its not mandatory that GRUB needs to be written to MBR. You can install it on partition boot sector and let the other boot loader from MBR load it, such as Windows 7 loader.

http://www.linuxselfhelp.com/gnu/grub/html_chapter/grub_3.html

share|improve this answer
add comment

Just about everything expects a partition table. I think you will have to re-install, and follow the suggested guidelines of having at least a /boot, swap, and /root partition. Where's your swap?

share|improve this answer
2  
Linux doesn't care. Most BIOSes don't care (though some do). Separate swap and boot partitions are not necessary, and /boot is no longer recommended on modern hardware (it was a kludge to bypass BIOS limitations on disk sizes and lack of support for advanced disk modes such as LVM in Grub 1). –  Gilles Dec 27 '10 at 12:39
    
@Gilles You mean, I can have LVM without a separated /boot? If so, why is it better to leave /boot in the same partition as /? –  phunehehe Dec 27 '10 at 13:01
1  
@phunehehe: You can have LVM without a separate /boot with Lilo or Grub 2, but not with Grub 1. A separate /boot has an administrative cost (you need to make one more partition, and you need to be careful not to mix up /boot with /), so you would only use one if there's a reason (such as your bootloader not understanding LVM). –  Gilles Dec 27 '10 at 13:08
1  
@Gilles now you make me feel like reinstalling... –  phunehehe Dec 27 '10 at 16:57
    
You can also have things like whole disk encryption :) –  XTL Mar 20 '12 at 9:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.