Dual boot OS X and Ubuntu 16.04 with encrypted partitions
Partition layout
sda1: Existing EFI boot Partitionsda2: Existing OSX installationsda3: Existing Recovery partitionsda4: New /boot partitionsda5: 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:
- https://help.ubuntu.com/community/MacBookPro
- https://www.jayway.com/2015/11/22/ubuntu-full-disk-encrypted-macosx/
- https://iocrunch.com/2014/02/linux-dual-boot-on-mac-with-full-disk-encryption/
General steps
- Unencrypt (if not already) OSX partition to resize and make space for Ubuntu.
- Download Ubuntu image: http://www.ubuntu.com/download/desktop/thank-you?country=US&version=16.04&architecture=amd64 and make bootable usb disk.
- Boot usb disk and choose 'Try Ubuntu' option.
- Create an ext2 /boot partition (~512M should be plenty) and an ext4 partition to hold the lvm partition.
- 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). - Unmount any mounted partitions that will be used in the install.
- Run the installer manually specifying the
/bootpartition in step 4 and the LV's created for/and swap in step 5, without rebooting or installing a bootloader, and exit installer. - 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.
Bootloaders
- https://wiki.archlinux.org/index.php/Archbootprocess
- https://wiki.archlinux.org/index.php/Boot_loaders
systemd-boot
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
rEFInd
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
MacBookPro11,5
Fix wifi
http://askubuntu.com/questions/622988/wifi-issues-with-macbook-pro-retina-early-2015-12-2-on-ubuntu-15-04
- Uninstall any old drivers:
dpkg -r bcmwl-kernel-source - Download brcmfmac43602 firmware from the Linux firmware git repo: https://git.kernel.org/cgit/linux/kernel/git/firmware/linux-firmware.git/plain/brcm/brcmfmac43602-pcie.bin
- Create the folder
/lib/firmware/brcmif it doesn't already exist. - Copy the file to
/lib/firmware/brcm - Reboot and enjoy your 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
https://help.ubuntu.com/community/AppleKeyboard
Fn keys by default, fn+
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:
./build.sh
./install.sh
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
http://superuser.com/questions/245138/linux-ubuntu-apple-aluminium-keyboard-remap-greater-less-with-tilde
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
https://wiki.archlinux.org/index.php/MacBookPro11,x#Suspend
Backlight issues
- http://ubuntuforums.org/showthread.php?t=2227981
- https://wiki.ubuntu.com/Kernel/Dev/KernelGitGuide?action=show&redirect=KernelTeam%2FKernelGitGuide
- https://bugzilla.kernel.org/show_bug.cgi?id=105051
LightDM dpi
- http://askubuntu.com/questions/540863/how-can-i-make-lightdm-scale-on-a-hidpi-screen
Fix systemd-boot on encrypted LUKS after failed Grub install or Ubuntu upgrade
- https://gist.github.com/samuelcolvin/43c5ed2807e7db004b1058d0c9bfb068
Guides:
- https://stephentanner.com/restoring-grub-for-an-encrypted-lvm.html
- https://askubuntu.com/questions/719409/how-to-reinstall-grub-from-a-liveusb-if-the-partition-is-encrypted-and-there-i
- https://help.ubuntu.com/community/Grub2/Installing
cryptsetup luksOpen /dev/sda5 home_sda5 vgchange -ay lvscan 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 # LUKSmount /dev/sda4 /boot mount /dev/sda1 /boot/efigrub-install **OR** grub-update 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