Skip to content
This repository

zfs not automounted during boot from init.d script in Ubuntu #381

Closed
astifter opened this Issue August 31, 2011 · 17 comments

7 participants

Andreas Neustifter Darik Horn Brian Behlendorf randomei Wim Van Leuven snowshoefox durandalTR
Andreas Neustifter

As discussed in http://groups.google.com/a/zfsonlinux.org/group/zfs-discuss/browse_thread/thread/0dc5b17133810e13# automount on Ubuntu does not work due to the zfs kernel modules not being loaded on time for the init.d scripts.

Is it possible that some recent commit massively increased the time for the zfs modules to load?

Andreas Neustifter

This is a workaround that waits for up to 2 minutes for the zfs mount -a to be successful.

diff --git a/init.d/zfs b/init.d/zfs
index 6263862..4f5be7f 100755
--- a/init.d/zfs
+++ b/init.d/zfs
@@ -26,8 +26,17 @@ PATH=/sbin:/bin:/usr/sbin:/usr/bin
 do_start() {
    log_begin_msg "Starting ZFS subsystem"
    log_progress_msg "filesystems"
-   zfs mount -a
-   RET=$?
+   COUNT=0
+   while [ $COUNT -lt 12 ] ; do
+       zfs mount -a
+       RET=$?
+       if [ $RET == 0 ] ; then
+           break
+       fi
+       logger -i -s -t zfs "Unable to mount zfs, waiting..."
+       COUNT=$(( $COUNT + 1 ))
+       sleep 5
+   done
    if [ $RET != 0 ] ; then
        log_end_msg $RET
        exit $RET
Brian Behlendorf
Owner

I can't think of anything which would have slowed down the zfs module load time that drastically. As for your patch you might try something a little cleaner and just wait for the /dev/zfs device to appear after a modprobe zfs. Once the device is available zfs is ready to go.

Andreas Neustifter

Ah, yes, that's very true:

diff --git a/init.d/zfs b/init.d/zfs
index 6263862..efc0145 100755
--- a/init.d/zfs
+++ b/init.d/zfs
@@ -26,6 +26,15 @@ PATH=/sbin:/bin:/usr/sbin:/usr/bin
 do_start() {
    log_begin_msg "Starting ZFS subsystem"
    log_progress_msg "filesystems"
+   COUNT=0
+   while [ $COUNT -lt 12 ] ; do
+       if [ -c /dev/zfs ] ; then
+           break
+       fi
+       COUNT=$(( COUNT + 1 ))
+       logger -t zfs -i "$COUNT unsuccessful test for /dev/zfs, sleeping for 5 seconds."
+       sleep 5
+   done
    zfs mount -a
    RET=$?
    if [ $RET != 0 ] ; then
Andreas Neustifter astifter closed this September 05, 2011
Andreas Neustifter astifter reopened this September 05, 2011
randomei

This issue also affects me.

/var/log/boot.log fragment:

Unable to open /dev/zfs: No such file or directory.
Verify the ZFS module stack is loaded by running '/sbin/modprobe zfs'.
Unable to open /dev/zfs: No such file or directory.
Verify the ZFS module stack is loaded by running '/sbin/modprobe zfs'.

  • Starting ZFS subsystem [80G [74G[[31mfail[39;49m]

After loggin in terminal and running "sudo service zfs start" zfs starts without any error.

Wim Van Leuven

Also affected by this issue (on Ubuntu)

/var/log/boot.log fragment

Unable to open /dev/zfs: No such file or directory.
Verify the ZFS module stack is loaded by running '/sbin/modprobe zfs'.
Unable to open /dev/zfs: No such file or directory.
Verify the ZFS module stack is loaded by running '/sbin/modprobe zfs'.

  • Starting ZFS subsystem ESC[80G ^MESC[74G[ESC[31mfailESC[39;49m]

Also, after logging in a terminal and starting the service, everything works w/o any error.

Brian Behlendorf
Owner

This is Ubuntu integration issue and Darik Horn has been working on this issue. If your running Ubuntu Oneiric see he recent post to the zfs-discuss mailing list:

http://groups.google.com/a/zfsonlinux.org/group/zfs-discuss/browse_thread/thread/5b25e2a172cd2616#

Wim Van Leuven

Will this mauntall pacakge be merged in the stable release one day?

Darik Horn
Collaborator

@wimvanleuven: I intend to move the mountall package into the stable PPA for the Ubuntu 12.04 LTS release if I get positive feedback. Please try it.

Darik Horn
Collaborator

@wimvanleuven @astifter

Any feedback or other commentary on this issue? Did the mountall package in the daily PPA resolve the problem?

This ticket is becoming stale, so I intend to close it December 7th.

Wim Van Leuven

I haven't been able to test it yet. Didn't find the time. I'll try to verify it this weekend.

Darik Horn
Collaborator

@behlendorf: I don't have permission to close assignments. Please close this one.

Brian Behlendorf
Owner

Done.

Yes, I wish I could assign those sort of permissions but the Github tools don't seem to allow that level of granularity.

Brian Behlendorf behlendorf closed this December 14, 2011
Brian Behlendorf
Owner

@dajhorn: Related to this what are your thoughts on the proposed auto import behavior I quickly described in #330. It seems like the right thing to do in general but I'm sure your more familiar with the various Ubuntu integration issue than I am.

#330 (comment)

Darik Horn
Collaborator

@behlendorf: I think that the proposal in #330 is a good thing, and I looked at the initialization code last week when I started the dajhorn/pkg-zfs@issue330 branch.

Looking at the bottom of spa_init(), it isn't obvious to me where the auto import and auto mount actually happens, so I need to get some time to trace it. Any hints?

Brian Behlendorf
Owner

spa_init()->spa_config_load()

The spa_config_load() function opens up /etc/zfs/zpool.cache and reads out the cached configuration information as an nvlist. This is really a no-no from kernel space but I did it anyway, it's what Solaris does, and it wasn't clear to me yet what the right thing for Linux was. It then creates the basic spa namespace but doesn't actually open any of the pools, the configuration is enough for things like zpool list to work. The pools themselves will be opened latter as needed. For the purposes of zfs internally an open and an import and basically the same thing.

Anyway, for the purposes of that bug simply skipping spa_config_load() would have the desired effect of ignoring the /etc/zfs/zpool.cache file.

snowshoefox

Ubuntu user here digging up an old bone... I ran into this issue recently as well. The simplest fix I found is just let udevadm settle on the device file.

Just add this to /etc/init.d/zfs before "zfs mount -a".
udevadm settle --exit-if-exists=/dev/zfs

durandalTR

I also still have this problem in Ubuntu 12.04.1
(Re)opened a ticket here: https://github.com/dajhorn/pkg-zfs/issues/53

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.