10

I have a Macbook Pro and I am loving it, though I still miss my Linux box, there are many things I need which are not completely compatible with Mac OS X. I heard many stories about installing Linux on a Mac OS, some say it's not a problem, but some others tend to say differently.

My question is, is it or is not fine to install Linux on a Mac OS machine? What are the pros and cons?

I am very well aware about virtual machines, but let's be honest, they do not run quite as well when running on a physical hardware.

  • 2
    An Intel Mac isn't really that different from a PC. Linux would probably run just fine (I can't say for sure — never had a Mac). Your one potential stumbling block may be UEFI/EFI. Some Linux distributions have trouble with it. That having been said, my own UEFI-only Lenovo laptop boots Debian and Ubuntu just fine. – Alexios Sep 4 '13 at 23:09
  • Yes, I run an Intel CPU and a Intel Graphic card. I heard about this story of UEFI, the distro I use won't make a problem out of it ;-). – user22921 Sep 4 '13 at 23:12
  • 1
    Have you had a look at mac.linux.be? – terdon Sep 4 '13 at 23:12
  • 1
    @Alexios an Intel Mac actually is pretty different. Unlike most UEFI systems, Macs ship with a nonstandard EFI/UEFI mix (UEFI == EFI 2.0). plus, you have to "bless" files/mounpoints/directories/_something_ in order for the firmware to recognize it as bootable. – strugee Sep 5 '13 at 3:07
  • 1
    Should have clarified: I was referring to the hardware. I'm reading your answer now, I've a feeling I'll learn something new (not that I'm likely to ever use it). :) – Alexios Sep 5 '13 at 10:27
6

tl;dr: it's doable but you will have to work just a little bit. If you don't have the ability to use Ethernet, and are installing from netinst media, you're basically screwed (although if you're really determined you can make it work).

When I originally wrote this answer, I'd only done this once, but now I'm doing it again on a different Mac, so I've split the post into two.

Debian Jessie on a MacBook Pro

I have successfully installed Debian Jessie (currently aka Debian Testing) on my MacBook Pro, early 2011.

I'm going to say this right away: If you have a MacBook Air and/or no Ethernet cord, you are largely screwed if you use a distro that uses a network-based installation (such as Arch Linux, or the recommended Debian image, or one of the Ubuntu alternate CDs). You will basically have to download all the firmware files, boot the installation media in such a way that it is prevented from doing network configuration, install the firmware manually, and then try to get it to pick up the firmware. Then have it do network configuration. To be perfectly honest, I never got that to work and am not entirely sure that it's a sound plan.

Other than that, installation went smoothly. If you intend to keep OS X, you should use OS X's built-in Disk Utility to resize, as GNU/Linux doesn't currently have write support for the default Mac filesystem configuration (HFS+ with journaling, for those curious; write support only works without journaling). Note that you don't have to boot into the Recovery partition to do this - HFS+ can do online resizing - but you may see Disk Utility or your entire computer freeze. Don't worry, this has happened to me a couple of times and you just have to let it do its thing, but you won't be able to use the Mac while the process is taking place. I have heard that Disk Utility has bugs when creating an empty partition (which you will have to do for Disk Utility to let you resize). Therefore, I'd recommend creating a FAT filesystem on the new partition. You're welcome to try with the "none" option selected, but I played it safe.

Since I used the Debian Installer, I'm not really sure how it installed GRUB (I'm going to replace Debian with Arch soon, so I'll edit this answer with my results). It appears to have installed to the EFI partition in the Mac, but I'm not sure if it did any magic aside from that. Presumably not, but who knows. After installing GRUB, you need to reboot into Mac OS X. Open a terminal, mount the EFI partition (use diskutil list to dump information about disks; it's like OS X's version of blkid or lsblk), and muck around with the bless utility until you get to the GRUB menu on reboot. (I don't know exact steps for this, because I tried a bunch of things at the same time because I didn't want to wait through OS X's long reboot time). See man bless in OS X for the details of this utility.

Note that yes, upon success you will go directly to the GRUB boot menu (assuming you're using GRUB). I'm not sure the internals of how it works, especially with Apple's moon-man EFI implementation, but here's how you choose the OS to boot from:

  1. If you want GNU/Linux, do nothing. The GRUB boot menu will appear (again, assuming you're using GRUB).

  2. If you want Mac OS X, wait for the startup tone, then hold Option until you get the disk chooser menu. Two disk options should appear: Macintosh HD and EFI Boot. Select Macintosh HD. Note: the Mac OS X option in GRUB appears to do nothing but hang.

  3. If you want Mac OS X Recovery, wait for the startup tone, then hold Option until you get the disk chooser menu. It's the exact same thing as booting regular OS X, except you choose EFI Boot instead of Macintosh HD.

The touchpad driver in Xorg is extremely lacking. Xorg will choose the Synaptics driver for you, which is a piece of crap on an Apple touchpad. Therefore, Google around until you find a decent driver, then override the Synaptics driver with it in your xorg.conf (or xorg.conf.d, depending on distro), although I never could find a driver that could actually do right-click on the Apple trackpad, which is kind of a pain in the neck. I would tell you the exact details of my configuration, but I have an initial Time Machine backup running and can't be bothered to reboot into Debian. I'll edit this answer when I do, though.

The biggest thing besides the wireless (which needs firmware but is easy to bootstrap as long as you have an Ethernet cable) was that if I closed the lid, the screen failed to wake up. The keyboard backlight would turn on, but never the screen. Preliminary Googling says that this is a kernel bug, but I haven't looked into exact fixes. I've started experimenting with the pm-* family of utilities (e.g. pm-suspend) but haven't done anything in-depth. A workaround for this issue is to switch to a virtual console, to "defocus" Xorg. This way, when you close the lid, your computer won't try to suspend at all. Note that this means that the Apple logo on the back will continue to be lit, although turning down the screen brightness also affects the Apple logo. Note, though, that you can only use the function keys when Xorg is "focused". Which brings me neatly to my next topic...

The keyboard basically acts normally. Option works exactly as you would expect alt to. Command is the superkey. The only thing that tripped me up - although not for long - is that the function keys not needing Fn pressed is a hardware thing, not a software thing. Therefore pressing e.g. brightness up works the same as in OS X - when you press F2, it turns up the brightness, and when you press Fn+F2, it sends the F2 key.

The final thing that I should mention is that I never got 3D acceleration to work. The GLX Gears demo worked with (I think) mesa, but I got booted to GNOME Fallback, so clearly true acceleration isn't working. The solution that I found hung me at boot (see the last post about the Debian installation in my blog), so I don't think there actually is a solution, at least until the linux-firmware-nonfree package is split up even more.

If you're interested in all the gory details, you should read my blog posts on the matter (just click next until you reach the one called "I FIXED EVERYTHING"). They also probably mention some details that I can't remember off the top of my head (like the name of that touchpad driver!).

Arch Linux (September 2013 image) on an iMac

I allocated space for the Arch install from OS X (see the beginning of the Debian section for the reasoning behind this), creating a ~100 GB partition for /home and ~100GB partition for /.

The CD boots fine - just hold down option, and then select the CD icon labelled "EFI Boot". The keyboard works fine up until you hit enter on the "boot Arch" option, at which point presumably Arch takes over from EFI, and hence the EFI Bluetooth keyboard driver. Therefore you'll need a USB keyboard to actually go through the installation.

The first thing I did after booting was to connect to the internet with wifi-menu, which surprisingly worked without a hitch. Next I messed with the sizing of the partitions that I'd allocated for Arch using cgdisk, since I'd changed my mind - this is apparently OK and I was able to reboot into OS X without a problem. One problem that I ran into is that I made a partition too small, and wanted to cut into the OS X partition to expand it. However, when I went to Disk Utility to shrink the OS X partition, it said "preparing to partition..." and then never got any further. Tried doing it from the recovery partition (with Macintosh HD both mounted and unmounted): same result. So the moral of the story is: be sure about your partition layout before you install!

From then on the install went without a problem. When I got to bootloader installation, I installed the grub, efibootmgr and dosfstools packages from Arch, as recommended by the wiki. I additionally installed os-prober, although according to the package description this is only for BIOS systems. I mounted the EFI system partition on /boot/efi (following the wiki, I'll refer to this as $esp below). Note that (at least on my computer) the EFI system partition is the first partition, making it /dev/sda1 under GNU/Linux and /dev/disk0s1 under OS X/Darwin. I installed GRUB using the following command:

grub-install --target=x86_64-efi --efi-directory=$esp --bootloader-id=grub --recheck --debug

If you can't be bothered to look, this is pretty much verbatim what the wiki recommends for the easy install (not keeping everything in the EFI partition, so some stuff goes in /boot). At the end it said "EFI variables are not supported on this system", but it still seems to have installed OK (as ls /boot/efi/EFI returns "grub" in addition to "APPLE").

Next, I generated grub.cfg:

grub-mkconfig -o /boot/grub/grub.cfg

I'll note that it seems to have found OS X on the correct partition, although given my experience in Debian I bet the menu item won't work. We'll see. Next, I rebooted into OS X - I seem not to have broken anything, although the EFI firmware seems to take slightly longer to get to the Apple logo as opposed to just the grey screen (it might be just me, not sure).

In preparation for using bless I mounted the EFI partition in OS X:

sudo mkdir /mnt
sudo mount -t msdos /dev/disk0s1 /mnt
cd /mnt

Next I did this exact sequence of commands, rebooting in between each one to check if it worked (and remounting every time I rebooted):

sudo bless --folder /mnt/ --bootefi EFI/grub/grubx64.efi

This yielded different, and arguably better results than my attempt from Debian did. What happened this time was that "EFI Boot" is now offered as an option when you hold Option, along with "Macintosh HD" and "Recovery-$YOUR_INSTALLED_OS_X_VERSION".

GRUB successfully loaded Arch, but I got dropped to an initrd shell. This was because I had misconfigured it so that the LUKS devices never got created, though, not due to a Mac-specific issue.

This is as far as I've gotten, but I'll be back with more edits later.

  • 2
    Few things to take note here, for a 15 years old, I must say, keep following the path you are following ;-) Also let me know about Arch, which is my "mother" distro, the only I use and the only I want to install it on my Mac. Cheers! – user22921 Sep 5 '13 at 19:50
  • Oh hey, didn't realize Stack Exchange bumped my age a couple of days ago (and thanks!). Anyway, one thing I forgot to mention for the 3D thing is that it seems like the MacBook has two video cards: one integrated and one dedicated. I think that's what's causing the driver issues. Also, I didn't try proprietary drivers. – strugee Sep 5 '13 at 20:28
  • 1
    @BenMezger I'm going to be installing Arch on an iMac soon, so I'll be updating this post as I go along if you're interested. I'll also eventually be moving from Debian to Arch on my MacBook, but not right now. – strugee Sep 22 '13 at 2:39
  • strugee: Yes please! – user22921 Sep 22 '13 at 10:53
1

I have installed Ubuntu 12.04 64bit for Mac on a 2010 MBP. It works for me. No problems installing, etc. But ... it appears - and I stress that these are impressions only and not backed up with tests ... that power management isn't quite right, the overall user experience is not as slick as for OS X. Which is strange as I have no problem with Ubuntu 12.04 on a HP notebook.

Like yourself, I've tried to get answers but not finding much. Considering that Linus Torvalds uses a MacBook Air, these niggling issues "should" have been fixed. Then again, it might all be due to the fact that I'm using an older MBP.

At the end of the day, I pulled the HD and installed a SSD with OS X on it.

  • I guess it goes that way, you buy a Macbook, you stay with the OS. It's not bad, perhaps I just have to get used to it. Thanks. – user22921 Sep 5 '13 at 19:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy