首页 > 解决方案 > Ubuntu 18.04 上的 zfs 传统挂载

问题描述

我在通用 Ubuntu 18.04 系统上使用 zfs。使用普通挂载点创建和挂载文件系统时一切正常。

但是,如果我可以使用在引导时自动挂载的传统挂载,我有一个用例会有所帮助。

如果我将传统挂载设置为noauto然后在启动后手动挂载,一切正常。

但是当我删除时noauto,我无法在启动时自动挂载。很明显问题出在哪里 - 在启动期间,在加载 ZFS 模块之前尝试安装驱动器:

$ systemctl status home-vagrant.mount
● home-vagrant.mount - /home/vagrant
   Loaded: loaded (/etc/fstab; generated)
   Active: failed (Result: exit-code) since Thu 2020-04-30 11:41:07 PDT; 24s ago
    Where: /home/vagrant
     What: vagrant
     Docs: man:fstab(5)
           man:systemd-fstab-generator(8)
  Process: 464 ExecMount=/bin/mount vagrant /home/vagrant -t zfs (code=exited, status=2)

Apr 30 11:41:07 ubuntu mount[464]: The ZFS modules are not loaded.
Apr 30 11:41:07 ubuntu mount[464]: Try running '/sbin/modprobe zfs' as root to load them.
Apr 30 11:41:07 ubuntu systemd[1]: home-vagrant.mount: Mount process exited, code=exited status=2
Apr 30 11:41:07 ubuntu systemd[1]: home-vagrant.mount: Failed with result 'exit-code'.
Apr 30 11:41:07 ubuntu systemd[1]: Failed to mount /home/vagrant.

当然,稍后在引导过程中会加载 ZFS 模块并且可以正确挂载它。我可以在启动打印输出中看到这两个事件,很明显问题出在哪里 - 但不是修复。

我还没有找到一个简单的方法来处理这个问题。从我所见,似乎安装 zsh-initramfs 应该对此有所帮助 - 但是如何?

那里漂浮的少量信息似乎主要涉及将 zsh 用于根文件系统,并且在许多情况下要复杂得多。

部分用例可能会解释为什么我需要传统挂载 - 我有绑定挂载,这些挂载挂载在 ZFS 文件系统中。所以一种解决方法是使用链接而不是安装 - 如果我不能解决这个问题,那就是我要做的。

但这似乎应该是可行的!

标签: ubuntu-18.04zfs

解决方案


一种可能的解决方法是在您的 initrd 中加载 zfs 内核模块。我不确定 Ubuntu,但在 CentOS/Fedora 上,您可以在 /etc/sysconfig/modules 中添加一个脚本,该脚本在安装rootfs后立即执行。您可能想看看 Ubuntu 中是否有类似物。


推荐阅读