MacBook

From ArchWiki
Revision as of 15:07, 30 December 2009 by Frigaut (Talk | contribs)

Jump to: navigation, search

Installing Arch Linux on a MacBook is quite similar to installing it on any other computer. However, due to the specific hardware configuration on a MacBook, there are a few deviations and special considerations which warrant a separate guide. For more background information, please see the Official Arch Linux Install Guide, Beginners Guide, Beginners Guide Appendix, and Post Installation Tips. This guide should also work for the MacBook Pros 5 serie, and apply to both the 32 and 64 bits versions. Template:Article summary start Template:Article summary text Template:Article summary heading Template:I18n entry Template:I18n entry Template:Article summary heading Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary end

Overview

Specifically, the procedure for installing Arch Linux on a MacBook is:

  1. Install Mac OS X: Regardless of the desired end-configuration, it helps to start from a clean install of OS X.
  2. Firmware Update: This should help reduce errors and provide newer features for the hardware.
  3. Partition: This step either resizes or deletes the OS X partition and creates partitions for Arch Linux.
  4. Install Arch Linux: The actual installation procedure.
  5. Post-Install Configuration: MacBook specific configuration.
Tip: rEFIt is a popular bootloader for EFI-firmware computers (including Macs). It can be installed at any time during the installation. For instructions, please see rEFIt.

Installation of Mac OS X and Firmware Update

Apple already has excellent instructions for installing Mac OS X. Follow their instructions. Finally, once OS X is installed, go to:

Apple Menu --> Software Update

And update all software. Once this has run, you will need to reboot your computer. Do this, and then run Software Update again to check to make sure that all updates have been installed.

Note: Sometimes Software Update may not pick up all the firmware updates available for your computer. However, you can try to search this upgrades directly into the Apple's Support site.

If you are not going to have Mac OS X installed, you need to make a backup of the file:

/System/Library/Extensions/IOUSBFamily.kext/Contents/PlugIns/AppleUSBVideoSupport.kext/Contents/MacOS/AppleUSBVideoSupport

You will need this file later for iSight functionality.

Partition

The next step in the installation is to re-partition the hard drive. If Mac OS X was installed using the typical procedure, then your drive should have a GPT format and the following two partitions:

  • EFI partition: a 200 MB partition at the beginning of the disk.It is often read as msdos or FAT by some partitioning tools and usually labelled #1
  • Mac OS X partition: the (HFS+) partition that should take up all of the remaining disk space. Usually labelled #2.

How to partition depends on how many operating systems you want install. The following options will be proposed here:

If you don't know which option to pick, we recommend the dual boot so you can still return to Mac OS X whenever you want.

Arch Linux Only

This situation is the easiest to deal with. Mostly, partitioning is the same as any other hardware that Arch Linux can be installed on. The only special consideration is the MacBook firmware boot sound. To ensure that this sound is off: mute the volume in Mac OS X before continuing further. The MacBook firmware relies on the value in Mac OS X, if available. Note that if you choose to get rid of the OsX partition, there is no easy way to update your machine firmware.

Then partition with parted. The simplest way is to change the partition table to msdos and then partition as normal. If you decide to use the GPT format, GRUB will not be able to recognize the partitioning scheme.

Note: to partition with parted, just boot the Arch Linux core install disk and run parted from the root account before using the install program.

Once you have finished this part, please move on to Installation section.

Mac OS X with Arch Linux

The easiest way to partition your hard drive, so that Mac OS X and Arch Linux will co-exist, is to use partitioning tools in Mac OS X and then finish with Arch Linux tools.

Warning: It is highly recommended that this only be attempted after a clean install of Mac OS X. Using these methods on a pre-existing system may have undesired results.

Procedure:

  • In Mac OS X, run Disk Utility (located in /Applications/Utilities)
  • Select the drive to be partitioned in the left-hand column (not the partitions!). Click on the partition tab on the right.
  • Select the volume to be resized in the volume scheme.
  • Decide how much space you wish to have for your Mac OS X partition, and how much for Arch Linux. Remember that a typical installation of Mac OS X requires around 15-20 GiB, depending on the number of software applications and files.
  • Finally, type the new (smaller) size for the MacOS partition in the size box and click apply. This will create a new partition out of the empty space.
Note: if you wish to have a shared partition between Mac OS X and Arch Linux, then additional steps will need to happen here. Please see Shared Partition.
  • If the above completed successfully, then you can continue. If not, then you may need to fix your partitions from within Mac OS X first.
  • Boot the Arch install CD and run parted
# parted
  • Delete the empty space partition and partition the space as you would for any other installation. Note that MBR is limited to 4 primary partitions (including the efi partition). That leaves 2 primary partitions for arch. One strategy is to have a system and home partition, and use a swap file (I haven't tried to use logical partitions). Another is to dedicate one partition to a shared partition (see below).
  • At this point, if you are dual booting, you should reboot your computer and have rEFIt fix the partition tables on your hard drive. (If you don't do this, you may have to reinstall GRUB later on in order to have your Mac recognize the Linux partition.) When you are into the rEFIt menu, select update partition table, then press Y.
# reboot

Installation

Note: This section is only required if you want to have Mac OS X installed along with Arch Linux. If not, follow the steps in the official install guide, then skip to post install.
  • Boot from the Arch Linux install CD. Type arch at the boot prompt or arch vga=773 if you prefer a higher console resolution.
boot: arch vga=773
Note: some MacBook users report strange keyboard output such as long delays and character doubling. If this is your situation, boot with follows options.
boot: arch noapic irqpoll acpi=force
  • Log in as root
  • Run the Arch installer:
/arch/setup
  • Proceed through the installation as described in the Official Arch Linux Install Guide except in the following areas:
    • In the prepare hard drive stage do only the set filesystem mountpoints step, taking care to assign the correct partitions.
    • In the install boot loader stage, edit the menu.lst file and add reboot=pci to the end of the kernel lines, for example:
      kernel /vmlinuz26 root=/dev/sda5 ro reboot=pci
      This will allow your MacBook to reboot correctly from Arch.
    • Also in the install boot loader stage, install GRUB on whatever partition that /boot is on.
      Warning: Do not install GRUB onto /dev/sda !!! Doing so is likely to lead to an unstable post-environment.
    • In the configure system stage, edit /etc/mkinitcpio.conf and add the usbinput hook to the HOOKS line somewhere after the autodetect hook. This will load the drivers for your keyboard in case you need to use it before Arch boots (e.g. entering a LUKS password or using the troubleshooting shell).
  • When the install process is complete, reboot your computer.
# reboot
  • Hold down the eject key as your MacBook starts, this should eject the Arch Linux install disk.

Post-Install Configuration

Tip: MacBooks require some extra software from AUR. You may wish to install this software speedly; then you should install Yaourt.
Tip: this software and its configuration require Root Privileges. To speed up this procedure i hint you to install Sudo.
Tip: follow one section at time.

Xorg

Install and configure Xorg by following the Xorg article.

Video

Different MacBook's models have different graphic cards.

To see which graphic card do you have type:

# lspci | grep VGA

If it returns a string with intel you need xf86-video-intel driver. You can install it typing

# pacman -S xf86-video-intel

If it returns nvidia

# pacman -S nvidia

Otherwise if it returns ATI

# yaourt catalyst

At least, intel users don't need any other work; instead others users need a basic xorg.conf file where you can specify the right driver to use.

To configure it read those pages ATI or NVIDIA.

Touchpad

The touchpad should have basic functionality by default.

To configure advanced functions, see Touchpad Synaptics and Xorg input hotplugging.

Keyboard

MacBook keyboard works by default. Only the eject key isn't recognized properly.

To enable it you can map with right application like xbindkeys or through DE preferences; but another very good way, that we recommend, is to install pommed from AUR.

To install and configure pommed is easy:

# yaourt pommed

to install it, after

Edit the /etc/pommed.conf according to your hardware on MacBook, building
it from /etc/pommed.conf.mac or /etc/pommed.conf.ppc example files.

Note that you can also run it without a configuration file, the defaults may work for you. Then

Put pommed at the end in your DAEMONS array in your /etc/rc.conf

finally reboot your pc.

Tip: if you are using Gnome or KDE you can easily configure 3rd level functionality, multimedia key, etc. in Keyboard Preferences.
Note: see the Xorg input hotplugging page for other configuration information.

Wifi

Different MacBook models have different wireless cards.

You can easily check what card do your MacBook have by:

# lspci | grep Network
  • if you have an Atheros all should works-out-of-the-box.

Power management

Suspend (the kernel suspend) should work out of the box (I had a problem in which the machine would "suspend immediately after resume" in certain conditions when suspending by closing the lid. This was solved by de-selecting the option "event_when_closed_battery" in gconf-editor → gnome-power-manager → actions).

Hibernate should work if you have a swap partition. If you opted for a swap file because of the MBR limitation to 4 primary partitions, you can still get hibernate functionality by following these instructions (this is mostly taken from http://ubuntuforums.org/showthread.php?t=1042946):

  • Create a swapfile (here 2G = bs*count):
sudo dd if=/dev/zero of=/swapfile bs=1024 count=2M

It is recommended, but not necessary, to create the swapfile on a newly created partition, so that fragmentation is minimum.

# chmod 600 swapfile 
# mkswap swapfile 
mkswap: swapfile: warning: don't erase bootbits sectors
        on whole disk. Use -f to force.
Setting up swapspace version 1, size = 2097148 KiB
no label, UUID=6bf46166-4f9e-433a-aac1-91cb3f5cf8ba
# 
Note that we won't use this UUID later.
  • Add the swapfile in fstab:
/swapfile   none   swap   sw   0   0
  • Determine the UUID of partition on which the swapfile is (/sbin/blkid is provided by util-linux-ng)
# blkid -g
# blkid
/dev/sda4: UUID="388014d3-1d18-4ca0-980e-ef2f9fdebde4" TYPE="ext3" 

388014d3-1d18-4ca0-980e-ef2f9fdebde4 is the number we're looking for.

  • Determine the physical offset of the swapfile:
$ sudo filefrag -v /swapfile | head
Filesystem type is: ef53
Filesystem cylinder groups is approximately 132
File size of /swapfile is 2147483648 (524288 blocks, blocksize 4096)
 ext logical physical expected length flags
   0       0    24576              12 merged
   1      12    24589    24587   1024 merged
   2    1036    25615    25612   1024 merged
   3    2060    26640    26638   1024 merged
   4    3084    27665    27663   1024 merged
   5    4108    28690    28688   1024 merged
$ 

Here, 24576 is the number we want.

  • Edit /boot/grub/menu.lst and add:
resume=/dev/disk/by-uuid/388014d3-1d18-4ca0-980e-ef2f9fdebde4 resume_offset=24576

to your kernel stanza options (or use the kopt method as in the post). Note that the "resume=UUID=" actually didn't work for me. I had to use the /dev/disk/by-uuid syntax.

  • Nothing to do with update-grub nor mkinitcpio.
  • Reboot once
  • Try to hibernate

Sound

First of all follow ALSA wiki page, then if something doesn't work correctly, continue reading this part.

Edit your /etc/modprobe.d/50-sound.conf or /etc/modprobe.d/modprobe.conf appending this line:

options snd_hda_intel model=intel-mac-auto

This should automatically specify the codec in your MacBook. Alternatively, for MacBookPro5,X, you can use:

options snd_hda_intel model=mb5

(note that the jack output is controlled with "HP").

If you have an iMac8,1, you should instead use

options snd-hda-intel model=mbp3 position_fix=2
Note: you can try to specify other options, agree with in your hardware. All other possible settings are listed in Kernel Documentation, avaible online:

Then, reboot.

Bluetooth

See the article on Bluetooth to install and configure all software needed.

Then if Bluetooth doesn't work out-of-the-box, you should edit your /etc/conf.d/bluetooth to enable hid2hci by uncommenting related line as follows:

HID2HCI_ENABLE="true"

Then restart your bluetooth daemon or simply reboot your pc.

Tip: for advanced bluetooth information see Bluetooth page.

iSight

Note: linux kernel from 2.6.26 includes the Linux UVC driver natively. You will not need to download the driver sources manually unless you want to test a newer version or help with development. iSight should work out of the box for these kernel versions and up.

iSight webcams require the Apple's proprietary firmware that can't be redistributed because proprietary. Then we must extract it from MacOS and load it Arch.

Tools to extract firmware is available at http://bersace03.free.fr/ift/ but we can found it on AUR isight-firmware-tools.

Instructions:

First you need to get the firmware out of a particular file located on your OS X install. It is located in /System/Library/Extensions/IOUSBFamily.kext/Contents/PlugIns/AppleUSBVideoSupport.kext/Contents/MacOS/AppleUSBVideoSupport.

To get it, mounts the MacOSX drive with:

# sudo mkdir /media/MacOSX
# sudo mount -t hfsplus /dev/sda2 /media/MacOSX

Then install the firmware extractor and let it do the work for you

# yaourt isight-firmware-tools

and click OK to accept the default path (/media/MacOSX/System...).

When it's done check that the firmware has been found:

# ls /lib/firmware/isight.fw

Once that is done, you need to completely SHUTDOWN your Mac and start it back up again (because this clears the hardware state of the camera).

Tip: to save very much time in the future, you just need to place the isight.fw file you saved in /lib/firmware/ and then shutdown and reboot as instructed above.

Finally you can load the uvcvideo module or add it at the end of MODULES() array into your /etc/rc.conf if you want it to load at boot.

Everything should works.

To test it there are many software:

  • MPlayer
# mplayer tv:// -tv driver=v4l2:width=1280:height=1024:device=/dev/video0 -fps 20
  • Cheese
  • Skype
  • Ekiga

Temperature Sensors

For reading temperature just install and configure lm_sensors. See Lm sensors page.

Color Profile

We can use color profiles from Mac OS.

First install xcalib from AUR:

# yaourt xcalib

Second copy pre-saved color profiles placed in /Library/ColorSync/Profiles/Displays/ on Mac OS partition to ~/colorprofiles/ for example.

There are color profile files agree with in MacBook models; select the right one:

  • Color LCD-4271800.icc for MacBook Pro with CoreDuo CPU
  • Color LCD-4271880.icc for MacBook with Core2Duo
  • Color LCD-4271780.icc for MacBook (not Pro) based on CoreDuo or Core2Duo.
Tip: also Mac OS allows to save current color profile from Displays -> Color section of the Mac OS System Preferences, in this case file is saved to /Users/<username>/Library/ColorSync/Profiles.

Finally you can activate it by running

# xcalib ~/colorprofile.icc
Warning: previous command set the color profile only for the current session; this mean that you must run it every time you login in your system. For automating it you can execute the command by Autostart Application, concording with your DE.
Note: see xcalib man pages for further information.

Apple Remote

First, to correctly install and configure the lirc software that control IR see Lirc wiki.

Then make LIRC use /dev/usb/hiddev0 (or /dev/hiddev0) by editing /etc/conf.d/lircd. Here is how mine look:

#
# Parameters for lirc daemon
#
LIRC_DEVICE="/dev/usb/hiddev0"
LIRC_DRIVER="macmini"
LIRC_EXTRAOPTS=""
LIRC_CONFIGFILE="/etc/lirc/lircd.conf"


Use irrecord (available when installing lirc) to create a config file matching your remote control signals (alternatively, you can try to use the lircd.conf below):

sudo irrecord -d /dev/usb/hiddev0 -H macmini output_conf_file

Start lircd and use irw to check if it works.

Example of an /etc/lircd.conf:

begin remote

  name  lircd.conf.macbook
  bits            8
  eps            30
  aeps          100

  one             0     0
  zero            0     0
  pre_data_bits   24
  pre_data       0x87EEFD
  gap          211994
  toggle_bit_mask 0x87EEFD01

      begin codes
          Repeat                   0x01
          Menu                     0x03
          Play                     0x05
          Prev                     0x09
          Next                     0x06
          Up                       0x0A
          Down                     0x0C
      end codes

end remote

Hfs Partition Sharing

First, we have to list our partitions. Use

fdisk -l /dev/sda

example output:

# fdisk -l /dev/sda
    Device  Boot     Start         End      Blocks   Id  Type
 /dev/sda1               1          26      204819   ee  GPT
 /dev/sda2              26       13602   109051903+  af  Unknown
 /dev/sda3   *       13602       14478     7031250   83  Linux
 /dev/sda4           14478       14594      932832+  82  Linux swap / Solaris

As we see, the "Unknown" partition is our OS X partition, which is located in /dev/sda2.

Create a "mac" folder in /media:

sudo mkdir /media/mac

Add at the end of /etc/fstab this line:

/dev/sda2    /media/mac     hfsplus rw,exec,auto,users   0 0

Mount it :

mount /media/mac

and check it:

ls /media/mac

Home Sharing

UID Synchronization

In OS X

Note: it is strongly recommended that UID/GID manipulation be done immediately after a new user account is created, in OS X as well as in Arch Linux. If you installed OS X from scratch, then this operation is guaranteed to work after logging into your account for the first time.
Step 1: Change UID and GID(s)

Pre-Leopard

  1. Open NetInfo Manager located in the /Applications/Utilities folder.
  1. If not done for you already, enable access to user account transactions by clicking on the closed lock at the bottom of the window, and entering your account password, or root password if you have created a root account.
  1. Navigate to /users/<new user name> where <new user name> is the name of the account that will have read/write access to the folder that will be shared with the primary user in Arch.
  1. Change the UID value to 1000 (the value used by default for first user created in Arch).
  1. Also change the GID value to 1000 (the value used by default for user account creation in Arch).
  1. Navigate to /groups/<new user name>, automatically saving the changes you have made so far.
Note: if you get an error message that the transaction is not allowed, log out and log back in.

Leopard

In Leopard, the NetInfo Manager application is not present. A different set of steps is required for UID synchronization:

  1. Open System Preferences.
  1. Click on Accounts.
  1. Unlock the pane if not already done so.
  1. Right-click on the desired user and select Advanced Options.
  1. Write down the value of the User ID field, you'll need it later on. Change both the UID and GID to match the UID and GID of the account wished to be shared with in Arch (1000 by default for the first user created in Arch).
Step 2: Change "Home" Permissions
  1. Open up Terminal in the /Applications/Utilities folder.
  1. Enter the following command to reclaim the permission settings of your home folder, replacing <your user name>, <your user group> and <your old UID> with the user name whose UID and GID values you just changed, the group name whose GID value you just changed and the old UID number, respectively.
find /User/<your user name> -user <your old UID> -exec chown <your user name>:<your user group>

In Arch

To synchronize your UID in Arch Linux, you are advised to perform this operation while creating a new user account. It is therefore recommended that you do this as soon as you install Arch Linux.

Now you must substitute Arch's home with Mac OS's home, by modify entries of the famous /etc/fstab file.

rEFIt

Now install rEFIt if you have not done so already.

Note: this is not a requirement. It only gives you a menu to choose between OS X and Arch Linux upon every boot.

In OS X, download the ".dmg" from -> Refit Homepage and install it.

Note: if you have already partitioned your hard disk in preparation for the Arch installation, rEFIt may not be enabled by default. You will have to run the "enable.sh" script installed in /efi/refit/.

Open up Terminal and enter:

cd /efi/refit; ./enable.sh