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

Closed
astifter opened this Issue Aug 31, 2011 · 18 comments

Comments

Projects
None yet
8 participants
@astifter

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?

@astifter

This comment has been minimized.

Show comment
Hide comment
@astifter

astifter Aug 31, 2011

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

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
@behlendorf

This comment has been minimized.

Show comment
Hide comment
@behlendorf

behlendorf Sep 5, 2011

Member

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.

Member

behlendorf commented Sep 5, 2011

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.

@astifter

This comment has been minimized.

Show comment
Hide comment
@astifter

astifter Sep 5, 2011

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

astifter commented Sep 5, 2011

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

@astifter astifter closed this Sep 5, 2011

@astifter astifter reopened this Sep 5, 2011

@randomei

This comment has been minimized.

Show comment
Hide comment
@randomei

randomei Sep 12, 2011

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.

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.

@wimvanleuven

This comment has been minimized.

Show comment
Hide comment
@wimvanleuven

wimvanleuven Nov 6, 2011

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.

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.

@behlendorf

This comment has been minimized.

Show comment
Hide comment
@behlendorf

behlendorf Nov 7, 2011

Member

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#

Member

behlendorf commented Nov 7, 2011

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#

@wimvanleuven

This comment has been minimized.

Show comment
Hide comment
@wimvanleuven

wimvanleuven Nov 7, 2011

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

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

@dajhorn

This comment has been minimized.

Show comment
Hide comment
@dajhorn

dajhorn Nov 8, 2011

Member

@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.

Member

dajhorn commented Nov 8, 2011

@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.

@ghost ghost assigned dajhorn Nov 8, 2011

@dajhorn

This comment has been minimized.

Show comment
Hide comment
@dajhorn

dajhorn Dec 1, 2011

Member

@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.

Member

dajhorn commented Dec 1, 2011

@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.

@wimvanleuven

This comment has been minimized.

Show comment
Hide comment
@wimvanleuven

wimvanleuven Dec 1, 2011

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

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

@dajhorn

This comment has been minimized.

Show comment
Hide comment
@dajhorn

dajhorn Dec 14, 2011

Member

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

Member

dajhorn commented Dec 14, 2011

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

@behlendorf

This comment has been minimized.

Show comment
Hide comment
@behlendorf

behlendorf Dec 14, 2011

Member

Done.

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

Member

behlendorf commented Dec 14, 2011

Done.

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

@behlendorf behlendorf closed this Dec 14, 2011

@behlendorf

This comment has been minimized.

Show comment
Hide comment
@behlendorf

behlendorf Dec 14, 2011

Member

@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)

Member

behlendorf commented Dec 14, 2011

@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)

@dajhorn

This comment has been minimized.

Show comment
Hide comment
@dajhorn

dajhorn Dec 14, 2011

Member

@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?

Member

dajhorn commented Dec 14, 2011

@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?

@behlendorf

This comment has been minimized.

Show comment
Hide comment
@behlendorf

behlendorf Dec 14, 2011

Member

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.

Member

behlendorf commented Dec 14, 2011

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

This comment has been minimized.

Show comment
Hide comment
@snowshoefox

snowshoefox Feb 25, 2012

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

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

This comment has been minimized.

Show comment
Hide comment
@durandalTR

durandalTR Oct 25, 2012

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

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

@RoxyFlux

This comment has been minimized.

Show comment
Hide comment
@RoxyFlux

RoxyFlux Jun 25, 2014

Mint 17 here. Just bumped into this today. No automount occurs before MDM presents itself asking for my creds. Both there and on terminal my $HOME is set to the system root because my /home is not mounted.

sudo zfs mount -a doesn´t throw any kind of errors though, and does what it should.

This is a nuisance-type bug, for sure.

Mint 17 here. Just bumped into this today. No automount occurs before MDM presents itself asking for my creds. Both there and on terminal my $HOME is set to the system root because my /home is not mounted.

sudo zfs mount -a doesn´t throw any kind of errors though, and does what it should.

This is a nuisance-type bug, for sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment