How to install GRUB command-line tools on OSX?

9

6

I need access to grub-mkrescue for a project I'm working on. I know that the GRUB command-line tools come builtin to Linux, but how do I get them on OSX? Is there a package? Is it built into the system somewhere? Is there an installer?

CLARIFICATION: The question is not about installing GRUB as a bootloader on the Mac. The question is about installing the GRUB command line tools to do things like create bootable disk images of other operating systems.

beakr

Posted 2013-06-12T21:08:33.280

Reputation: 201

Answers

4

I know this is two years too late for the OP, but by following the OSDev Wiki on installing GRUB2 on Mac OS X, I was able to get grub-mkrescue (and other GRUB related tools for my target platform) installed after installing the proper build tools for the target platform.

To get the build tools, I used a Homebrew tap, but at its root, Homebrew is just a pile of Ruby scripts that install things for you so they could be followed if you don't use Homebrew.

jcaudle

Posted 2013-06-12T21:08:33.280

Reputation: 43

-1

I would highly suggest that you don't mess with the bootloader on your Mac unless you are in a position to format your machine.

Macs do not use grub to boot into OSX

The firmware’s built-in boot volume chooser (hold Option to activate it) will recognize Linux boot CDs as well as bootable hard disks and let you boot them. (They may be labeled “Windows”, though.) For triple-booting you’ll get only one item in the built-in chooser, but you can use GRUB, LILO, or NTLDR to act as a second-level menu to choose between Windows and Linux. http://refit.sourceforge.net/myths/

A much better solution would be to spin up a VM in Virtualbox, and run grub-mkrescue to create your grub recovery disk from there.

If you search a Mac package manager for grub software, you will find none: Likely because the tools have no use on Mac.

spuders-macbook-pro:Downloads spuder$ brew search grub
No formula found for "grub". Searching open pull requests...

spuders-macbook-pro:Downloads spuder$ brew search grub-mkrescue
No formula found for "grub-mkrescue". Searching open pull requests...

Update

Attempt to compile from source

-Install Homebrew
-Install bazaar
-Download grub source
-Install autogen
-Compile

$uname -a 
Darwin spuders-macbook-pro.localhost 12.4.0 Darwin Kernel Version 12.4.0: Wed May  1 17:57:12 PDT 2013; root:xnu-2050.24.15~1/RELEASE_X86_64 x86_64


$ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
$ brew install bazaar
$ #The installation of bazaar pops up a warning that you need to export PYTHONPATH
$ export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH
$ brew install autogen
$ cd /tmp
$ bzr branch http://bzr.savannah.gnu.org/r/grub/trunk/grub
$ cd /tmp/grub
$ autogen
$ ./configure
configure: error: cannot find install-sh, install.sh, or shtool in build-aux "."/build-aux

It looks like the configure.ac was not setup for the Mac OS. If you are adept at compiling software, you may be able to modify it.

Your best bet will still be to install virtualbox, and create a linux VM and run the grub tools from there


Additional Resources

http://refit.sourceforge.net
http://mac.linux.be/content/problems-refit-and-grub-after-installation
http://crunchbang.org/forums/viewtopic.php?id=24692
http://uk.answers.yahoo.com/question/index?qid=20080929055515AAeK1j7
https://apple.stackexchange.com/questions/39291/ubuntu-on-mac-dual-boot-where-do-i-install-grub

spuder

Posted 2013-06-12T21:08:33.280

Reputation: 8 755

4I'm not trying to mess with my Mac. I'm trying to create a GRUB-based bootable disk image to be used with a virtual machine for a custom OS. Specifically, I need the "grub-mkrescue" tool. I'd rather not keep using ubuntu and am just looking for a way to get this working on my Mac. Does that make the question clearer? I hardly think there is "no use for grub-mkrescue on a mac" when creating a bootable image of another OS is a perfectly good use. – Steve – 2013-07-26T17:42:46.837

That makes sense. Since Mac's don't use grub, it is unlikely that you will find that tool ported to Mac. The tool doesn't appear in mac ports, nor does it appear in home-brew. – spuder – 2013-07-26T17:51:55.990

I think the argument about whether or not GRUB supports EFI-based Macs is besides the point. Your answer doesn't address the question of how to install the GRUB command line tools. Your argument that "because there isn't a use for GRUB as a boot loader on the Mac means that no one will have a solution for building the GRUB command line tools on the Mac" is absolutely non-sensicle since nothing has stopped me from building any number of cross-compilers (the output of which have no use on the Mac). – Steve – 2013-07-26T18:21:37.340

I updated my answer after trying to compile the grub tools on Mac OS. I did not have success compiling and installing them, but I am not an expert on compiling software. – spuder – 2013-07-26T20:58:21.160

1Thanks, but you are obviously missing some very basic compiler tools if that's the error you're getting. As much as I appreciate the attempt, I think we're looking for someone who has worked out the issues instead of being told to boot into a linux vm. – Steve – 2013-07-26T22:17:14.230