4 <meta charset=
"utf-8"/>
5 <meta name=
"viewport" content=
"width=device-width, initial-scale=1"/>
6 <title>Arch GNU/Linux on MacBook Air
2013 — Amin Bandali
</title>
7 <link rel=
"icon" href=
"/gnu.ico"/>
8 <link rel=
"stylesheet" href=
"/style.css"/>
12 <strong><a href=
"/">Amin Bandali
</a>'s Personal Site
</strong>
16 <li><a href=
"/#papers">Publications
</a></li>
17 <li><a href=
"/#projects">Projects
</a></li>
18 <li><a href=
"/#notes">Notes
</a></li>
19 <li><a href=
"/cv" title=
"curriculum vitae">CV
</a></li>
20 <li><a href=
"/contact">Contact
</a></li>
26 <h1>Arch GNU/Linux on MacBook Air
2013</h1>
27 <p>Published on November
1,
2016<br/>
28 Last updated on March
27,
2020</p>
31 <p>This post summarizes how I install and dual-boot Arch GNU/Linux
32 with Full-Disk Encryption alongside macOS. It is not meant to be a
34 <a href=
"//wiki.archlinux.org/index.php/installation%5Fguide">Installation
35 Guide
</a> or the former
36 <a href=
"//csdietz.github.io/arch-beginner-guide/">Beginner's
37 Guide
</a>. Rather, it mostly serves as a small summary with a few
38 useful notes about the gotchas.
</p>
40 <p>So, make sure you understand what you type into your terminal. If
41 you don't, checking out the Arch wiki should probably be your first
44 <p><em>Note:
</em> you will need internet access throughout the
45 installation and the MacBook Air's WiFi doesn't work out of the box on
46 Arch. I recommend using an Ethernet-USB adapter or your phone's USB
47 Tethering feature (if it does support it).
</p>
49 <h2>Shrinking the macOS partition
</h2>
50 <p>The first step I take is resizing the HFS+ macOS partition to make
51 room for the new GNU/Linux installation. There are plenty of
52 tutorials on how to do this using macOS's Disk Utility, so do that and
55 <h2>Creating a bootable Arch Installer USB
</h2>
56 <p>There are different ways of creating a bootable Arch USB, all
58 <a href=
"//wiki.archlinux.org/index.php/USB%5Fflash%5Finstallation%5Fmedia">USB
59 flash installation media
</a> page on the Arch wiki, but the simplest
60 one is using
<code>dd
</code> if you already have access to another
63 <p><strong class=
"warn">Warning:
</strong> make sure you backup the
64 data on your flash drive, as
<code>dd
</code> will irrevocably destroy
67 <p>Use
<code>lsblk
</code> to find the name (block device) of your USB drive, then
68 run
<code>dd
</code> (as root) as shown below:
</p>
71 dd bs=
4M if=/path/to/archlinux.iso of=/dev/sdx status=progress && sync
74 <p>Replace
<code>/path/to/archlinux.iso
</code> with the path to the
75 Arch image you have downloaded, and
<code>/dev/sdx
</code> with your
78 <h2>Booting up from the USB
</h2>
79 <p>After creating the install USB, reboot your laptop and hold the alt
80 key and boot from the USB.
</p>
82 <p>When booting is complete and you're presented with the prompt, it's
83 a good time to make sure you're connected to the internet (see the
84 <em>note
</em> at the top of this post).
</p>
86 <p>Use
<code>ping
</code> to verify that you have established a
93 <h2>Updating the system clock
</h2>
94 <p>Once you're connected to the internet, make sure the system clock
98 timedatectl set-ntp true # start and enable systemd-timesyncd
101 <p>You can check the service status using
<code>timedatectl
104 <h2>Partitioning
</h2>
105 <p>I won't dive into partitioning and instead, I will refer you to the
106 <a href=
"//wiki.archlinux.org/index.php/Partitioning">Partitioning
</a>
107 page of Arch wiki. Of the available partitioning tools, I personally
108 prefer
<code>cfdisk
</code>.
</p>
110 <h2>Setting up LVM
& LUKS
</h2>
112 <a href=
"//wiki.archlinux.org/index.php/Dm-crypt/Encrypting%5Fan%5Fentire%5Fsystem#LVM%5Fon%5FLUKS">LVM
113 on LUKS
</a> setup, where I set up LVM on top of the encrypted
116 <p>First, let's set up the underlying encrypted partition:
</p>
119 cryptsetup -v --cipher aes-xts-plain64 --key-size
512 --hash sha512 \
120 --iter-time
5000 --use-urandom -y luksFormat /dev/sdaX
123 <p>where
<code>/dev/sdaX
</code> is the partition you created in the
124 last step (e.g.
<code>/dev/sda4
</code>). For more information about
125 the
<code>cryptsetup
</code> options, see the
126 <a href=
"//wiki.archlinux.org/index.php/Dm-crypt/Device%5Fencryption#Encryption%5Foptions%5Ffor%5FLUKS%5Fmode">LUKS
127 encryption options
</a>.
</p>
129 <p>Then we open the container:
</p>
132 cryptsetup open --type luks /dev/sdaX lvm
135 <p>Now it's time to use lvm and prepare the logical volume(s):
</p>
138 pvcreate /dev/mapper/lvm vgcreate vg /dev/mapper/lvm
139 lvcreate --extents +
100%FREE -n root vg
142 <p>This will create a physical volume on the mapping we just opened,
143 create a volume group named
<code>vg
</code> on the physical volume,
144 and create a logical volume named
<code>root
</code> that spans the
145 entire volume group. More complex setups are possible thanks to the
146 great flexibility of lvm.
</p>
148 <p>We now format the logical volume with
<code>ext4
</code>:
</p>
151 mkfs.ext4 /dev/mapper/vg-root
154 <h2>Installing the base system
</h2>
155 <p>Let's mount the logical volume, make a directory for the mount
156 point of the boot partition, and mount the boot partition
157 (
<code>/dev/sda1
</code>):
</p>
160 mount /dev/mapper/vg-root /mnt
162 mount /dev/sda1 /mnt/boot
165 <p>Finally, let's install the base system (and optionally
166 <code>base-devel
</code>):
</p>
169 pacstrap /mnt base base-devel
172 <h2>Configuring the system
</h2>
173 <p>Let's generate the fstab:
</p>
176 genfstab -U /mnt
>> /mnt/etc/fstab
179 <p>Use your favorite terminal-based editor, edit the fstab file and
180 add the
<code>discard
</code> option for the root partition to enable
183 <p>Now we change root into our newly installed system and will
184 configure it. Adjust these according to your own setup.
</p>
187 arch-chroot /mnt /bin/bash
188 passwd # set the root password
189 echo myhostname
> /etc/hostname # set the hostname
190 ln -s /usr/share/zoneinfo/Canada/Eastern /etc/localtime # time zone
191 hwclock --systohc --utc # write system clock to hardware clock (UTC)
192 useradd -m -G wheel -s /bin/bash myuser # create myuser
193 passwd myuser # set the password for myuser
194 echo
"myuser ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/myuser
195 # uncomment en_US.UTF-
8 UTF-
8 and other needed locales in /etc/locale.gen
197 echo LANG=en_US.UTF-
8 > /etc/locale.conf
198 export LANG=en_US.UTF-
8
201 <p>Then adjust the initramfs hooks in
202 <code>/etc/mkinitcpio.conf
</code> and enable the
203 <code>encrypt
</code> and
<code>lvm2
</code> hooks, and make sure
204 <code>keyboard
</code> is available before
<code>encrypt
</code> so you
205 can actually type in the LUKS password when booting. Your
206 <code>HOOKS
</code> line should look similar to this:
</p>
209 HOOKS=(base udev autodetect keyboard keymap consolefont modconf block encrypt lvm2 filesystems fsck)
212 <p>After adjusting the hooks, build the initramfs:
</p>
218 <p>Create the
<code>/boot/loader/loader.conf
</code> with the following
219 content (adjust the timeout to your liking):
</p>
222 default arch timeout
3
225 <p>Then create the entry for Arch:
</p>
228 mkdir -p /boot/loader/entries
229 touch /boot/loader/entries/arch.conf
232 <p>Now edit
<code>/boot/loader/entries/arch.conf
</code> to specify the
238 initrd /intel-ucode.img
239 initrd /initramfs-linux.img
240 options cryptdevice=/dev/sdaX:vg:allow-discards root=/dev/mapper/vg-root rw
243 <p>Again,
<code>/dev/sdaX
</code> is the partition you created in the
244 partitioning step earlier as the underlying encrypted partition.
</p>
246 <p>Finally, install the bootloader, exit the chroot, umount and
256 <h2>Post-installation recommendations
</h2>
257 <p>Congratulations! You now have a minimal Arch installation.
</p>
259 <p>At this point, I usually install my favorite AUR helper,
260 <a href=
"//aur.archlinux.org/packages/pacaur/">pacaur
</a>, then I
262 <a href=
"//aur.archlinux.org/packages/mba6x%5Fbl-dkms/">mba6x_bl-dkms
</a>
263 backlight driver to fix the post suspend/resume issue where there's no
264 brightness after waking up from suspend, and the only available
265 brightness would be
100%.
</p>
268 pacaur -S linux-headers dkms # linux-headers is required for dkms
269 pacaur -S broadcom-wl-dkms
270 pacaur -S mba6x_bl-dkms
273 <p>Then, I'd like to install
</p>
275 <li>input, graphics, and sound drivers,
</li>
276 <li>a desktop environment (I prefer Xfce or LXQt),
</li>
277 <li>a display manager for login screen (lightdm or sddm), and
</li>
278 <li>a network manager (NetworkManager or ConnMan).
</li>
282 <a href=
"//wiki.archlinux.org/index.php/General%5Frecommendations">General
283 recommendations
</a> for more details.
</p>
286 <p>Here are some resources I've come across each with lots of useful
287 bits and pieces, about installing Arch on a MacBook:
</p>
290 <li><a href=
"//github.com/pandeiro/arch-on-air">pandeiro/arch-on-air
</a></li>
291 <li><a href=
"//loicpefferkorn.net/2015/01/arch-linux-on-macbook-pro-retina-2014-with-dm-crypt-lvm-and-suspend-to-disk/">Arch Linux on MacBook Pro Retina
2014 with DM-Crypt, LVM and suspend to disk
</a></li>
292 <li><a href=
"//www.frankshin.com/2014/installing-archlinux-on-macbook-air-2013/">Installing Archlinux on Macbook Air
2013</a></li>
293 <li><a href=
"http://panks.me/posts/2013/06/arch-linux-installation-with-os-x-on-macbook-air-dual-boot/">Arch Linux Installation with OS X on Macbook Air (Dual Boot)
</a></li>
294 <li><a href=
"//alexeyzabelin.com/arch-on-mac">Installing Arch Linux on a MacBook Air
2013</a></li>
295 <li><a href=
"//medium.com/phils-thought-bubble-of-recent-stuff/arch-linux-running-on-my-macbook-2ea525ebefe3">Arch Linux running on my MacBook
</a></li>
296 <li><a href=
"http://codylittlewood.com/arch-linux-on-macbook-pro-installation/">Dual boot Arch Linux on MacBook Pro Installation
</a></li>
299 <p class=
"muted inbox">Got a question or comment? You can find my
300 email address on my
<a href=
"contact">contact
</a> page.
301 <span class=
"smly">:-)
</span></p>
305 <p>Copyright
© 2016,
2019,
2020 Amin Bandali. See
306 <a href=
"/license.html">license.html
</a> for license conditions.
307 Please copy and share.
</p>