Page 1 of 3 123 LastLast
Results 1 to 10 of 24

Thread: Running Ubuntu 12.04 on a 2012 MacBook Air (5,2)

  1. #1
    Join Date
    Apr 2005
    Location
    Portland, OR
    Beans
    90

    Running Ubuntu 12.04 on a 2012 MacBook Air (5,2)

    I recently obtained a 2012 13" MacBook Air (MBA) to use as a development laptop. The documentation on installing and running Linux on this year's model is fairly sparse and had to be collected and verified from numerous sources, so I'm summarizing it here in this post in the hopes it will be helpful to others. Follow these instructions at your own risk, and acknowledge that I accept no responsibility for possible damage that could happen to your computer due to following these instructions.

    I will try to edit and maintain this post as I learn new information or others correct me for any misundertandings (which I highly encourage you to do).

    I have absolutely no interest in OS X (and to be honest feel more than a tad hypocritical for buying an Apple product, but that's a rant for another time), so my goal was just to wipe the default OS and install a Linux distro (Ubuntu 12.04, "Precise Pangolin") natively. Before doing this, however, you may want to boot OS X just to mute the audio, otherwise you'll be stuck with the Apple "bong" sound when turning the machine on. This sound and its volume level are apparently encoded in the MacBook's firmware, and I'm not aware that it's possible to mute it without doing so from OS X.

    Installation

    If you want to dual-boot your system with Linux and OS X, I have no experience with that, but I've heard that you may need to use an OS X utility called rEFIt to set up your partitions before booting your Linux installer - more details can be found in this Ubuntu Mactel Installation Guide.

    A number of people have reported problems trying to get the default Ubuntu 12.04 install CD or USB installation method to work. Thanks to this blog post, I learned that you can download an alternate Ubuntu 12.04 install ISO that is formatted differently to boot properly on UEFI-based Apple hardware. Additionally, this nightly image includes all of the package updates that have been released for 12.04, saving you time from having to download and install them. Download the precise-alternate-amd64+mac.iso file from here, and then simply dd it to a 1 GB or larger USB key. Of course you'll want to dd this to the full disk device name, e.g, /dev/sdb and not /dev/sdb1.

    Now plug that USB key into your MBA and hold down the Alt key while powering the computer on. Select the "Windows" disk to boot from and the Ubuntu alternate installer should come up. After selecting my language, I hit F6 and enabled the "noapic" boot option, which I've heard is necessary for stability. From there the install went smoothly - there was one warning about the broadcom wifi driver needing additional firmware, but that was safe for me to ignore, and on the first bootup the open source broadcom wifi driver seemed to work fine.

    Post Install

    At this point you should be able to boot into 12.04 (TODO: you still need to hold down the Alt key when powering the system on, I need to find out how to make it boot into Ubuntu automatically). You should be gentle with the system now, because the applesmc kernel driver that ships with 12.04 does not work properly with the 2012 hardware and your CPU fans will be locked at their lowest speed, 2k RPM.

    Most of the remaining information I gleaned from this excellent guide and post-install script which was written for the 2011 MBA.

    I'm copying portions of this script that I was able to run verbatim:

    Code:
    # --- macfanctld
    # It is highly recommended to use the fan controller daemon that is included in
    # the mactel-support ppa called macfanctl. 
    echo "Adding macfanctld ppa (fan control daemon)."
    sudo add-apt-repository ppa:mactel-support/ppa
    
    # --- lightum
    echo "Adding lightum ppa (automatic light sensor daemon)."
    sudo add-apt-repository ppa:poliva/lightum-mba
    
    # --- broadcom-sta
    echo "Adding broadcom-sta ppa (better wireless module)."
    sudo add-apt-repository ppa:poliva/pof
    
    # --- fix 30seconds wifi timeout using wl driver
    sudo aptitude purge bcmwl-kernel-source
    
    echo "Installing packages."
    sudo aptitude update
    sudo aptitude install macfanctld lightum lightum-indicator lm-sensors broadcom-sta-dkms
    Critically Important Note: the mactel-support repo also has an updated applesmc kernel module that works with the 2012 MBA, so install that too and load the module:

    Code:
    sudo aptitude install applesmc-dkms
    sudo modprobe applesmc
    Back to that post-install-precise.sh script - you should be able to run these sections verbatim:

    Code:
    # The program lmsensors detects the sensors, however it does not know what they
    # are yet. The module coretemp will allow lm-sensor to detect the others
    # sensors, the rotation speed of the fan, and the GPU temperature.
    sudo tee -a /etc/modules <<-EOF
    	coretemp
    	hid_apple
    EOF
    
    # make function keys behave normally and fn+ required for macro
    sudo tee -a /etc/modprobe.d/hid_apple.conf <<-EOF
    	options hid_apple fnmode=2
    EOF
    sudo modprobe coretemp hid_apple
    
    # blacklist conflicting wireless module
    sudo tee -a /etc/modprobe.d/blacklist-bcma.conf <<-EOF
    	blacklist bcma
    EOF
    
    # configure macfanctld
    tee <<-EOF
    	Configuring macfanctld to ignore some sensors. On my system three
    	sensors gave bogus readings, i.e.,
    	    TH0F: +249.2 C                                    
    	    TH0J: +249.0 C                                    
    	    TH0O: +249.0 C
    	Run 'sensors' to see current values; run 'macfanctld -f' to
    	obtain the list of sensors and their associated ID.
    	Applying this exclude: 13 14 15.
    EOF
    sudo service macfanctld stop
    sudo cp /etc/macfanctl.conf /etc/macfanctl.conf.$(date +%Y-%m-%d)
    sudo sed -i "s/\(^exclude:\).*\$/\\1 13 14 15/" /etc/macfanctl.conf
    sudo service macfanctld start
    At this point I recommend rebooting and ensuring that the system comes back up with the coretemp, hid_apple, and (most importantly) applesmc kernel modules loaded (lsmod will show you your loaded kernel modules). Also make sure that macfanctld is running - while on some systems this daemon is optional, I believe it is mandatory for the 2012 MBA.

    I also will keep a terminal window open running watch sensors to keep an eye on the CPU temperatures and fan speed. The fan speed should start around 2k rpm and go up to 6.2k rpm when the CPUs heat up. If this doesn't happen, you could be damaging your system!

    Power Management

    By default, suspend to RAM works, but there are a number of tweaks you can make to reduce power consumption.

    Again, from the post-install-precise.sh script:

    Code:
    echo "Fixing post-hibernate hang."
    sudo tee -a /etc/pm/config.d/macbookair_fix <<-EOF
    	# The following brings back eth0 after suspend when using the apple usb-ethernet adapter.
    	SUSPEND_MODULES="asix usbnet"
    EOF
    
    # no password after resume (like mac)
    echo "Disable lock screen after resume."
    gsettings set org.gnome.desktop.lockdown disable-lock-screen 'true'
    
    
    # --- Boot ------------------------------------------------------
    
    echo "Setting boot parm (better power usage)."
    sudo cp /etc/default/grub /etc/default/grub.$(date +%Y-%m-%d)
    SWAP=$(cat /etc/fstab |grep "# swap was on" |awk '{print $5}')
    sudo sed -i "s:\(GRUB_CMDLINE_LINUX_DEFAULT=\).*\$:\\1\"quiet splash i915.i915_enable_rc6=1 resume=${SWAP}\":" /etc/default/grub
    sudo update-grub
    
    echo "Ensuring bcm5974 loads before usbhid (editing /etc/rc.local)."
    # update /etc/rc.local to ensure bcm5974 is loaded BEFORE usbhid
    sudo cp /etc/rc.local /etc/rc.local.$(date +%Y-%m-%d)
    sudo sed -i '$i modprobe -r usbhid\nmodprobe -a bcm5974 usbhid' /etc/rc.local
    
    echo "Configuring extra power management options."
    wget -Nq http://pof.eslack.org/archives/files/mba42/99_macbookair || wget -Nq http://www.almostsure.com/mba42/99_macbookair
    chmod 0755 99_macbookair
    sudo mv 99_macbookair /etc/pm/power.d/99_macbookair
    # disable bluetooth by default
    sudo sed -i '$i /usr/sbin/rfkill block bluetooth' /etc/rc.local
    Backlit Keyboard and Ambient Light Sensor

    lightum is a background program that controls your keyboard backlight and LCD screen brightness according to the ambient light sensor. It works just fine on my 2012 MBA:

    Code:
    # --- enable lightum
    /usr/bin/lightum
    /usr/bin/lightum-indicator &
    gsettings set org.gnome.settings-daemon.plugins.power idle-dim-ac 'false'
    gsettings set org.gnome.settings-daemon.plugins.power idle-dim-battery 'false'
    For more lightum configuration options, check out the lightum README.

    Touchpad

    The default settings the synaptic touchpad comes with in 12.04 were driving me nuts. I discovered I could even hover my finger a millimeter or so over the touchpad and make the mouse move, it was so overly sensitive. I owe a debt of gratitude to the author of this blog post for clearly describing the problematic default settings and how to change them.

    What Doesn't Work

    The Thunderbolt to Ethernet adaptor does not work, you'll want to pick up a USB to Ethernet adaptor instead.

    Other Notes

    The iSight camera works with cheese. I haven't tried it with Skype yet.

    I have not tested hibernate or using an external display yet, but I have heard they should work.

    I've tried running some of the Ubuntu 3.4 kernels, but haven't seen any noticable improvements from them, and sometimes they have introduced new problems. For example, with kernel 3.4.7, I found that the graphical login screen wouldn't come up after booting, so I'd have to go to a virtual console, login, and sudo service lightdm restart to get it to come up.

    Enjoy,

    Scott
    Last edited by sgarman; August 9th, 2012 at 09:24 PM.
    Free Software - It's About Freedom

  2. #2
    Join Date
    Feb 2007
    Beans
    32
    Distro
    Kubuntu 9.04 Jaunty Jackalope

    Re: Running Ubuntu 12.04 on a 2012 MacBook Air (5,2)

    Works like charm.

    I created BOOT USB and that's it.

    Total installation took 10 mins.

    Also I am getting 7 hours battery!!!!

    Shiva
    Last edited by shivathreya; August 11th, 2012 at 02:32 PM.

  3. #3
    Join Date
    Aug 2012
    Beans
    1

    Re: Running Ubuntu 12.04 on a 2012 MacBook Air (5,2)

    This guide looks great! I'm on a mba 3.1 with ubuntu 12.04 and thinking about upgrading to an mba 5, because my garantie has run out, but also because I hope the hardware will support ubuntu better. Flash, minecraft, and basicly everything that uses my graphic card causes the computer to heat up more than i think it should. How is that on the mba 5?

  4. #4
    Join Date
    Apr 2011
    Beans
    6

    Re: Running Ubuntu 12.04 on a 2012 MacBook Air (5,2)

    Thank you so much for that post. I have it all up and running on my macbook air. I do have one issue, and I'm not sure what is the cause. The function keys seem to be remapped. I can hit the function key and change the volume, display brightness, etc, however hitting them normally does not do the actual shortcuts. For instance, hitting f11 opens and closes a tab in my browser instead of togging full screen.
    Does anyone have any clue on what I can configure to correct this?

    EDIT: just reran the above script by copying into gedit and running it through the terminal. all seems well now. I copied it all line by line earlier, so I'm not sure what was different, but it worked.
    Last edited by asting; September 20th, 2012 at 03:15 AM.

  5. #5
    Join Date
    Jun 2012
    Beans
    8

    Re: Running Ubuntu 12.04 on a 2012 MacBook Air (5,2)

    I have a question about the following text:
    You should be gentle with the system now, because the applesmc kernel driver that ships with 12.04 does not work properly with the 2012 hardware and your CPU fans will be locked at their lowest speed, 2k RPM.
    Should I update to the current packages during installation with Wlan (internet) to the current packages (flag in installation on Ubuntu setup) or should I better wait after loading the fan control module and kernel module (for more fan speed) to start the update manager??
    I don't want to destroy hardware during installation/update process.

    And a second question: How about 12.10? Is it possible to make a distribution-upgrade from 12.04 to 12.10 when 12.10 is officially released??

  6. #6
    Join Date
    Apr 2005
    Location
    Portland, OR
    Beans
    90

    Re: Running Ubuntu 12.04 on a 2012 MacBook Air (5,2)

    Quote Originally Posted by mlux View Post
    I have a question about the following text:
    Should I update to the current packages during installation with Wlan (internet) to the current packages (flag in installation on Ubuntu setup) or should I better wait after loading the fan control module and kernel module (for more fan speed) to start the update manager??
    I don't want to destroy hardware during installation/update process.

    And a second question: How about 12.10? Is it possible to make a distribution-upgrade from 12.04 to 12.10 when 12.10 is officially released??
    I'd recommend waiting to update your packages until after getting fan control working, just to stay on the safe side.

    As for distribution upgrades, I never do them, even on my non-Apple hardware. Been burned too many times, and I maintain a text file of most of my OS customizations so it's a bit more convenient for me to run though those changes at all once after doing a full install from scratch.

    Scott
    Free Software - It's About Freedom

  7. #7
    Join Date
    Jun 2012
    Beans
    8

    Re: Running Ubuntu 12.04 on a 2012 MacBook Air (5,2)

    Thank you very much Scott. I will get the hardware next week!
    So I try to install 12.04 and wait for a HowTo before installing 12.10.

    One other question:
    I purchased an i7 CPU on my MacBook Air 13". Is there any difference for the scripts to an i5 (common - most people have) => e.g., in view of the fan control....
    Last edited by mlux; September 27th, 2012 at 07:09 AM.

  8. #8
    Join Date
    Apr 2005
    Location
    Portland, OR
    Beans
    90

    Re: Running Ubuntu 12.04 on a 2012 MacBook Air (5,2)

    Quote Originally Posted by mlux View Post
    I purchased an i7 CPU on my MacBook Air 13". Is there any difference for the scripts to an i5 (common - most people have) => e.g., in view of the fan control....
    No difference - I also have an i7 in my MBA.

    Scott
    Free Software - It's About Freedom

  9. #9
    Join Date
    Jun 2012
    Beans
    8

    Re: Running Ubuntu 12.04 on a 2012 MacBook Air (5,2)

    edit2: now, all it is working
    Last edited by mlux; October 5th, 2012 at 11:02 PM.

  10. #10
    Join Date
    Feb 2012
    Location
    Los Angeles, CA
    Beans
    138
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Running Ubuntu 12.04 on a 2012 MacBook Air (5,2)

    Pure excellence.

    This is the standard post for struggling Ubuntu mac users to refer to. After dealing with a rather clunky Mac, the post helped me improve my system from nothing to beyond miracles, as if everything works straight out of the box! Thanks for this really useful post!!! I mean, palm rest works!

    It would be great if Canonical can implement these scripts for their next releases. Is it possible?

Page 1 of 3 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •