Does the 'mount' command rely on MBR to detect partitions, or can it use the GPT partition table?

1

TL:DR

I have Mac, which means I have EFI and a GPT formatted disk with a hybrid MBR. I am considering adding a fifth partition; to do this, I will mask my first three GPT partitions with one partition in my protective and hybrid MBR.

However, if, say, I fire up an operating system after these (say, on my fourth I have Linux), will I be able to mount filesystems from inside the protective MBR? I.e., can an OS like Linux that has been booted from a legacy MBR view GPT partitions, or does it rely on the MBR to tell it what partitions exist?

Does mount rely on MBR, or will it find (my) GPT disks?


Full / Old Question

I have a hybrid MBR of 4 partitions on my Mac.

1. EFI System Partition
2. Mac OS X
3. Mac Recovery Partition
4. Ubuntu

Now, I want to add Archlinux to the end, i.e., append 5. Archlinux, but I would also like to maintain a reasonable MBR (because an MBR can only have four records).

My idea is to create a MBR partition that covers both partitions 1 and 2, or 2 and 3, or 1-3, thus making the MBR think that there is one partition, and nothing will touch it (this is typical of GPT disks, which have a protective MBR which covers all the GPT partitions with one legacy MBR partition for safety reasons).

My question is: Does Ubuntu use the MBR to mount filesystems? If I do create my nice protective partition, will I no longer be able to mount my Mac OS X filesystem in Ubuntu, assuming Ubuntu is installed using the legacy MBR method, and not the GPT / EFI boot Ubuntu.*

*Or maybe EFI compatibility in Ubuntu is better now?

kalaracey

Posted 2013-03-05T01:36:00.873

Reputation: 2 039

Should this be moved to AskUbuntu? – kalaracey – 2013-03-05T03:13:35.613

1I can't fully answer your question, but mount itself would not rely on the MBR. I know this as it is possible to mount loopback images and entire block devices, so presumably its more a question of what will your kernel recognise. – davidgo – 2013-03-05T04:17:58.040

@davidgo Oooh. That's a good point... So I should look at how the kernel detects partitions / devices. Thanks. – kalaracey – 2013-03-05T12:07:52.487

@davidgo Alright, but I think that maybe how the kernel detects partitions might depend on the MBR, and then mount will depend on the kernel to tell it what's there. – kalaracey – 2013-03-06T13:17:03.053

Answers

4

The answer is OS-dependent. It's not really mount per se that uses GPT or MBR; it's the OS kernel. OS X's kernel depends on the GPT data in preference to the MBR data, so it reads hybrid MBR disks as GPT disks. The same is true of the Linux kernel if that kernel includes GPT support, as most binary kernels distributed by major distributions do. If you build your own kernel and omit GPT support, though, it will ignore the GPT partitions and use the MBR partitions instead.

Windows ignores the GPT data if it sees a hybrid MBR. That's what makes hybrid MBRs useful (albeit ugly and dangerous): Windows sees a hybrid MBR disk as an MBR disk, which means it will install to the disk when booted in BIOS mode, whereas Windows will not install to a GPT disk when booted in BIOS mode.

FreeBSD works in a third way: It presents both sets of partitions using different device nodes. GRUB 2 does something similar; you can specify which table to use by preceding the partition number with a code, as in (hd0,gpt3) to use the third GPT partition on the first disk.

One more point: Because of the dangers of hybrid MBRs, if you're dual-booting between OS X and Linux but not booting Windows, it's best to convert your hybrid MBR to a standard protective MBR. Given the Mac's architecture, though, this will require you to boot Linux in EFI mode. This works fine on most Macs, but there are problems with hardware detection on some models. Thus, you may want to install an EFI-capable boot loader to test your ability to boot and use Linux in EFI mode before you convert your hybrid MBR to a protective MBR. You can read more about EFI boot loaders for Linux here. You can convert a hybrid MBR to a conventional protective MBR by using GPT fdisk (gdisk); type x to enter the experts' menu, type n to create a new protective MBR, and then type w to save your changes.

Rod Smith

Posted 2013-03-05T01:36:00.873

Reputation: 18 427

Wow... the great Rod Smith of rEFIt and GPT Fdisk fame has answered my questions! Thank you very much, for both the answer and the software you've put out. – kalaracey – 2013-03-13T12:57:54.780

"this will require you to boot Linux in EFI mode... problems with hardware detection..." Yes, I have been worried about hardware issues. I am going to install linux on another partition to test soon. One thing: if I installed Linux with the bootloader (Grub) on the same partition as the OS, and that gets found by rEFInd, will that still be affected by the MBR? I.e. would Grub use the MBR for partition/disk information, even though it is not located there? – kalaracey – 2013-03-13T13:00:52.423

AFAIK, GRUB's partition-detection logic is not dependent on where it's stored. – Rod Smith – 2013-03-13T17:15:36.410

Does Grub's partition-detection logic depend on the contents of the MBR? Actually, I don't think it really matters that much, as long as it can detect Ubuntu, which is on the same partition as it (Grub) is installed. I would like to convert my MBR to a protective MBR, but I would still like to be able to boot Ubuntu. I am not yet prepared to get Ubuntu booting with EFIstub or Grub EFI. – kalaracey – 2013-03-13T20:33:27.067