# How to install slackware64-current on a ZFS root # PREREQUISITES # - EFI machine # - a disk that can be wiped fully # - USB-stick created with https://github.com/tterpelle/docker-slack64-current-zfs # - you've read and understood https://github.com/zfsonlinux/zfs/wiki/Debian-Stretch-Root-on-ZFS # # Note1: only create a mountpoint for your / dataset, create the other datasets as 'legacy': # zfs create -o mountpoint=legacy ${ZPOOL}/home # # Note2: create a swap partition if you want to be able to hibernate (pm-hibernate) your system. # It should be at least the size of your RAM. # You've booted the USB-stick and are now in the Slackware64-current installer shell. # Press ALT+F2 to open a terminal on tty2, for some reason it will not open on tty1. # Here we go! # Empty /mnt because ZFS (by default) refuses to mount over non-empty directories rm /mnt/README # Search for your target disk in /dev/disk/by-id and save it in variable export TARGET="/dev/disk/by-id/scsi-SATA_disk1" # Choose a name for your ZFS pool and save it in a variable export ZPOOL=rpool # WIPE ALL THE THINGS on your target disk mdadm --zero-superblock --force ${TARGET} sgdisk --zap-all ${TARGET} zpool labelclear -f ${TARGET} # Create EFI, swap and ZFS partitions sgdisk -n2:1M:+100M -t2:EF00 ${TARGET} sgdisk -n3:0:$(free -m | grep Mem | awk '{ print $3 }')M -t3:8200 ${TARGET} sgdisk -n4:0:0 -t4:BF01 ${TARGET} # Create ZPOOL zpool create -o ashift=12 -d \ -o feature@async_destroy=enabled \ -o feature@bookmarks=enabled \ -o feature@embedded_data=enabled \ -o feature@empty_bpobj=enabled \ -o feature@enabled_txg=enabled \ -o feature@extensible_dataset=enabled \ -o feature@filesystem_limits=enabled \ -o feature@hole_birth=enabled \ -o feature@large_blocks=enabled \ -o feature@lz4_compress=enabled \ -o feature@spacemap_histogram=enabled \ -O acltype=posixacl -O canmount=off -O compression=lz4 \ -O normalization=formD -O relatime=on -O xattr=sa \ -O mountpoint=/ -R /mnt \ ${ZPOOL} ${TARGET}-part4 # Create datasets, see "Debian Stretch Root on ZFS" for more info zfs create -o canmount=off -o mountpoint=none ${ZPOOL}/ROOT zfs create -o canmount=noauto -o mountpoint=/ ${ZPOOL}/ROOT/linux zfs create mountpoint=legacy ${ZPOOL}/ROOT/home zfs create mountpoint=legacy ${ZPOOL}/ROOT/opt zfs create mountpoint=legacy ${ZPOOL}/ROOT/tmp zfs create mountpoint=none ${ZPOOL}/ROOT/var zfs create mountpoint=legacy ${ZPOOL}/ROOT/var/tmp zfs create mountpoint=legacy ${ZPOOL}/ROOT/var/log # ... # Mount the datasets zfs mount ${ZPOOL}/ROOT/linux for dir in tmp home var/log var/tmp opt do mkdir -pv /mnt/${dir} mount -t zfs ${ZPOOL}/${dir} /mnt/${dir} done # Format and mount EFI partition mkdir -pv /mnt/boot/efi mkfs.vfat -F32 ${TARGET}-part2 mount ${TARGET}-part2 /mnt/boot/efi # Format swap partition mkswap ${TARGET}-part3 # Install Slackware but DO NOT REBOOT when it's finished, # we still have to make the system bootable setup # Install ZFS and SPL packages in /boot/initrd-tree so be included in initrd # TODO: optimize this step, the initrd doesn't need the entire content of # the packages. installpkg --root /mnt/boot/initrd-tree \ /usb-stick/slackware64/a/zfs-on-linux-* \ /usb-stick/slackware64/a/spl-solaris-* # Copy patches to new system cp /usb-stick/zfs/*.patch /mnt/tmp # Chroot into fresh system chroot /mnt /bin/bash # Create mkinitrd.conf cat < /etc/mkinitrd.conf SOURCE_TREE="/boot/initrd-tree" CLEAR_TREE="0" OUTPUT_IMAGE="/boot/initrd.gz" KERNEL_VERSION="\$(uname -r)" KEYMAP="us" MODULE_LIST="zfs" RESUMEDEV="UUID=$(blkid -t TYPE=swap -s UUID -o value)" ROOTDEV="${ZPOOL}/ROOT/linux" ROOTFS="zfs" UDEV="1" EOF # Copy required .so for zpool to initrd cp /usr/lib64/libgcc_s.so* /boot/initrd-tree/usr/lib64 # Add ZFS support to boot scripts patch /boot/initrd-tree/init < /tmp/init.zfs.patch patch /etc/rc.d/rc.S < /tmp/rc.S.zfs.patch # Create initrd mkinitrd -F /etc/mkinitrd.conf # Install GRUB export ZPOOL_VDEV_NAME_PATH=YES grub-install ${TARGET} grub-mkconfig -o /boot/grub/grub.cfg # Create /etc/fstab cat /etc/mtab >> /etc/fstab vi /etc/fstab # Exit chroot exit # Clean up for dir in boot/efi home opt tmp var/log var/tmp sys proc dev do umount -flv /mnt/${dir} done zfs umount -a zpool export -a # Reboot reboot