What follows are my personal notes (circa September 2015) of setting up my new MacBook Pro 11,4 ("Mid-2015", third generation/Retina) for dual boot between MacOS and Arch Linux, with Arch Linux on a LUKS encrypted partition (single LUKS crypted / dm-crypt partition with LVM) and FileVault full disk encryption for the Mac side.
- Note that these instructions were written in 2015 and (hopefully) I won't be redoing them until either I switch jobs or my laptop comes up on our 4-year refresh cycle. Some details may have changed since then, but the gist should be the same.
- I originally setup LVM partitions on my ~92GB LUKS-crypted Linux partition for a 17G swap, 20G root and 55.5GB home volume. As I've been relying heavily on Docker lately this became problematic. Not wanting to mess with resizing the LVM volumes and partitions, I've moved
/var/lib/docker
to the home partition, so that I can manage the balance between data in my home directory and Docker.
- Boot machine, setup my user (jantman) and set a password, and setup WiFi. When prompted, setup my existing Apple ID.
- Drag Applications/Utilities/Terminal to the launcher.
- Decine on a hostname ("exodus-mac" for the first one) and set it:
sudo scutil --set HostName exodus-mac
; open a new terminal to refresh. - Shrink the Mac partition (special instructions for 10.10 Yosemite with CoreStorage):
- Shut down the machine; reboot into Internet Recovery Mode holding
alt
+cmd
+R
(release when it shows the spinning globe and "Starting Internet Recovery") - Open Utilities/Terminal in the menubar
- Run
diskutil list
to get the partition layout, and possibly photograph this. On my machine,/dev/disk1
is the main SSD (with GUID partitioning, a 209 MB EFI partition (disk1s1
), a 650MB Recovery HD (disk1s3
), and a 250GB CoreStorage volume (disk1s2
)), and/dev/disk2
is the "Macintosh HD" 249GB volume (a logical volume ondisk1s2
). - Run
diskutil cs list
to list CoreStorage volumes - Get the UUID of the 'Macintosh HD' Logical Volume
- Shrink it to 150GB:
diskutil cs resizeStack <UUID> 150g
; this should also automatically move "Recovery HD" to the end of the partition - When this finishes,
exit
and quit Terminal - Open "Disk Utility" and run "Verify Disk" on "Macintosh HD", and verify that it shows as 150GB
- Quit Disk Utility, Reboot. It should boot to the normal disk, and your Mac OS install; login.
- Shut down the machine; reboot into Internet Recovery Mode holding
ssh-keygen
- Launch the "App Store" app; search for and install XCode (full version).
- Enable FileVault Full Disk Encryption:
Apple Menu -> System Preferences -> Security and Privacy
; Select theFileVault
tab, unclick the padlock icon to enable changes, and click the "Turn On FileVault..." button.- Select "Create a recovery key and do not use my iCloud account"
- Transcribe the recovery key onto a piece of paper, and store in fireproof safe.
- Restart computer to begin encryption process.
- Wait for disk encryption to finish, and then close System Preferences.
Before we go any further with setting up Mac OS, we want to at least make sure that we can get Arch and the bootloader setup and working; it's better to do this now than later, as there's a chance we might need to reinstall OS X.
- Download the Arch Linux Image, verify checksums and signatures.
- Verify PGP signatures and sha1 sums.
- write to USB flash drive:
dd bs=4M if=/path/to/archlinux.iso of=/dev/sdx && sync
- Open Safari and download rEFInd
- Open a terminal and navigate to the rEFInd download directory.
./install.sh
(--esp
is now default in rEFInd 0.8.4+; some posts recommend--alldrivers
, but the docs warn against this).- if unmount failed:
diskutil unmount /Volumes/ESP
- Copy the ext drivers:
diskutil list
- find the partition ID of theEFI
partition (disk0s1
on my Mac)sudo su -
mkdir /Volumes/ESP
mount -t msdos /dev/disk0s1 /Volumes/ESP
mkdir /Volumes/ESP/EFI/refind/drivers_x64
- cd to the rEFInd download directory
cp refind/drivers_x64/ext4_x64.efi /Volumes/ESP/EFI/refind/drivers_x64/
cd ~/
diskutil unmount /Volumes/ESP
- Plug in the Arch Linux flash drive and reboot
- If all went well, you should get the rEFInd bootloader almost immediately; select the
Boot EFI\boot\loader.efi from ARCHISO_EFI
entry; let it choose and boot the Arch option. If that goes right, you should end up at aroot@archiso ~ #
prompt. - Partitioning - we're going to go for full system encryption using dm-crypt and LVM on LUKS with suspend-to-disk support
cgdisk
to create partitons (92.9G free at start)- create a first partition, start of
+128M
, size 250M, type8300
, nameboot
- create a LUKS partition, start of next block, size all remaining, type
8E00
, namearch
- write the partition table
- Determine an encryption password, and record it on paper; store in fireproof safe.
cryptsetup luksFormat /dev/sda5
(use the LVM device)cryptsetup open --type luks /dev/sda5 lvm
pvcreate /dev/mapper/lvm
vgcreate arch /dev/mapper/lvm
lvcreate -L 17G arch -n swapvol
- 17G swap volumelvcreate -L 20G arch -n rootvol
- 20G root volumelvcreate -l +100%FREE arch -n homevol
- 55.5G home volumemkfs.ext4 /dev/mapper/arch-rootvol
mkfs.ext4 /dev/mapper/arch-homevol
mkswap /dev/mapper/arch-swapvol
mount /dev/arch/rootvol /mnt
mkdir /mnt/home
mount /dev/arch/homevol /mnt/home
swapon /dev/arch/swapvol
mkfs.ext4 /dev/sda4
mkdir /mnt/boot
mount /dev/sda4 /mnt/boot
- Continue installation process up to mkinitcpio configuration.
- Time setup
- check hardware clock with
timedatectl
- ensure that it's correct and hardware is set to UTC - set the timezone:
timedatectl set-timezone America/New_York
date
should now display the correct local time
- check hardware clock with
- Set mirrors - per https://wiki.archlinux.org/index.php/Mirrors#List_by_speed
cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup
vim /etc/pacman.d/mirrorlist.backup
- make sure the US mirrors are un-commentedrankmirrors -n 6 /etc/pacman.d/mirrorlist.backup > /etc/pacman.d/mirrorlist
pacstrap /mnt base base-devel
genfstab -p /mnt >> /mnt/etc/fstab
arch-chroot /mnt
echo "exodus.jasonantman.com" > /etc/hostname
ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime
vi /etc/locales.gen
and uncommenten_US.UTF-8 UTF-8
and thenlocale-gen
echo LANG=en_US.UTF-8 > /etc/locale.conf
echo KEYMAP=qwerty > /etc/vconsole.conf
- Skip networking for now; we're already connected, and we'll setup NetworkManager later.
- So we can work a bit easier,
pacman -S vim
vim /etc/mkinitcpio.conf
; set theHOOKS=
line toHOOKS="base udev autodetect usbinput modconf block keymap encrypt lvm2 resume filesystems keyboard fsck shutdown"
per dm-crypt/Encrypting an entire system - ArchWiki, dm-crypt/Swap encryption - ArchWiki, MacBook - ArchWiki and http://iocrunch.com/2014/02/linux-dual-boot-on-mac-with-full-disk-encryption/- mkinitcpio -p linux
- set the root password:
passwd
(and record it somewhere secure) - rEFInd configuration (most of this came from here even though it conflicts with the dm-crypt instructions, with some additions from dm-crypt/Swap encryption - ArchWiki and dm-crypt/Specialties - ArchWiki):
echo '# This manipulates the linux kernel options in the refind boot loader' > /boot/refind_linux.conf
echo '"Crypt Boot" "cryptdevice=/dev/sda5:arch:allow-discards root=/dev/mapper/arch-rootvol rw resume=/dev/mapper/arch-swapvol"' >> /boot/refind_linux.conf
echo '"Crypt Boot with nomodeset" "cryptdevice=/dev/sda5:arch:allow-discards root=/dev/mapper/arch-rootvol rw resume=/dev/mapper/arch-swapvol nomodeset"' >> /boot/refind_linux.conf
echo '"Crypt Boot Text Mode" "cryptdevice=/dev/sda5:arch:allow-discards root=/dev/mapper/arch-rootvol rw resume=/dev/mapper/arch-swapvol systemd.unit=multi-user.target"' >> /boot/refind_linux.conf
- exit the chroot:
exit
reboot
- remove the USB key
- Boot Arch; enter the LUKS password when prompted
- Login as root and confirm that you can.
ip addr
shows no addresses; find your wired interface name (mine wasenp0s20u1
) and start DHCP (systemctl start dhcpcd@enp0s20u1
).ip addr
should now show an address andping www.google.com
should resolve the address and ping.reboot
and boot into OS X. You should be able to log in as your user.
- Get your Mac user's SSH key onto a working machine, and add it to your GitHub account.
- Setup Boxen on the Mac - https://github.com/jantman/boxen#distributing and run
./script/boxen
; authenticate to GitHub when prompted cd ~/
boxen --env
- make sure it worksboxen
until it works with no changes
- Boot into Arch and login as
root
ip addr
shows no addresses; find your wired interface name (mine wasenp0s20u1
) and start DHCP (systemctl start dhcpcd@enp0s20u1
).ip addr
should now show an address andping www.google.com
should resolve the address and ping.pacman -Syu
- follow the instructions in the workstation-bootstrap README
- Login as your user
- Use the Network Manager Plasmoid in the system tray; click the little settings icon to the right of the airplane mode checkbox, and add a DHCP connection on your Ethernet interface. You'll likely want to set it to activate automatically.