Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 440382 - sys-fs/zfs-0.6.0_rc11: shutdown fails if zfs-shutdown added to shutdown runlevel but root fs is not zfs
Summary: sys-fs/zfs-0.6.0_rc11: shutdown fails if zfs-shutdown added to shutdown runle...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: AMD64 Linux
: High major (vote)
Assignee: Richard Yao (RETIRED)
URL:
Whiteboard:
Keywords: Bug
Depends on:
Blocks:
 
Reported: 2012-10-31 08:23 UTC by Uwe Sauter
Modified: 2013-01-07 20:43 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Uwe Sauter 2012-10-31 08:23:06 UTC
I have installed sys-fs/zfs-0.6.0_rc11 with USE flags rootfs and test-suite. Emerge message contains following lines:

 * You should add zfs to the boot runlevel.
 * You should add zfs-shutdown to the shutdown runlevel.

so I added both init-scripts to the appropriate runlevel.

My root fs is ext4. Every time I try to shutdown the system hangs with error messages like "Cannot remount / read-only because / is not ext4" (I'm too lazy to type the message letter by letter as this happens after syslog shutdown. If needed I will provide the error.)

I think that either

a) the ebuild should mention that adding zfs-shutdown to runlevel shutdown is only useful and necessary if your root partition is zfs, or

b) the zfs-shutdown init script should check, if root partition is zfs, else only umount every other mounted zfs.

Reproducible: Always

Steps to Reproduce:
1. install sys-fs/zfs with USE rootfs test-suite
2. add init scripts to runlevels as mentioned by emerge ( and start /etc/init.d/zfs to load kernel module)
3. shutdown 
Actual Results:  
System hangs while shutting down, does not power off.

Expected Results:  
Clean shutdown.
Comment 1 Sergey Popov gentoo-dev 2012-10-31 14:08:11 UTC
Confirming this.

Situation: root on ext4 LVM volume, initramfs generated by sys-kernel/genkernel-3.4.24_p2, adding zfs-shutdown to shutdown runlevel - and shutdown/reboot stucks with:

/linuxrc: line 10: expr: command not found
Comment 2 Richard Yao (RETIRED) gentoo-dev 2012-12-16 05:16:52 UTC
My apologies for not getting to this sooner. I was preoccupied with Hurricane Sandy when this was filed and I am still catching up on the backlog that caused.

I believe that I fixed this issue a few weeks ago in =sys-fs/zfs-0.6.0_rc12-r1. If that is not the case, please let me know.
Comment 3 Uwe Sauter 2012-12-16 10:58:01 UTC
Hi Richard, thanks for working on this bug. I hope you and your family are all well.

I'm sorry to report that this issue isn't resolved yet. But before presenting the error message, here's a short overview to my drives:

device     fs       mountpoint    options   comment

/dev/sda1  ntfs-3g  /mnt/windows  noauto    my dual-boot windows
/dev/sda2  ext4     /             noatime   Gentoo root
/dev/sda3  swap     -             sw        swap
/dev/sda4  ntfs-3g  /mnt/daten    noatime   data space, access with win and lin
/dev/sdb1  ntfs-3g  /mnt/sdb1     noatime   data space, access with win and lin
and sometimes
/dev/sdc   auto     /mnt/usb                external drive with changing FS including ZFS


So this is the message coming when trying to reboot/shutdown:

########
[...]
Stopping acpid ... [ok]
Stopping syslog-ng ... [ok]
Unmounting ZFS filesystems ... [ok]
Unmounting loop devices ...
Unmounting filesystems ...
  Unmounting /mnt/sdb1 ... [ok]
  Unmounting /mnt/daten ... [ok]
Deactivating swap devices ... [ok]
Stopping udev ... [ok]
Setting hardware clock using system clock [Local Time] ... [ok]
Terminating remaining processes ... [ok]
Killing remaining processes ... [ok]
Saving dependency cache ... [ok]
Remounting remaining filesystems read-only ...
  Remounting / read only ... [ok]

mount: Too many levels of symbolic links
/linuxrc: line 10: expr: command not found
mkdir: cannot create directory '/': File exists
mount: special device /run does not exist
/linuxrc: line 10: expr: command not found
mkdir: cannot create directory '/': File exists
mount: wrong fs type, bad option, bad superblock on /dev,
       missing codepage or helper program, or other error
       In some cases useful info is found in syslog - try
       dmesg | tail or so

/linuxrc: line 10: expr: command not found
mkdir: cannot create directory '/': File exists
mount: special device /sys/fs/cgroup does not exist
/linuxrc: line 10: expr: command not found
Failed to load ZFS module stack.
Load the module manually by running 'insmod <location>/zfs.ko' as root.
internal error: unable to open /etc/mtab
Failed to load ZFS module stack.
Load the module manually by running 'insmod <location>/zfs.ko' as root.
Failed to load ZFS module stack.
Load the module manually by running 'insmod <location>/zfs.ko' as root.
########

Then the system hangs and only a long press on the power button powers off the system.

Oh, one thing: I'm using =sys-kernel/gentoo-sources-3.5.7 but no initrd.
Comment 4 Richard Yao (RETIRED) gentoo-dev 2012-12-16 22:51:05 UTC
What does `df -TP / | awk 'NR>1{print $2}'` output on your system?
Comment 5 Uwe Sauter 2012-12-17 07:28:25 UTC
As I wrote in comment #3 my root partition (sda2) is ext4:

> df -TP / | awk 'NR>1{print $2}'
ext4
Comment 6 Simon Bühler 2013-01-05 23:43:33 UTC
i have a problem on shutdown with a root ZFS system and /usr/portage etc as seperate datasets:

when trying to shutdown i get:
can't unmount /usr, still busy

added zfs-shutdown to the shutdown runlevel
Comment 7 Uwe Sauter 2013-01-06 09:04:34 UTC
Hi Simon,

please provide the output of "zfs list" and "rc-update show". Did your problem occur with or without zfs-shutdown being in the shutdown runlevel? Did adding it to the shutdown runlevel solve your problem?
Comment 8 Richard Yao (RETIRED) gentoo-dev 2013-01-07 20:31:57 UTC
Originally, I wrote the zfs-shutdown script because I felt that it would be a good idea to cleanly export the root pool, but that is unnecessary. No other ZFS implementation does this and I am now fairly certain that it was a mistake. Situations where the pool is cleanly exported will result in a label update that invalidates zpool.cache, requiring a force import on the next reboot.

As a consequence, the zfs-shutdown script will never work as I had originally intended and I have removed it from the tree. If you update sys-fs/zfs and have zfs-shutdown in the boot runlevel, it will be automatically removed.
Comment 9 Richard Yao (RETIRED) gentoo-dev 2013-01-07 20:42:13 UTC
As an additional note, you will see some messages about not being able to unmount datasets at shutdown when using ZFS as a root filesystem. This is harmless.

What happens is that during shutdown, OpenRC will invoke RC/init scripts' shutdown() functions in reverse order of dependencies. This means that zfs is called before localmount. When the rootfs is ZFS, zfs will naturally try to unmount it, but localmount has other stuff on top, which prevents that, causing information about the failure to unmount ZFS to be printed.

That is a comsetic issue. I plan to address it in the future, but I consider it to be a low priority. I have opened a new bug to track it. I have also CCed the people in this bug.
Comment 10 Richard Yao (RETIRED) gentoo-dev 2013-01-07 20:42:26 UTC
(In reply to comment #9)
> As an additional note, you will see some messages about not being able to
> unmount datasets at shutdown when using ZFS as a root filesystem. This is
> harmless.
> 
> What happens is that during shutdown, OpenRC will invoke RC/init scripts'
> shutdown() functions in reverse order of dependencies. This means that zfs
> is called before localmount. When the rootfs is ZFS, zfs will naturally try
> to unmount it, but localmount has other stuff on top, which prevents that,
> causing information about the failure to unmount ZFS to be printed.
> 
> That is a comsetic issue. I plan to address it in the future, but I consider
> it to be a low priority. I have opened a new bug to track it. I have also
> CCed the people in this bug.
Comment 11 Richard Yao (RETIRED) gentoo-dev 2013-01-07 20:43:11 UTC
Ignore that last comment. I was setting bug #450758 under See Also and accidentally hit enter without realizing that I had started a reply to myself.