Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/pandeiro/arch-on-air

Step by step of setting up Arch Linux on a Macbook Air 2013
https://github.com/pandeiro/arch-on-air

Last synced: about 2 months ago
JSON representation

Step by step of setting up Arch Linux on a Macbook Air 2013

Awesome Lists containing this project

README

        

* 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:
- [[https://bbs.archlinux.org/viewtopic.php?id=165899][ArchLinux Forums: Macbook Air 2013]]
- [[http://panks.me/posts/2013/06/arch-linux-installation-with-os-x-on-macbook-air-dual-boot/][ArchLinux Installation With OS X on Macbook Air (Dual Boot)]]

** Procedure
*** 1. Make bootable USB media with Arch ISO image ([[https://wiki.archlinux.org/index.php/USB_Flash_Installation_Media][wiki]])
*** 2. Hold the 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.
#+begin_src sh
cgdisk /dev/sda
#+end_src
**** 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
#+begin_src sh
mkfs.ext4 /dev/sda5
mkfs.ext4 /dev/sda6
mount /dev/sda6 /mnt
mkdir /mnt/boot && mount /dev/sda5 /mnt/boot
#+end_src
If you plan to use any memory-heavy applications (which includes
most web browsers), it's a good idea to create either a [[https://wiki.archlinux.org/index.php/Swap#Swap_partition][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:
#+begin_src sh
dd if=/dev/zero of=/mnt/swapfile bs=1M count=512
chmod 600 /mnt/swapfile
mkswap /mnt/swapfile
#+end_src
*** 5. Installation
This requires an internet connection. Options:
- Tethered phone via USB ([[https://wiki.archlinux.org/index.php/Android_tethering][instructions for Android]], [[https://wiki.archlinux.org/index.php/IPhone_Tethering][instructions for iPhone]])
- Wired (with some Apple proprietary ethernet thing ($$$?))
- Wireless (requires b43 wireless firmware ([[https://aur.archlinux.org/packages/b43-firmware/][AUR]]))
#+begin_src sh
pacstrap /mnt base base-devel
genfstab -U -p /mnt >> /mnt/etc/fstab
#+end_src
*** 6. Optimize fstab for SSD, add swap
#+begin_src sh
nano /mnt/etc/fstab
#+end_src
#+begin_example
/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
#+end_example
*** 7. Configure system
#+begin_src sh
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
#+end_src
*** 8. Grant sudo
#+begin_src sh
echo "%wheel ALL=(ALL) ALL" > /etc/sudoers.d/10-grant-wheel-group
#+end_src
*** 9. Set up locale
#+begin_src sh
nano /etc/locale.gen
#+end_src
#+begin_src sh
locale-gen
echo LANG=en_US.UTF-8 > /etc/locale.conf
export LANG=en_US.UTF-8
#+end_src
*** 10. Set up mkinitcpio hooks and run
Insert "keyboard" after "autodetect" if it's not already there.
#+begin_src sh
nano /etc/mkinitcpio.conf
#+end_src
Then run it:
#+begin_src sh
mkinitcpio -p linux
#+end_src
*** 11. Set up GRUB/EFI
To boot up the computer we will continue to use Apple's EFI
bootloader, so we need GRUB-EFI:
#+begin_src sh
pacman -S grub-efi-x86_64
#+end_src
**** Configuring GRUB
#+begin_src sh
nano /etc/default/grub
#+end_src
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 [[https://bbs.archlinux.org/viewtopic.php?pid%3D1295212#p1295212][this thread]]:
#+begin_example
GRUB_CMDLINE_LINUX_DEFAULT="quiet rootflags=data=writeback libata.force=1:noncq"
#+end_example
Additionally, the grub template is broken and requires this adjustment:
#+begin_example
# fix broken grub.cfg gen
GRUB_DISABLE_SUBMENU=y
#+end_example
#+begin_src sh
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
#+end_src
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.
#+begin_src sh
exit # exit chroot
reboot
#+end_src
*** 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.
#+begin_src sh
cd /Volumes/disk0s4
mkdir System mach_kernel
cd System
mkdir Library
cd Library
mkdir CoreServices
cd CoreServices
touch SystemVersion.plist
#+end_src
#+begin_src sh
nano SystemVersion.plist
#+end_src
#+begin_example

ProductBuildVersion

ProductName
Linux
ProductVersion
Arch Linux

#+end_example
Copy boot.efi from your USB stick to this CoreServices directory.
The tree should look like this:
#+begin_example
|___mach_kernel
|___System
|
|___Library
|
|___CoreServices
|
|___SystemVersion.plist
|___boot.efi
#+end_example
*** 15. Make Boot Loader partition bootable
#+begin_src sh
sudo bless --device /dev/disk0s4 --setBoot
#+end_src

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
***** Download and install [[https://aur.archlinux.org/packages/broadcom-wl/][broadcom from AUR]]
(Make sure that b43 and ssb modules are not present in the output
from `lsmod`)
#+begin_src sh
modprobe wl
#+end_src
***** Alternatively, install [[https://aur.archlinux.org/packages/broadcom-wl-dkms/][broadcom-wl-dkms]] instead
...so that kernel updates don't leave you without wifi. DKMS
is a service that recompiles external modules after every kernel
upgrade.
#+begin_src sh
sudo pacman -S dkms
sudo systemctl enable dkms.service
#+end_src
**** Select network
#+begin_src sh
sudo pacman -S dialog
sudo wifi-menu -o
#+end_src
*** 17. Access common keys
**** Tilde key
The tilde key does not work on the keyboard out of the box. There
are several solutions listed [[https://wiki.archlinux.org/index.php/Apple_Keyboard][here]] but this one worked for me:
#+begin_src sh
sudo nano /etc/modprobe.d/hid_apple.conf
#+end_src
#+begin_example
options hid_apple iso_layout=0
#+end_example
**** Insert and keys
The key can be reproduced with fn+. So to paste in an xterm
window for instance, use S-fn-.

F1-F12 require fn+, 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:
- [[https://01.org/powertop][PowerTOP]]: a tool provided by Intel to enable various powersaving
modes in userspace, kernel and hardware, *available in the official
repositories*. ([[https://wiki.archlinux.org/index.php/Powertop][ArchWiki]])
- [[http://linrunner.de/en/tlp/tlp.html][TLP]]: a collection of power-saving scripts *available in the official repositories*.
([[https://wiki.archlinux.org/index.php/TLP][ArchWiki]])
** Additional Links
There are other folks who have blogged about this process since I started this:
- [[http://frankshin.com/installing-archlinux-on-macbook-air-2013/][Installing Archlinux on Macbook Air 2013 - Frank Shin]]
- [[http://ryangehrig.com/index.php/arch-linux-on-macbook-air-2013/][Arch Linux – MacBook Air 2013 | Ryan Gehrig]] (broken)