LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-27-2018, 10:14 PM   #1
replica9000
Senior Member
 
Registered: Jul 2006
Distribution: Debian Unstable
Posts: 1,125
Blog Entries: 2

Rep: Reputation: 260Reputation: 260Reputation: 260
ZFS not importing zpool at boot


At some point, an upgrade had caused ZFS to stop automatically importing the pool on it's own. Not sure if the upgrade that caused this is the kernel, systemd, or ZFS itself. It's been like this for a while. I can manually import the pool with the same command shown in the output below.

ZFS/SPL: 0.7.5-1
Kernel: 4.14.0-3-amd64

Code:
Please unlock disk cryptroot:
[    8.482283] NET: Registered protocol family 38
cryptsetup (cryptroot): set up successfully
done.
Begin: Running /scripts/local-premount ... Begin: Waiting for suspend/resume device ... Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
done.
Gave up waiting for suspend/resume device
done.
Begin: Sleeping for ... done.
[   30.432949] spl: loading out-of-tree module taints kernel.
[   30.435094] SPL: Loaded module v0.7.5-1
[   30.436229] znvpair: module license 'CDDL' taints kernel.
[   30.437122] Disabling lock debugging due to kernel taint
[   32.367164] ZFS: Loaded module v0.7.5-1, ZFS pool version 5000, ZFS filesystem version 5
Begin: Sleeping for ... done.
Begin: Attempting to import additional pools. ... Begin: Importing pool 'zroot' using defaults ... Failure: 127
Begin: Importing pool 'zroot' using cachefile. ... Failure: 127

Command: /sbin/zpool import -c /etc/zfs/zpool.cache -N   'zroot'
Message: /init: line 1: /sbin/zpool import -c /etc/zfs/zpool.cache -N  : not found
Error: 127

Failed to import pool 'zroot'.
Manually import the pool and exit.


BusyBox v1.27.2 (Debian 1:1.27.2-2) built-in shell (ash)
Enter 'help' for a list of built-in commands.

/bin/sh: can't access tty: job control turned off
/#
 
Old 01-31-2018, 11:29 AM   #2
voleg
Member
 
Registered: Oct 2013
Distribution: RedHat CentOS Fedora SuSE
Posts: 354

Rep: Reputation: 51
Been there.
A starting script checks if zfs module installed, if not it skip ZFS activation.
As a dirty workaround I've forced loading module at boot time.
See how here: ZFS recepies
 
Old 07-28-2018, 03:05 PM   #3
-TCM-
LQ Newbie
 
Registered: Jul 2018
Posts: 1

Rep: Reputation: Disabled
For anyone stumbling upon this thread like I did, here is the solution to this particular idiotic problem.

In /usr/share/initramfs-tools/scripts/zfs there are multiple occurrences of the following code, 2 of which are in the function import_pool():

Code:
ZFS_STDERR="$(${ZFS_CMD} 2>&1)
The problem is, this is a bash-ism that doesn't work as it should, in pretty much any other shell. If you look closely at the error

Code:
Message: /init: line 1: /sbin/zpool import -c /etc/zfs/zpool.cache -N  : not found
what you really see is the shell complaining that it can't find a binary called "/sbin/zpool import -c /etc/zfs/zpool.cache -N", including spaces and all. After changing that code to

Code:
ZFS_STDERR="$(eval ${ZFS_CMD} 2>&1)
it works as expected. What this tells you is that not a single person on earth has tested this code in real usage. It also tells you NOT TO PROGRAM FOR BASH if you claim to use /bin/sh in your shebang. Yet again stupid coders using bash ruin it for everyone. Thanks for the waste of time to that particular individual.

Last edited by -TCM-; 07-28-2018 at 03:09 PM.
 
1 members found this post helpful.
Old 08-03-2018, 03:02 PM   #4
replica9000
Senior Member
 
Registered: Jul 2006
Distribution: Debian Unstable
Posts: 1,125

Original Poster
Blog Entries: 2

Rep: Reputation: 260Reputation: 260Reputation: 260
Thank you -TCM-

This did solve my issue, however, I did have to change more than two occurances.

Code:
ZFS_STDERR="$($ZFS_CMD "$pool" 2>&1)"
                        ZFS_STDERR="$($ZFS_CMD "$pool" 2>&1)"
        ZFS_STDERR=$(${ZFS_CMD} "${fs}" "${rootmnt}/${mountpoint}" 2>&1)
                ZFS_STDERR="$(${ZFS_CMD} 2>&1)"
        ZFS_STDERR="$(${ZFS_CMD} 2>&1)"
        ZFS_STDERR="$(${ZFS_CMD} 2>&1)"
        ZFS_STDERR="$(${ZFS_CMD} 2>&1)"
        ZFS_STDERR="$(${ZFS_CMD} 2>&1)"
to

Code:
ZFS_STDERR="$(eval ${ZFS_CMD} "$pool" 2>&1)"
                        ZFS_STDERR="$(eval ${ZFS_CMD} "$pool" 2>&1)"
        ZFS_STDERR=$(eval ${ZFS_CMD} "${fs}" "${rootmnt}/${mountpoint}" 2>&1)
                ZFS_STDERR="$(eval ${ZFS_CMD} 2>&1)"
        ZFS_STDERR="$(eval ${ZFS_CMD} 2>&1)"
        ZFS_STDERR="$(eval ${ZFS_CMD} 2>&1)"
        ZFS_STDERR="$(eval ${ZFS_CMD} 2>&1)"
        ZFS_STDERR="$(eval ${ZFS_CMD} 2>&1)"
And just for good measure, I changed any $ZFS_CMD to ${ZFS_CMD}.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ZFS Snapshots and low space on zpool DarkhunterCZ Linux - Server 0 12-03-2015 07:45 PM
zfs zpool lun resize frankerooney Linux - Server 1 04-14-2014 04:15 PM
ZFS Native replacing disk in zpool Asterlan Linux - Newbie 0 08-06-2012 08:45 AM
is there a way to convert a standard zpool into a raidz pool? (ZFS) LauMars Linux - Server 1 03-08-2009 09:11 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration