Skip to content

Instantly share code, notes, and snippets.

@fire
Last active March 7, 2018 21:38
Show Gist options
  • Save fire/c0fa189c55322e062a23 to your computer and use it in GitHub Desktop.
Save fire/c0fa189c55322e062a23 to your computer and use it in GitHub Desktop.
Install Elementary Loki on ZFS root
# Experimental 2016-01-10
DOES NOT WORK YET.
sudo -i
apt-get update
apt-get install --yes debootstrap zfsutils-linux zfs-initramfs zfs-dkms
modprobe zfs
# setup zfs
sudo zpool create -d \
-o feature@async_destroy=enabled \
-o feature@empty_bpobj=enabled \
-o feature@lz4_compress=enabled \
-o ashift=12 \
-O compression=lz4 \
rpool \
/dev/disk/by-id/ata-DISK
zfs create rpool/ROOT
zfs create rpool/ROOT/elementary-1
zfs set mountpoint=/ rpool/ROOT/elementary-1
zpool set bootfs=rpool/ROOT/elementary-1 rpool
zpool export rpool
zpool import -R /mnt rpool
debootstrap --arch amd64 xenial /mnt
cp /etc/hosts /mnt/etc/
nano /mnt/etc/hostname
mount --rbind /dev /mnt/dev
mount --rbind /proc /mnt/proc
mount --rbind /sys /mnt/sys
chroot /mnt /bin/bash --login
locale-gen en_US.UTF-8
dpkg-reconfigure tzdata
apt-get update
apt-get install --yes ubuntu-minimal software-properties-common wget bsd-mailx patch
apt-get update
apt-get install --yes --no-install-recommends linux-generic linux-headers-generic
wget -q -O /etc/cron.hourly/zfs-check https://gist.githubusercontent.com/fire/65f7aa33b91d3af2aef0/raw/a0309ef9a6bec26b497b2ee7e00aaa2889310384/zfs-check.sh
wget -q -O /etc/cron.monthly/zfs-scrub https://gist.githubusercontent.com/fire/65f7aa33b91d3af2aef0/raw/5b0904343897b1410fd57239879a0f43ff634883/zfs-scrub.sh
chmod 755 /etc/cron.hourly/zfs-check /etc/cron.monthly/zfs-scrub
# See existing /etc/sudoers.d/zfs
#wget -q -O /etc/sudoers.d/zfs https://gist.githubusercontent.com/fire/65f7aa33b91d3af2aef0/raw/36a2b9e37819abffc6bfc2a9a36859afabf47754/zfs.sudoers
#chmod 440 /etc/sudoers.d/zfs
# Change name of admin user
USERNAME="johnd"
adduser $USERNAME
cp -a /etc/skel/.[!.]* /home/$USERNAME
chown $USERNAME:$USERNAME /home/$USERNAME
usermod -a -G adm,audio,dialout,dip,cdrom,floppy,fuse,lpadmin,plugdev,sambashare,scanner,sudo,video $YOURUSERNAME
apt-get install -y grub-efi nano
# Add to /etc/apt/sources.list
# deb http://archive.ubuntu.com/ubuntu xenial universe
apt-get install -y zfsutils-linux zfs-initramfs spl-dkms zfs-dkms
sudo nano /etc/default/grub
# add "boot=zfs" to GRUB_CMDLINE_LINUX_DEFAULT=
# Install zfs script to recreate /dev/ nodes so that grub can use it.
cat > /etc/udev/rules.d/70-zfs-grub-fix.rules << 'EOF'
ENV{DEVTYPE}=="partition", IMPORT{parent}="ID_*", ENV{ID_FS_TYPE}=="zfs_member", SYMLINK+="$env{ID_BUS}-$env{ID_SERIAL} $env{ID_BUS}-$env{ID_SERIAL}-part%n"
EOF
udevadm trigger
update-initramfs -c -k all
# update-initramfs: Generating /boot/initrd.img-3.2.0-40-generic
# 6.3 Update the boot configuration file:
update-grub
# Generating grub.cfg ...
# Found linux image: /boot/vmlinuz-3.2.0-40-generic
# Found initrd image: /boot/initrd.img-3.2.0-40-generic
# done
# 6.4 Install the boot loader
grub-install $(readlink -f /dev/disk/by-id/scsi-SATA_disk1)
# Installation finished. No error reported.
add-apt-repository ppa:elementary-os/daily
add-apt-repository ppa:elementary-os/os-patches
apt-get update
apt-get -y install elementary-desktop
apt-get -y install upgrade
exit
# 7.2 Run these commands in the LiveCD environment to dismount all filesystems:
umount -l /mnt/dev
umount -l /mnt/proc
umount -l /mnt/sys
zfs umount -a
zpool export rpool
reboot
## How to boot a grub efi from scratch
linux /ROOT/elementary-1/@/boot/vmlinuz-4.3.0-5-lowlatency # Sample
initrd /ROOT/elementary-1/@/boot/initrd.img-4.3.0-5-lowlatency
boot
@globalcitizen
Copy link

globalcitizen commented Jan 9, 2018

Did you ever get this working?

I am considering testing this out on an existing boot-from-ZFS machine (gentoo) as the degree of tedium required in setting up a decent graphical environment on Gentoo exceeds my available time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment