… or any other recent enough version of Linux …
Everyone seems to be praising ZFS for its advanced features and its reliability and all sorts of other crap and they’re right to do that. The only thing I hate about it is its stupid license which is not GPL compatible which is complicating things for me because I’d like to see the darn thing in the kernel.
I’ve been working with the “original” version of it on Solaris as well as on OpenIndiana as well as the “linux” version of it on various flavours of Linux (yes, Gentoo as well and even a farily old NAS running BSD with ZFS ) and to be honest … the only problems I’ve encountered were related to either not having enough RAM on the machine or human errors.
The damn thing is so resilient that it made me consider the option of running my Linux machines on it (as in the root / file system) despite the crappy process involved to get that to work (once again, thank you Sun for your shitty CDDL license).
Let’s get down to business:
I started doing this based on following article:
https://wiki.gentoo.org/wiki/User:Fearedbliss/Installing_Gentoo_Linux_On_ZFS
Step1: Boot a live cd that has zfs on it (not gonna be easy to find one considering the crappy licensing but nobody will stop you from creating one or getting an unofficial one) – I found an Arch Linux iso that worked … https://xyinn.org/gentoo/livecd/
Step2: boot your machine using that iso (like you’d do with a an official gentoo iso)
Step3: partition your drive (like you would for installing Gentoo). I chose to not go with the efi model and got /boot running on xfs. The link I shared will contain information for boot partition on zfs provided you don’t upgrade the pool and because of that I felt like not using zfs for my /boot mountpoint
Step4: getting that sweet zfs root in place looks like this:
tank is the name of the storage pool, feel free to replace “tank” with whatever … I chose to replace with “storage” on my system
zpool create -f -o ashift=12 -o cachefile= -O compression=lz4 -O acltype=posixacl -O atime=off -O xattr=sa -m none -R /mnt/gentoo tank /dev/sda4
(replace /dev/sda4 with the relevant partition that you want to use , if you’re using multiple drives in the process don’t be shy and feel free to use mirrored setups or raidz, also notice -R /mnt/gentoo which will essentially use that path as the mountpoint for the newly created pool which also means the file systems we’ll be creating further on will have this as the relative mountpoint)
zfs create tank/gentoo
(the command above will create a zfs filesystem named gentoo on storage pool tank)
zfs create -o mountpoint=/ tank/gentoo/os
(the command above will create a zfs filesystem named os on top of the gentoo one on top of the storage pool tank which will have the mountpoint set to / when mounted by zfs)
zfs create -o mountpoint=/home tank/gentoo/home
(the command above will create a zfs filesystem named home on top of the gentoo one on top of the storage pool tank which will have the mountpoint /home when mounted by zfs)
Notice I chose to create /home as a separate file system – did that because I wanted to have the ability to snapshot it separately. Nothing should stop you from doing that for other parts of the system (ex. /var/lib/mysql or whatever)
Step5: Continue with remaining steps like prepping your swap partition then chroot (before chrooting mkdir /mnt/gentoo/etc/zfs
&& cp /etc/zfs/zpool.cache /mnt/gentoo/etc/zfs
) and continue with the normal gentoo installation process. Make sure you install the zfs packages and make sure grub and genkernel have the required zfs support (echo "sys-boot/grub libzfs" >> /etc/portage/package.use
)
Step6: After you got the packages compiled and everything ready to be able to run your Gentoo OS you need to sort out the kernel, grub.cfg and /etc/fstab files. I compiled my kernel using genkernel with the strategic zfs option so that zfs would be added to my initramfs (including that /etc/zfs/zpool.cache file) and then I modified my /etc/default/grub file like so:
GRUB_CMDLINE_LINUX=”dozfs root=ZFS=tank/gentoo”
and ran the classic grub-mkconfig command to generate the grub.cfg file.
Last step: Reboot and enjoy. You’re now running your very own Gentoo on ZFS (GoZ)
🙂