Dobrica Pavlinušić's random unstructured stuff
ZFS: Revision 4


ZFS

MySQL

cache only metadata for Innodb

zfs set primarycache=metadata tank/db

match recordsize to block size

before creating database

zfs set recordsize=16k tank/db

root filesystem on zfs

based on https://github.com/zfsonlinux/zfs/wiki/HOWTO-install-Debian-GNU-Linux-to-a-Native-ZFS-Root-Filesystem

root@lib10:~# apt-get install zfs-initramfs

root@lib10:~# zfs create -o mountpoint=none lib10/ROOT

root@lib10:~# zfs create -o mountpoint=/ lib10/ROOT/debian-1
cannot mount '/': directory is not empty
filesystem successfully created, but not mounted

root@lib10:~# zpool set bootfs=lib10/ROOT/debian-1 lib10

root@lib10:~# mkdir /tmp/root
root@lib10:~# mount --bind / /tmp/root/

root@lib10:~# mkdir /tmp/zfs-root
root@lib10:~# zfs set mountpoint=/tmp/zfs-root lib10/ROOT/debian-1
root@lib10:~# zfs mount lib10/ROOT/debian-1
root@lib10:~# zfs set compression=lz4 lib10/ROOT
root@lib10:~# rsync -ravH --numeric-ids /tmp/root/ /tmp/zfs-root/

# duh, source btrfs had snapshot on it

root@lib10:~# rsync -ravH --numeric-ids --exclude '/.snapshot' --exclude '/tmp' --delete /tmp/root/ /tmp/zfs-root/

root@lib10:~# zfs umount lib10/ROOT/debian-1

root@lib10:~# cd /tmp/zfs-root/

root@lib10:~# cd /tmp/zfs-root/
root@lib10:/tmp/zfs-root# mount --bind /dev dev/
root@lib10:/tmp/zfs-root# mount --bind /sys sys/
root@lib10:/tmp/zfs-root# mount --bind /proc/ proc/
root@lib10:/tmp/zfs-root# chroot .
root@lib10:/# 

root@lib10:~# df
Filesystem          1K-blocks    Used Available Use% Mounted on
lib10/ROOT/debian-1 195788544 1149184 194639360   1% /
udev                 10270376       0  10270376   0% /dev
root@lib10:~# mount /boot/
root@lib10:~# df
Filesystem          1K-blocks    Used Available Use% Mounted on
lib10/ROOT/debian-1 195787904 1149184 194638720   1% /
udev                 10270376       0  10270376   0% /dev
/dev/sdg1              198337   62072    136265  32% /boot

root@lib10:~# grep zfs /etc/default/grub 
GRUB_CMDLINE_LINUX_DEFAULT="boot=zfs rpool=lib10 bootfs=lib10/ROOT/debian-1"

root@lib10:~# update-grub

root@lib10:~# grep zfs /boot/grub/grub.cfg 
insmod zfs
        linux   /vmlinuz-4.8.0-2-amd64 root=ZFS=lib10/ROOT/debian-1 ro  boot=zfs rpool=lib10 bootfs=lib10/ROOT/debian-1
                linux   /vmlinuz-4.8.0-2-amd64 root=ZFS=lib10/ROOT/debian-1 ro  boot=zfs rpool=lib10 bootfs=lib10/ROOT/debian-1
                linux   /vmlinuz-4.8.0-1-amd64 root=ZFS=lib10/ROOT/debian-1 ro  boot=zfs rpool=lib10 bootfs=lib10/ROOT/debian-1


root@lib10:~# update-initramfs -v -k all -u

root@lib10:~# umount /boot/
root@lib10:~# exit


root@lib10:~# umount /tmp/zfs-root/dev/
root@lib10:~# umount /tmp/zfs-root/proc/
root@lib10:~# umount /tmp/zfs-root/sys/

root@lib10:~# zfs umount lib10/ROOT/debian-1

root@lib10:~# zfs set mountpoint=/ lib10/ROOT/debian-1