Skip to content

Instantly share code, notes, and snippets.

@quidome
Last active June 6, 2017 07:44
Show Gist options
  • Save quidome/b4453d307f5aaebf4c9535f432ba58f2 to your computer and use it in GitHub Desktop.
Save quidome/b4453d307f5aaebf4c9535f432ba58f2 to your computer and use it in GitHub Desktop.
Dual boot OSX with archlinux using zfs on crypted disks
# resize OSX partition (disable filevault if enabled)
# enable support for OSX
pacman-key -r 0EE7A126
pacman-key --lsign-key 0EE7A126
cat<<EOF>>/etc/pacman.conf
[archzfs]
Server = http://archzfs.com/$repo/x86_64
EOF
pacman -Sy zfs-linux
modprobe zfs
# create two new partitions
/boot - 250MB - type 8300 (Linux)
root_crypt - the rest - type BF00 (Solaris root)
# if you're lucky you'll end up with something just like this
Device Start End Sectors Size Type
/dev/sda1 40 409639 409600 200M EFI System
/dev/sda2 409640 488757327 488347688 232.9G Apple Core storage
/dev/sda3 488757328 490026863 1269536 619.9M Apple boot
/dev/sda4 490026864 491075439 1048576 512M Linux filesystem
/dev/sda5 491075440 977105026 486029587 231.8G Solaris root
# format boot partition
mkfs.ext4 -L boot /dev/sda4
# create luks and open it
cryptsetup luksFormat -c aes-xts-plain64 -s 512 -h sha512 /dev/sda5
cryptsetup luksOpen /dev/sda5 root_crypt
# create zfs filesystem in
pool create -f -o ashift=12 -O compression=lz4 -o cachefile=/etc/zfs/zroot.cache -m none -R /mnt zroot /dev/mapper/root_crypt
zfs create -V 8G -b 4K zroot/swap
mkswap /dev/zvol/zroot/swap
zfs create zroot/home -o mountpoint=/home
zfs create zroot/root -o mountpoint=/root
cp /etc/zfs/zroot.cache /tmp/zroot.cache
zfs umount -a
rmdir /mnt/{home,root}
zfs set mountpoint=/ zroot #ignore error
zpool set bootfs=zroot zroot
#swapoff /dev/zvol/zroot/swap #if it doesn't want to export
zpool export zroot
zpool import -d /dev/mapper -R /mnt zroot
mkdir /mnt/etc
mkdir /mnt/etc/zfs
cp /tmp/zroot.cache /mnt/etc/zfs/zroot.cache
# mount boot and efi
mkdir /mnt/boot
mount /dev/sda4 /mnt/boot
mkdir /mnt/boot/efi
mount /dev/sda1 /mnt/boot/efi
# do base install
pacstrap -i /mnt base
# add fstab entries
genfstab -U -p /mnt | grep boot >> /mnt/etc/fstab
# add the following to fstab as well:
/dev/mapper/root_crypt / zfs defaults 0 0
/dev/zvol/zroot/swap none swap defaults 0 0
modprobe efivarfs
arch-chroot /mnt /bin/bash
# at this point lts is easier to get working with zfs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment