Dual boot OS X and Ubuntu 16.04 with encrypted partitions

Partition layout

  • sda1: Existing EFI boot Partition
  • sda2: Existing OSX installation
  • sda3: Existing Recovery partition
  • sda4: New /boot partition
  • sda5: New encrypted lvm partition for swap and /

Detailed guide

I followed this guide ➡ https://coderwall.com/p/amvmaa/dual-booting-os-x-and-ubuntu-16-04-on-macbook-pro-10-1-with-encrypted-root

General links

These pages were also helpful:

General steps

  1. Unencrypt (if not already) OSX partition to resize and make space for Ubuntu.
  2. Download Ubuntu image: http://www.ubuntu.com/download/desktop/thank-you?country=US&version=16.04&architecture=amd64 and make bootable usb disk.
  3. Boot usb disk and choose ‘Try Ubuntu’ option.
  4. Create an ext2 /boot partition (~512M should be plenty) and an ext4 partition to hold the lvm partition.
  5. Create encrypted luks partition with LV’s for Ubuntu installation / and encrypted swap (at least size of RAM, slightly bigger for hibernation - https://help.ubuntu.com/community/SwapFaq#Example_Scenarios).
  6. Unmount any mounted partitions that will be used in the install.
  7. Run the installer manually specifying the /boot partition in step 4 and the LV’s created for / and swap in step 5, without rebooting or installing a bootloader, and exit installer.
  8. Set up a UEFI bootloader. There are lots of ways to do this. I use systemd-boot, which works fine. Ubuntu mounts the EFI partition (sda1) at /boot/EFI.



bootctl install --path=/boot/efi
efibootmgr -c -d /dev/sda1 -p 1 -l EFI/systemd/systemd-bootx64.efi -L "Linux Boot Manager"

Grub EFI

apt install grub-efi
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=grub
grub-mkconfig -o /boot/grub/grub.cfg


sudo apt-add-repository ppa:rodsmith/refind
sudo apt update
sudo apt install refind

Notes, fixes and tweaks

Hardware revision

sudo dmidecode -s system-product-name


Fix wifi


Alternative wifi firmware (wrong drivers for my mac, but might work on yours)

sudo apt remove --purge bcmwl-kernel-source
sudo apt install firmware-b43-installer

Change keyboard fn key behaviour


Fn keys by default, fn+ for multimedia keys:

echo 2 | sudo tee /sys/module/hid_apple/parameters/fnmode

Swap cmd and alt keys:

echo 1 | sudo tee /sys/module/hid_apple/parameters/swap_opt_cmd

Clone repo at https://github.com/free5lot/hid-apple-patched and install:


Put options in /etc/modprobe.d/hid_apple.conf

options hid-apple iso_layout=1
options hid_apple fnmode=2
options hid_apple swap_opt_cmd=0
options hid_apple swap_fn_leftctrl=1
options hid_apple ejectcd_as_delete=0
sudo update-initramfs -u -k all


Fix usb at boot

echo XHC1 > /proc/acpi/wakeup

Fix Suspend issue

Recompile patched kernel source

Kernel patch here: https://bugzilla.kernel.org/show_bug.cgi?id=103211#c172

sudo apt-get build-dep linux-image-$(uname -r)
fakeroot debian/rules clean
DEB_BUILD_OPTIONS=parallel=2 fakeroot debian/rules binary-headers binary-generic

More info


Backlight issues

LightDM dpi

Fix systemd-boot on encrypted LUKS after failed Grub install or Ubuntu upgrade


cryptsetup luksOpen /dev/sda5 home_sda5
vgchange -ay
mkdir /media/linux
mount /dev/vgcrypt/root /media/linux/
mount -o bind /proc /media/linux/proc
mount -o bind /dev /media/linux/dev
mount -o bind /sys /media/linux/sys
chroot /media/linux /bin/bash
> fdisk -l:

Device       Start       End   Sectors   Size Type
/dev/sda1     2048   1050623   1048576   512M EFI System
/dev/sda4  1050624   2050047    999424   488M Linux filesystem   # /boot
/dev/sda5  2050048 500117503 498067456 237.5G Linux filesystem   # LUKS
mount /dev/sda4 /boot
mount /dev/sda1 /boot/efi

umount /boot/efi
umount /boot

Leave chroot: exit

umount /media/linux/boot/efi
umount /media/linux/boot
umount -l /media/linux
vgchange -an
cryptsetup luksClose home_sda5