Arch on Air
Instructions for installing Arch Linux side-by-side with OS X on a Macbook Air 2013.
Most of this information was taken from these two sources:
Procedure
wiki)
1. Make bootable USB media with Arch ISO image (2. Hold the <alt/option> key and boot into USB
3. Create partitions
The following example assumes Arch will sit on a single partition; adjust according to preference.
It may also be possible to create a data partition that can be accessed from both OS X and GNU/Linux systems: how to do that properly is left as an exercise to the reader.
cgdisk /dev/sda
Partitions:
/dev/sda4 - [128MB] Apple HFS+ “Boot Loader”
/dev/sda5 - [256MB] Linux filesystem “Boot”
/dev/sda6 - [Rest of space] Linux filesystem “Root”
4. Format and mount partitions
mkfs.ext4 /dev/sda5
mkfs.ext4 /dev/sda6
mount /dev/sda6 /mnt
mkdir /mnt/boot && mount /dev/sda5 /mnt/boot
If you plan to use any memory-heavy applications (which includes most web browsers), it’s a good idea to create either a swap partition or a swapfile for system stability. Swapfiles are easier to resize or remove if you change your mind, so we’ll create a 512M one:
dd if=/dev/zero of=/mnt/swapfile bs=1M count=512
chmod 600 /mnt/swapfile
mkswap /mnt/swapfile
5. Installation
This requires an internet connection. Options:
- Tethered phone via USB (instructions for Android, instructions for iPhone)
- Wired (with some Apple proprietary ethernet thing ($$$?))
- Wireless (requires b43 wireless firmware (AUR))
pacstrap /mnt base base-devel
genfstab -U -p /mnt >> /mnt/etc/fstab
6. Optimize fstab for SSD, add swap
nano /mnt/etc/fstab
/dev/sda6 / ext4 defaults,noatime,discard,data=writeback 0 1 /dev/sda5 /boot ext4 defaults,relatime,stripe=4 0 2 /swapfile none swap defaults 0 0
7. Configure system
arch-chroot /mnt /bin/bash
passwd
echo myhostname > /etc/hostname
ln -s /usr/share/zoneinfo/America/Sao_Paulo /etc/localtime
hwclock --systohc --utc
useradd -m -g users -G wheel -s /bin/bash myusername
passwd myusername
pacman -S sudo
8. Grant sudo
echo "%wheel ALL=(ALL) ALL" > /etc/sudoers.d/10-grant-wheel-group
9. Set up locale
nano /etc/locale.gen
locale-gen
echo LANG=en_US.UTF-8 > /etc/locale.conf
export LANG=en_US.UTF-8
10. Set up mkinitcpio hooks and run
Insert “keyboard” after “autodetect” if it’s not already there.
nano /etc/mkinitcpio.conf
Then run it:
mkinitcpio -p linux
11. Set up GRUB/EFI
To boot up the computer we will continue to use Apple’s EFI bootloader, so we need GRUB-EFI:
pacman -S grub-efi-x86_64
Configuring GRUB
nano /etc/default/grub
Aside from setting the quiet and rootflags kernel parameters, a special parameter must be set to avoid system (CPU/IO) hangs related to ATA, as per this thread:
GRUB_CMDLINE_LINUX_DEFAULT="quiet rootflags=data=writeback libata.force=1:noncq"
Additionally, the grub template is broken and requires this adjustment:
# fix broken grub.cfg gen GRUB_DISABLE_SUBMENU=y
grub-mkconfig -o boot/grub/grub.cfg
grub-mkstandalone -o boot.efi -d usr/lib/grub/x86_64-efi -O x86_64-efi --compress=xz boot/grub/grub.cfg
Copy boot.efi (generated in the command above) to a USB stick for use later in OS X.
12. Setup boot in OS X
Exit everything and reboot into OS X (by holding alt/option) and then choosing it.
exit # exit chroot
reboot
13. Launch Disk Utility in OS X
Format (“Erase”) /dev/sda4 using Mac journaled filesystem
14. Create boot file structure
This procedure allows the Apple bootloader to see our Arch Linux system and present it as the default boot option.
cd /Volumes/disk0s4
mkdir System mach_kernel
cd System
mkdir Library
cd Library
mkdir CoreServices
cd CoreServices
touch SystemVersion.plist
nano SystemVersion.plist
<xml version="1.0" encoding="utf-8"?> <plist version="1.0"> <dict> <key>ProductBuildVersion</key> <string></string> <key>ProductName</key> <string>Linux</string> <key>ProductVersion</key> <string>Arch Linux</string> </dict> </plist>
Copy boot.efi from your USB stick to this CoreServices directory. The tree should look like this:
|___mach_kernel |___System | |___Library | |___CoreServices | |___SystemVersion.plist |___boot.efi
15. Make Boot Loader partition bootable
sudo bless --device /dev/disk0s4 --setBoot
You may need to disable the System Integrity Projection of OS X:
- Restart the computer, while booting hold down Command-R to boot into recovery mode.
- Once booted, navigate to the “Utilities > Terminal” in the top menu bar.
- Enter “csrutil disable” in the terminal window and hit the return key.
- Restart the machine and System Integrity Protection will now be disabled.
Voila, Arch Linux is installed.
Reboot the computer and hold the alt/option key to select which operating system to boot.
16. Get wireless working in Arch
Get broadcom drivers
broadcom from AUR
Download and install(Make sure that b43 and ssb modules are not present in the output from `lsmod`)
modprobe wl
broadcom-wl-dkms instead
Alternatively, install…so that kernel updates don’t leave you without wifi. DKMS is a service that recompiles external modules after every kernel upgrade.
sudo pacman -S linux-headers dkms
sudo systemctl enable dkms.service
Select network
sudo pacman -S wpa_supplicant dialog
sudo wifi-menu -o
17. Access common keys
Keyboard setup
Stop requiring the fn key to trigger F1-F12. Also swap the option and command (alt and super) keys. The tilde key does not work on the keyboard out of the box. There are several solutions listed here but this one worked for me:
sudo nano /etc/modprobe.d/hid_apple.conf
options hid_apple iso_layout=0 fnmode=2 swap_opt_cmd=1
Insert and <F1..12> keys
The <insert> key can be reproduced with fn+<Enter>. So to paste in an xterm window for instance, use S-fn-<Enter>.
F1-F12 require fn+<F1>, etc.
18. Improve battery performance
Out-of-the-box battery performance on Arch Linux should be good and at least comparable to OS X.
If you want to try to improve battery life, there are two recommended packages documented in the ArchWiki:
- PowerTOP: a tool provided by Intel to enable various powersaving modes in userspace, kernel and hardware, available in the official repositories. (ArchWiki)
- TLP: a collection of power-saving scripts available in the official repositories. (ArchWiki)\
19. Trackpad
gpasswd -a <username> input
owlman install xf86-input-mtrack
20. Backlight
With an intel graphics card, the backlight can be controlled with `xbacklight`:
sudo pacman -S xorg-xbacklight
To specify the specific backlight device, create a `/etc/X11/xorg.conf.d./20-intel.conf` file:
Section "Device"
Identifier "Card0"
Driver "intel"
Option "Backlight" "intel_backlight"
EndSection
Using `xbindkeys` to bind the backlight keys:
sudo pacman -S xbindkeys
touch ~/.xbindkeysrc
echo "xbindkeys" >> ~/.xinitrc
Add the bindings to the `.xbindkeysrc` file:
"xbacklight -inc 10"
XF86MonBrightnessUp
"xbacklight -dec 10"
XF86MonBrightnessDown
21. Audio
If the default audio device is hdmi instead of the normal output, add these lines to `~/.asoundrc`
defaults.ctl.card 1; defaults.pcm.card 1;
and bind the volume keys in `.xbindkeysrc` with
"amixer set Master 5%+" XF86AudioRaiseVolume "amixer set Master 5%-" XF86AudioLowerVolume "amixer set Master toggle" XF86AudioMute
22. Suspend
Bugs with out suspend is handled necessitates disabling USB-related wakeup and lid-related wakeup. Adding a service that disables these two wakeup approaches can be done by creating a systemd service in a `/etc/systemd/system/fix-suspend.service` file:
[Unit] Description=fix-suspend [Service] ExecStart=/bin/bash -c "echo XHC1 >> /proc/acpi/wakeup; echo LID0 >> /proc/acpi/wakeup" [Install] WantedBy=multi-user.target
To use and activate the service:
sudo systemctl daemon-reload sudo systemctl start fix-suspend sudo systemctl enable fix-suspend
23. Power button
Annoyingly, the power button immediately shuts the system down with no other warning. Editing `/etc/systemd/logind.conf` with
HandlePowerKey=ignore
will stop the button from having any effect while the system is on.
24. Keyboard Backlight
Installing kbdlight:
owlman install kdblight
will provide a way to bind keys that change the keyboard brightness in `~/.xbindkeysrc`:
"kbdlight up 25" XF86KbdBrightnessUp "kbdlight down 25" XF86KbdBrightnessDown
Additional Links
There are other folks who have blogged about this process since I started this: