Setting up root on ZFS with EFI boot. Can't use MBR boot because GRUB doesn't like ZFS with Debian Jessie.
-
Grab Debian live CD ("iso-hybrid") 64-bit; username
user
passwordlive
-
(optional) set sshd_config to allow password login, ssh into live environment - easier than a console window when you can copy-paste
-
Install ZoL in live environment
sudo -i wget http://archive.zfsonlinux.org/debian/pool/main/z/zfsonlinux/zfsonlinux_6_all.deb dpkg -i zfsonlinux_6_all.deb apt-get update apt-get install linux-image-amd64 debian-zfs modprobe zfs
-
Partition boot device: gpt, with EFI system partition of at least 200 MB (and no more than 400 MB on SuperMicro motherboards).
- fdisk
-
Format boot partition as FAT32:
mkdosfs -F 32 /dev/xxx
-
Create zpool:
- RAID-Z:
zpool create -o ashift=12 tank raidz1 /dev/disk/by-id/...
replacing...
with a glob representing your disk(s)- OR RAID-1:
zpool create -o ashift=12 tank mirror /dev/disk/by-id/...
replacing...
with a glob representing your disk(s)
- OR RAID-1:
- Optional read cache (L2ARC) and write cache (ZIL):
zpool add tank log mirror /dev/disk/by-id/...
for ZIL - must be less than 50% of RAM sizezpool add tank cache /dev/disk/by-id/...
for L2ARC - can be any size, pure read performance if this is SSD-backed
- If you want LZ4 compression (recommended for hard drives - higher CPU usage during I/O but higher throughput):
zfs set compression=lz4 tank
- RAID-Z:
-
Create root fs
zfs create tank/root
-
zfs umount -a
-
zfs set mountpoint=/ tank/root
-
zpool set bootfs=tank/root tank
-
zpool export tank
-
zpool import -d /dev/disk/by-id -R /mnt tank
-
mkdir -p /mnt/boot/efi
-
mount /dev/xxx /mnt/boot/efi
replacingxxx
with a partition (not raw disk) where your EFI System Partition will be -
apt-get install debootstrap
-
debootstrap jessie /mnt
-
cp /etc/hostname /etc/hosts /mnt/etc/
-
Add to
/mnt/etc/fstab
:/dev/disk/by-id/xxxbootpartition /boot/efi auto defaults 0 1
replacingxxxbootpartition
with your EFI System Partition
-
Add interfaces to
/mnt/etc/network/interfaces
, e.g.:auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
20. Chroot into new system: `systemd-nspawn -D /mnt /bin/bash --login` 21. Install ZFS on new system - it must compile again
apt-get install locales
locale-gen en_US.UTF-8
wget http://archive.zfsonlinux.org/debian/pool/main/z/zfsonlinux/zfsonlinux_6_all.deb
apt-get install lsb-release
dpkg -i zfsonlinux_6_all.deb
apt-get update
apt-get install linux-image-amd64 debian-zfs
apt-get install zfs-initramfs
apt-get dist-upgrade
```
- Add boot support files
-
Make
/etc/kernel/postinst.d/zz-update-efistub
:#!/bin/sh cp /vmlinuz /initrd.img /boot/efi/EFI/debian/
-
chmod +x /etc/kernel/postinst.d/zz-update-efistub
-
mkdir -p /boot/efi/EFI/debian
-
/etc/kernel/postinst.d/zz-update-efistub
-
Also add to
/etc/initramfs/post-update.d/
-
- Set root password (
passwd root
) - (optional) snapshot new root
zfs snapshot tank/root@cleaninstall
exit
from chroot envzfs umount -a
umount -l /mnt
zpool export tank
ZFS now installed. Next: set up boot
- Boot into live CD with EFI support (Debian Jessie Live does not). Suggestion: Lubuntu. Must be 64-bit. Username
lubuntu
no password - Install
efibootmgr
- Add boot entry:
efibootmgr -d /dev/xxx -c -g -L "Debian (EFI stub)" -l '\EFI\debian\vmlinuz' -u "add_efi_memmap boot=zfs rpool=tank bootfs=tank/root root=ZFS=tank/root initrd=\\EFI\\debian\\initrd.img ro"
- Add
vmwgfx.enable_fbdev=1
required to work around plymouth blank screen bug in jessie on VMware - Add
quiet
to suppress startup messages. Unnecessary and not recommended especially for servers. - Add
security=apparmor
to enable AppArmor, which is a requirement for LXD.
- Add
- Boot! (and pray)