ZFS root on Manjaro

Anyone running a zfs root partition?

I have been increasingly using zfs. Currently, my data is on zfs and my root partition is ext4.

I am building out a new PC and toying with the idea of moving my root partition to zfs.

I have read a couple of articles/tutorials on it including the info in the arch wiki and it seems possible.

I suppose you would need to do an M-A install and pre-mount the root filesystem before running M-A?

Also, what bootloader are people using? It seems like grub, refind and systemd-boot all have support for zfs.

I was going to say it could be an option in MA … then I realized it requires a custom kernel…

Note: Due to potential legal incompatibilities between CDDL license of ZFS code and GPL of the Linux kernel ([2],CDDL-GPL,ZFS in Linux) - ZFS development is not supported by the kernel.

As a result:

  • ZFSonLinux project must keep up with Linux kernel versions. After making stable ZFSonLinux release - Arch ZFS maintainers release them.
  • This situation sometimes locks down the normal rolling update process by unsatisfied dependencies because the new kernel version, proposed by update, is unsupported by ZFSonLinux.
Though what MA already offers aint bad:
  • btrfs
  • ext3
  • ext4
  • jfs
  • nilfs2
  • ntfs
  • reiserfs
  • vfat
  • xfs

Manjaro has zfs support. There is a kernel module for it in the repos.

Ah… well then…
https://gitlab.manjaro.org/applications/manjaro-architect/blob/master/lib/util-disk.sh
[starting around line 240]

Yes, I think, I would have to create and mount the filesystem ahead of time since m-a doesn’t handle zfs.

Sounds like the kind of thing I should test in a vm first.

Well, yeah :wink:
Dont go patching and running on your bosses production server or anything. .
[this is a new feature you want … but it is untested … seems we can implement it … but testing]
(PS - I use ‘we’ alot in the royal or commie or whatever sense :slight_smile:)
@Chrysostomus is the MA person… maybe they have thoughts?

You might be interested in this, it includes a tutorial made by another ZFS user

OK, so it seems the real problem is this:

Essentially, there is no way to get consistent zfs support on a the live images. As soon the kernel changes, the zfs modules can no longer be loaded.

Thanks. It seems what he is doing is installing to USB, doing the zfs setup and then copying the system. That seems like a huge pita.

I might try making my own ISO that includes the packages needed for zfs support.

Well, I made some progress.

  • It was surprisingly easy to make a new ISO which included the packages needed for zfs support
  • I went partially through the m-a installer to see how it mounted the partitions(It just uses /mnt as the root)
  • I used gparted to partition the disk and then created the zfs pool and a dataset for / and /home
  • On my first pass through it threw an error that I hadn’t mounted the partitions.
    • I took a look at it and it uses lsblk to check mounts which doesn’t work for zfs
    • Commenting out check_mount() served as an effective workaround
  • At this point, m-a installed the system onto my zfs datasets but it didn’t know how to configure the bootloader for zfs so I am not yet sure how well it worked.

I think I am done for tonight but my next task will be seeing if I can figure out how to manually setup the bootloader.

The mounting wizard sets some flags besides just mounting the partitions, so it usually best to run through it, and then (reformat and) remount the partitions how you actually want them. Not sure how relevant that is for ZFS though…

1 Like

I totally failed to get refind working. This is probably due more to my lack of knowledge of refind than an issue with zfs.

However, I got everything working with systemd-boot

I will need to do another dry-run and document everything as I go. I will share the steps here in case anyone else finds it useful in the future.

3 Likes

After running through this again I think it would be a decent amount of work to get zfs support fully working in m-a.

One thing that would make life a lot easier would be to replace the call to lsblk -o MOUNTPOINT in check_mount() with a call to mount or something that has a more general way of checking mounted filesystems.

Unless I am missing something(which is totally possible), it would be as simple as replacing:

if [[ $(lsblk -o MOUNTPOINT | grep ${MOUNTPOINT}) == "" ]]; then

with

if [[ $(cat /proc/mounts | grep ${MOUNTPOINT}) == "" ]]; then

I’ll look into it when I have the time, it might be useful also for mounting btrfs subvolumes

1 Like

I would love to switch to Manjaro - and I would love to keep ZFS as my file system of choice.

My knowledge to use ZFS in Manjaro is currently limited so I would really (as in please :wink:) appreciate, if you @dalto could share what you did and how you did it.
As detaild as possible of course. :smile:

Thanks upfront, merry Christmas and a happy 2019!

Are you wanting to use zfs as your / filesystem? That is the only hard part.

If you want to use zfs for /home or some other data it pretty much works out of the box.

You just need to install linux*-zfs and linux*-zpl

For example sudo pacman -S linux419-zfs linux419-spl if you are using kernel 4.19.

Then either reboot or sudo modprobe zfs

Can you give a little more detail about what you are trying to accomplish?

If I create an iso with linux419-zfs and linux419-spl
can I install using calamares and use zfs as root.
Does calamares provide format as zfs option
or
have to format as zfs before installing with calamares and set mount point

No. 

calamares doesn’t support zfs at all. I don’t think you could install a zfs root using the built-in manjaro calamares, even if you mounted the filesystems ahead of time. I don’t think it will let you past the partitioning screen since it won’t recognize the filesystem

I have done all my installs with m-a. You could also unpack the files from the iso into a previously mounted filesystem but then you would need to do the rest of the install manually. This seems much harder than using m-a.

1 Like

I am working on a tutorial for zfs on root for Manjaro. However, it will come with disclaimers and will probably never be a “blindly type these commands” type of scenario. It will require some careful thought and an understanding of what you are doing.

Here are the general steps if someone wants to tackle it before I finish writing it up.

  • Create a custom ISO
  • Load the kernel module
  • Manually partition the disk(s)
  • Create the zfs pool(s) and datasets
  • Update manjaro-architect
  • Modify the check_mount() function in m-a
  • Mount all the filesystems manually in /mnt
  • Run portions of the manjaro-architect install process
  • Edit /etc/mkinitcpio.conf and regenerate initrds for all installed kernels
  • Configure and install a bootloader
  • Enable zfs services
  • Prepare and export zpool

It is somewhat time consuming to create and test the detailed instructions because of the integration with the boot loader and uefi vs mbr, systemd-boot vs grub, etc

In hindsight, it probably would have made more sense to spend my time creating patches for m-a to add zfs support than what I have been doing.

3 Likes

I think at least those two could/should be solved at distro level. I can modify the function and add ZFS modules to the iso.

Btw, if you can send a merge request to https://gitlab.manjaro.org/applications/manjaro-architect/tree/master, it might get included faster that way.

I think that could be a good start for the ZFS support.

3 Likes

Forum kindly sponsored by