Sunday, December 16, 2012

Ubuntu 13.04 Daily Build Macbook Pro Retina documentation and install guide

      Over the past few days I have embarked on a journey:  to install and run Linux on a Retina Macbook Pro. (15-inch 2.3 GHz base model)  The main issues were the kernel not supporting it and the lack of internet connections that work immediately without extra hardware. (As well as the lack of solid instruction, which is why I created this guide.)

      Other places I have seen this topic discussed have been focused on current releases, which is understandable.  However, looking at these changes for Ubuntu 13.04, one of which states that it will be compatible with this computer, I decided to try the daily build.

      The daily build of Ubuntu 13.04 has kernel support for this computer.  This first post will describe the current state of Ubuntu 13.04 and the various steps I used to get Ubuntu working.

When partitioning, it is better to let Linux do the partitioning of free space in the installer rather than creating an msdos partition in Mac OS X.  This prevents the creation of a hybrid MBR and creates a protective MBR which has a standard.

 Installing to an external drive--Important Note


Your disk's partition table needs to be GUID/GPT  (GPT and GUID are the same thing).  External drives can be checked in disk utility under partitions.  Underneath the picture of the partitioning scheme, there is a button named options.  Click it, and you should be able to see what the partition table format is.  If it is GPT, you can proceed.  if it is not, the EFI bootloader will not work.

To make the drive GPT, it will need to be reformatted, erasing all the data on the disk, so don't convert unless you have somewhere to put those files.

Before you begin:


Create enough free space (unformatted) for Ubuntu to fit.

Grab a 1GB or larger flash drive and a DVD-R, or a 4GB or larger flash drive.

Recommended:  an ethernet adapter that works with the retina mac

Now for the actual guide.  Hopefully it is easy enough that people who are newer to linux can follow it.

1:  Install rEFInd

       The install.sh should be run in a Mac OS X partition with the --drivers option and I (personally) installed it to the Mac partition rather than the EFI (ESP according to the rEFInd guide).  For more information, the creator of rEFInd has this information organized already:  http://www.rodsbooks.com/refind/

so unzip the files, run the install.sh.

If you want to have Linux on an external hard drive, or want to dual-boot, you may run either option:

      ./install.sh --alldrivers

but if you want only Linux on your internal hard drive, you must run this:

       ./install.sh --esp --alldrivers

Test if rEFInd works.  It may take two reboots for it to load.

2:  Install Linux

 

The iso image for the daily build can be grabbed here:
http://cdimage.ubuntu.com/daily-live/current/

(grab the amd64 mac iso)

Insert an ethernet or wifi adapter if you have one.  If you have a thunderbolt ethernet adapter, you will need to plug it in before booting Ubuntu.

If not, you will need this .deb file and this driver package later:

http://archive.ubuntu.com/ubuntu/pool/main/b/b43-fwcutter/b43-fwcutter_015-14_i386.deb

http://www.lwfinger.com/b43-firmware/broadcom-wl-5.100.138.tar.bz2

Save them to the flash drive. 

Make the LiveCD

Reboot into the Ubuntu LiveCD through the rEFInd menu

Select try ubuntu.

Get the ethernet settings set up

run the installer with

      ubiquity -b

This will prevent it from installing grub.  Since we will be booting from the kernel itself, grub is not necessary for this install.

Go through the normal installation process

Select "continue to try ubuntu": there are a couple more steps to make this visible to the mac's EFI.

3:Configure rEFInd


Mount your /boot (if you made one) to your install's /boot or your hard drive's EFI (if you didn't) to your install's /boot/efi directory (make one if it isn't there.)

Create the path /boot/efi/EFI/ubuntu/

Then run:

     sudo cp /boot/vmlinuz<version> /boot/efi/EFI/ubuntu/vmlinuz<version>

     sudo cp /boot/initrd<version> /boot/efi/EFI/ubuntu/initrd<version>

As an example, my current vmlinuz and initrd reads vmlinuz-3.8.0-0-generic and initrd-3.8.0-0-generic. 

      Find your UUID with either "sudo blkid /dev/sdXY" (the one you want to know) or with  "ls -l /dev/disks/by-uuid/"  and finding the /dev/sdXY that you need

UUID is a long string of numbers and letters.

My options inside refind_linux.conf look like this:

"Boot using standard options" "root=UUID=<Your root partition's UUID> ro   quiet splash $vt_handoff"
"Boot using minimal options"  "root=UUID=<Your root partition's UUID> ro"
"Boot to shell"                           "root=UUID=<Your root partition's UUID> ro text"
"Boot using recovery options" "root=UUID=<Your root partition's UUID> ro recovery nomodeset"


This uses the kernel (which should be above 3.7 if you are following this guide) as the bootloader, with no requirements for grub.  (Grub can be safely ignored, as with this setup the mac cannot see grub as a boot option)

If you upgrade your kernel, you will need to also copy it inside the ubuntu folder like before.


4:Final Adjustments


At this point, reboot into your newly-working Ubuntu install.

(There should be an Ubuntu logo on the rEFInd boot selection screen)

Reconfigure wired internet if required.

Wireless Drivers


If you have Ethernet working


Download the drivers from here: 


open with the archive manager and extract wl_apsta.o to your home folder.

run
     sudo apt-get install b43-fwcutter

then run

     sudo b43-fwcutter -w /lib/firmware/`uname -r` ~/wl_apsta.o

     sudo modprobe b43

Wireless networking should be working.  If it isn't, reboot.

Without Ethernet

Mount your flash drive and move the files to your home folder.

Open the driver package with the archive manager and extract wl_apsta.o to your home folder.


       sudo dpkg -i b43-fwcutter.deb

       sudo b43-fwcutter -w /lib/firmware/`uname -r` ~/wl_apsta.o

      sudo modprobe b43

Wireless networking should be working.  If it isn't, reboot.

 Nvidia graphics


Nvidia drivers work from the standard repository (run

           sudo apt-get update; sudo apt-get install nvidia-current

in the terminal), but the setting must be configured by the Nvidia x Server settings program to display properly.


Reboot after install.  I saw 3 mirrored 800x600 screens stacked on top of each other, with garbage to the right.

Open the x server settings. 

Selection:  change to  X screen 0

click advanced

click X server Display Configuration

click the first button after "metamode" and select nvidia auto-select

hit apply.  if the screen goes back to looking like a 2880x1800 screen, reopen x server settings if it closed, check the configuration to make sure it's the same, and click "save to X configuration file"  This will keep this setting throughout reboots.

*For changing the resolution, after the NVIDIA graphics is set up correctly, my second post has a scrip that you can use.*

Changing the desktop environment:


This should work.  If you speakers stop working after installing it, run

sudo apt-get remove --purge alsa-base
sudo apt-get remove --purge pulseaudio
sudo apt-get install alsa-base
sudo apt-get install pulseaudio
sudo alsa force-reload

The current status below is in a shorthand, descriptive format.

Retina Macbook Pro Ubuntu 13.04 daily-build, installed on eternal hard drive.

Desktop Environment:  Cinnamon
Steam for Linux working properly
EFI boot working
Nvidia Graphics working (yes, at the same time as EFI booting)
full screen resolution  2880x1800

Current Status:

      Kernel of LiveCD and installed OS does not require any extra configuration from the default. Thunderbolt and USB to ethernet adapters work, but only when plugged in from boot.

      b43 wireless drivers work after install with sudo modprobe b43 with a reboot, using the standard b43-fwcutter with the open-source broadcom driver 5.100.138. No network drops seen so far.

      The booting is handled by rEFInd using the kernel as an EFI stub inside the external drive's ESP (labelled EFI) in the GUID as described by the creator of rEFInd. http://www.rodsbooks.com/ubuntu-efi/index.html

       Installing cinnamon desktop destroyed detection of sound card, though it can be fixed by reinstalling alsa-core and pulseaudio and running sudo alsa force-reload

      At this point, everything that I have tested works. The system usually reports a couple crashes early on after login which don't affect the stability. One freeze has been seen while changing the auto-hide option in the cinnamon settings, but  later attempts to recreate failed, so no confirmed bugs.

      The trackpad is sensitive to the lightest tap, so a USB mouse in recommended, though I had heard of someone editing the trackpad config... which if I get around to it I will include in another post. The keyboard works normally, AFAIK.

      With the latest updates and the proper libraries, steam and TF2 work, although TF2's frame-rate is choppy and resolution cannot be changed in TF2 in fullscreen mode. Unknown whether this is an issue with hardware or optimization by Valve being incomplete or something else entirely.

Enjoy having linux on that 2880x1800 screen!
 



16 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Followed your guide to the letter, but when I try to boot into the installed copy of Ubuntu, it always hangs at "Disabling IRQ #17." I can't get past that.

    I've tried booting into recovery mode, then booting normally from there, but when I do that it's unable to access the whole filesystem; it just boots to a command prompt that can only access a file called something like example.desktop.

    Got any suggestions?

    ReplyDelete
  3. A quick question. Did you try cd / and ls to see if you could get to your root directory? You can also attempt to start the xserver with startx

    If you installed the nvidia drivers, I'd recommend editing /etc/X11/xorg.conf that was generated by the nvidia drivers so that the section "Device" looks like this:
    Section "Device"
    Identifier "Device0"
    Driver "nvidia"
    VendorName "NVIDIA Corporation"
    Option "UseDPLib" "off"
    EndSection

    If you don't have an xorg.conf or it doesn't have nvidia drivers enabled, run sudo nvidia-xconfig and then change it. Sometimes I have trouble booting straight into the OS, but going through the recovery mode works.

    ReplyDelete
  4. I got the same hang on Disabling IRQ #17 after upgrading to the 3.8.0-11 kernel. 3.8.0-9 still works for me.

    ReplyDelete
  5. Getting a back screen on reboot after nVidia driver installation. instead of " I saw 3 mirrored 800x600 screens stacked on top of each other, with garbage to the right."

    ReplyDelete
    Replies
    1. There were points when I was having issues with the nvidia drivers as well, and I would get this issue. There are a couple ideas to try. First, try changing the xorg.conf file like I mentioned above. Second, try booting into text mode and adding the xorg-edgers ppa: sudo apt-add-repository ppa:xorg-edgers/ppa and then install nvidia-313. Those are the drivers I've been using lately. I still have to boot through the recovery mode though... I had run into issues with the module not being installed, so 'modprobe nvidia' would fail. Check to make sure you have headers installed at the very least. Failing that, the kernel version may be the problem, as I was having the most trouble where certain kernels would work, but none of the others would. Using the xorg-edgers ooa should solve this, but you might try a different kernel version which can be grabbed from http://kernel.ubuntu.com/~kernel-ppa/mainline/ You can download the packages manually or you can find a guide for the specfic kernel you want from upubuntu ex. http://www.upubuntu.com/2013/03/installupgrade-to-linux-kernel-383-in.html (I happen to be using 3.8.3 right now, and it is working well for me.)

      Delete
  6. don't you mean:

    sudo apt-get remove --purge alsa-base

    there isn't a alsa-core package

    ReplyDelete
  7. Hi,
    I get "boot error" when I tried to boot from the live USB drive. But I can install Ubuntu 12.04 this way and 13.04 is a no-go.
    Thanks,
    Phil

    ReplyDelete
  8. Hi Travis,

    Thanks so much for the write-up! I ordered the rMBP last week, specifically with the intention of booting Ubuntu as my main OS. Some thoughts and notes of my experience, for you and others after me:

    I made a bootable USB as you instructed on a 16GB stick from the nightly builds, and I copied the wireless drivers to another 512MB USB stick. This is how I got my initial wireless drivers on, as I don't have a network adapter.

    I copied the /boot/* files from the installed directory which I mounted with sudo mount /dev/sda5 /mnt (5 was the number for my disk) and then sudo mkdir -p /mnt/boot/efi/EFI/ubuntu, and cp'd /mnt/boot/ /mnt/boot/efi/EFI/ubuntu. Just a tip as I was unsure where the /boot/ files were support to come from initially and how to mount the new install.

    The first time I tried to boot did not work. The first choice in the EFI list (I only have two Linux choices) are "minimal" and "standard", so the "minimal" one gets stuck while booting on the "Disabling IRQ #17" message that others saw. But the "standard" (second in my list) works fine, so make sure you pick the right choice or you'll be disappointed.

    After that I just followed the instructions about installing the wireless, copied the files from my 512MB USB stick, installed, and rebooted. The wireless worked straight away. Audio also worked out of the box. Yay! At this point I had a (nearly) fully working system.

    I then did the nvidia install as instructed up to the point of rebooting, when I rebooted I got a black screen as the other dude here in the comments got. I noticed that there was no /etc/X11/xorg.conf at all! That's weird! Why didn't nvidia's installer make one or run nvidia-xconfig or something? Anyhoo, I booted up on my Live USB again and sudo mount /dev/sda5 /mnt again to look at the X11 config. There was, fortunately, a dummy backup config like /etc/X11/xorg.conf.sample which had a couple "default" sections. I just changed the Device section to the one you instructed to Simon above and it was fine. You mentioned in your post "the setting must be configured by the Nvidia x Server settings program", but I didn't really know what that implied I should do, if anything, so I just rebooted. If anyone else did that, this solution might work.

    Now I have a working system with a big-ass resolution. For now I installed unity-tweak-settings and doubled the size of text and installed NoSquint for FireFox. It's not a long-term solution, but it's good enough for now to avoid the initial jarring tiny-text.

    Good luck, everyone! Text on this thing looks outstanding!

    ReplyDelete
    Replies
    1. Hi,

      Thanks for sharing this information. I'm having the same (or similar) problem with the the Nvidia driver. Could you tell me which driver version you used and which kernel you have? I cannot see any *xorg* file in my /etc/X11/. I guess I should just create one...

      Could you or anybody with working Nvidia drivers post what exactly they have in their xorg.conf?
      Thanks.

      Delete
    2. For anyone who doesn't see the xorg.conf file, that's because Ubuntu works without needing one. Run sudo nvidia-xconfig in your terminal, to create it then modify it like I stated above. It should work then. Or, if you have a sample or dummy xorg.conf, you should be able to modify that in the way that Christopher did to get it working.

      Delete
  9. I am currently stuck at this point:
    Without Ethernet
    Mount your flash drive and move the files to your home folder.

    Open the driver package with the archive manager and extract wl_apsta.o to your home folder.


    sudo dpkg -i b43-fwcutter.deb

    Terminal begins to install b43-fwcutter but then I get an error that libc6 (>=2.4) is not installed or available (or something along those lines). I have done extensive searches as to how to resolve this and the closest I've come is someone redirecting themselves to this page and that it solved their issue. I have followed the instructions on this site "to the T" thus far and everything has gone smoothly. But I am unable to get wireless installed if this "libc6 error" persists. I am at a loss right now and am unsure what can be done.

    Any help or guidance would be much appreciated.

    Thanks

    ReplyDelete
    Replies
    1. Huh. Libc6 is a core package, I believe... so if it isn't there that's a problem. You might try checking the md5 sum of the image or re-downloading it. I haven't seen a problem like that when I've worked with Linux, so my only guess is that it didn't download correctly. At this point in time, it's much better to download the latest bcmwl-kernel-source package from Ubuntu's site: http://packages.ubuntu.com/raring/bcmwl-kernel-source because it has updated official broadcom drivers that work with the wireless chip. At that point, wireless should be working, and you can continue with the internet-enabled instructions.

      Delete
  10. For anyone having the issue with a black screen after installing the graphics driver (on an EFI-based install), all you have to do is install NVIDIA's latest driver using xorg-edgers (remove the malfunctioning driver first of course). It should work without any additional hassle, at least on Macbook Pro 10,1

    ReplyDelete