Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 579876

Summary: sys-apps/util-linux: make nofail be silent about ntfs if windows is hibernated
Product: Gentoo Linux Reporter: nobody <noreply>
Component: [OLD] Core systemAssignee: Gentoo's Team for Core System packages <base-system>
Status: UNCONFIRMED ---    
Severity: major    
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
See Also: https://github.com/karelzak/util-linux/issues/316
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: as suggest per karelzak in openrc bug tracker

Description nobody 2016-04-13 23:19:07 UTC
Adding nofail do nothing, when the fs with nofail fail to mount, openrc and depending services fail to start.



Reproducible: Always

Steps to Reproduce:
1.add a non working fs with nofail as option
2.start openrc
3.the non working fs prevent openrc to continue its work



/dev/disk/by-label/WINDOWS              /mnt/windows    ntfs-3g            user,uid=1000,gid=100,nofail      0 0

for the story why it couldn't mount it:
mount /dev/disk/by-label/WINDOWS /mnt/windows -t ntfs-3g
Windows is hibernated, refused to mount.
Failed to mount '/dev/sda4': Opération non permise
The NTFS partition is in an unsafe state. Please resume and shutdown
Windows fully (no hibernation or fast restarting), or mount the volume
read-only with the 'ro' mount option.

Well, no big deal if openrc keep going even it couldn't mount this one, that's what i expect from the "nofail" option, but it doesn't not, and worst all services that depend on it are also unable to start (no network...)
Comment 1 nobody 2016-04-14 11:01:08 UTC
totally forget to provide infos, sorry:

emerge --info openrc
Portage 2.2.28 (python 2.7.11-final-0, default/linux/x86/13.0, gcc-4.9.2, glibc-2.20-r2, 3.18.30 i686)
=================================================================
                         System Settings
=================================================================
System uname: Linux-3.18.30-i686-Intel-R-_Core-TM-_i7-4790K_CPU_@_4.00GHz-with-gentoo-2.2
KiB Mem:    16574584 total,  10743564 free
KiB Swap:    7167996 total,   7166468 free
Timestamp of repository gentoo: Fri, 08 Apr 2016 16:30:01 +0000
sh bash 4.3_p42-r2
ld GNU ld (Gentoo 2.25.1 p1.1) 2.25.1
distcc 3.2rc1 i686-pc-linux-gnu [enabled]
app-shells/bash:          4.3_p42-r2::gentoo
dev-java/java-config:     2.2.0-r3::gentoo
dev-lang/perl:            5.22.1::gentoo
dev-lang/python:          2.7.11-r2::gentoo, 3.3.5-r7::gentoo, 3.4.3-r7::gentoo, 3.5.1-r2::gentoo
dev-util/cmake:           3.5.1::gentoo
dev-util/pkgconfig:       0.29.1::gentoo
sys-apps/baselayout:      2.2::gentoo
sys-apps/openrc:          0.20.5::gentoo
sys-apps/sandbox:         2.10-r2::gentoo
sys-devel/autoconf:       2.13::gentoo, 2.69-r2::gentoo
sys-devel/automake:       1.11.6-r1::gentoo, 1.12.6::gentoo, 1.13.4::gentoo, 1.14.1-r1::gentoo, 1.15-r2::gentoo
sys-devel/binutils:       2.25.1-r1::gentoo
sys-devel/gcc:            4.9.2::gentoo
sys-devel/gcc-config:     1.8-r1::gentoo
sys-devel/libtool:        2.4.6-r2::gentoo
sys-devel/make:           4.1-r1::gentoo
sys-kernel/linux-headers: 3.18::gentoo (virtual/os-headers)
sys-libs/glibc:           2.20-r2::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000

local_overlay
    location: /usr/local/portage
    masters: gentoo
    priority: 0

hasufell
    location: /var/lib/layman/hasufell
    masters: gentoo
    priority: 50

Installed sets: @system
ACCEPT_KEYWORDS="x86 ~x86"
ACCEPT_LICENSE="*"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-march=haswell -mmmx -msse -msse2 -msse3 -mssse3 -mcx16 -msahf -mmovbe -maes -mpclmul -mpopcnt -mabm -mfma -mbmi -mbmi2 -mavx -mavx2 -msse4.2 -msse4.1 -mlzcnt -mrtm -mhle -mrdrnd -mf16c -mfsgsbase -mfxsr -mxsave -mxsaveopt --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=8192 -mtune=haswell -fstack-protector-strong"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt /var/lib/hsqldb"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-march=haswell -mmmx -msse -msse2 -msse3 -mssse3 -mcx16 -msahf -mmovbe -maes -mpclmul -mpopcnt -mabm -mfma -mbmi -mbmi2 -mavx -mavx2 -msse4.2 -msse4.1 -mlzcnt -mrtm -mhle -mrdrnd -mf16c -mfsgsbase -mfxsr -mxsave -mxsaveopt --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=8192 -mtune=haswell -fstack-protector-strong"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--keep-going --buildpkg"
FCFLAGS="-O2 -march=i686 -pipe"
FEATURES="assume-digests binpkg-logs buildpkg config-protect-if-modified distcc distcc-pump ebuild-locks fixlafiles merge-sync news parallel-fetch protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch usersandbox usersync xattr"
FFLAGS="-O2 -march=i686 -pipe"
GENTOO_MIRRORS="ftp://ftp.free.fr/mirrors/ftp.gentoo.org ftp://mirror.ovh.net/gentoo-distfiles http://gentoo.mirror.sdv.fr/  http://gentoo.oregonstate.edu/ http://www.ibiblio.org/pub/Linux/distributions/gentoo"
INSTALL_MASK="/usr/lib/systemd /etc/systemd"
LANG="fr_FR.UTF-8"
LDFLAGS="-Wl,-Ol -Wl,--as-needed"
MAKEOPTS="-j12 -l8"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
USE="X a52 aac aalib acl acpi alsa amarok apng audacious audio berkdb branding bzip2 cairo cdda cdr cleartype cli consolekit corefonts cracklib crypt cups cxx dbase dbus device-mapper divx dri dvd dvdread embedded encode exif extras fbsplash ffmpeg firefox flac ftp gdbm gdu glitz gmedia gnutls gstreamer gtk gtk2 gudev hddtemp iconv icu imap introspection ipod java javascript jpeg jpeg2k kde lame libcaca libnotify live lm_sensors logrotate lzo maildir matroska mdnsresponder-compat midi mikmod minizip mjpeg mng mod modplug modules moznomail moznoxft mp3 mp4 mp4live mpeg mpeg2 mplayer msn musepack ncurses network nfs nls nptl nsplugin ntfs ogg openal opengl openmp pam pcre pdf png policykit python qt3support qt4 readline sdl sdl-image sensord session skins smp sqlite ssl startup-notification stream subtitles svg tcpd tga theora threads thunderbird tiff timidity truetype type1 udev unicode usb v4l v4l2 vcd vdpau vlm vorbis webkit wma wmf wxwidgets wxwindows x264 x86 xattr xcb xcomposite xine xinerama xosd xulrunner xv xvid zip zlib" ABI_X86="32" ALSA_CARDS="intel-hda" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx avx2 fma3 mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="fr fr_FR" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-5" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_4" RUBY_TARGETS="ruby22 ruby20" USERLAND="GNU" VIDEO_CARDS="nvidia" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CC, CPPFLAGS, CTARGET, CXX, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON

=================================================================
                        Package Settings
=================================================================

sys-apps/openrc-0.20.5::gentoo was built with the following:
USE="ncurses netifrc pam unicode -audit -debug -newnet (-prefix) (-selinux) -static-libs -tools"
Comment 2 William Hubbs gentoo-dev 2016-04-14 21:46:30 UTC
The nofail option works if the device the file system is on doesn't
exist. For example, if you are unable to reach a network file system.

If this is actually a bad file system, you have two options:

You can add noauto instead of nofail so mount -a doesn't try to mount
it, or you can set ignore_mount_errors="yes" in /etc/conf.d/localmount.
I recommend the first method, because the second will ignore more things
than just bad mounts.
Comment 3 nobody 2016-04-15 11:00:03 UTC
Thanks, i'll pickup the ignore_mount_error option.

But trying to figure how "nofail" works, it raise other questions:

1/ the news didn't speak about nofail be a network only option, news says localmount and netmount change to fail now if fs cannot be mount but news then says "nofail" will allow the mount to fail. But the news didn't says it's only for network, nor it says it's only for some specifics conditions.

2/ looking at netmount, i see no "nofail" check in it. So i don't see any "nofail" support, i don't see any also in localmount, but it's ok as you said it's a netmount option only. I suppose you handle it elsewhere.

3/ netmount have a bug
- line 38 : mount -at $fs
- and on next line, it check if system is linux, and on linux only it try to "mount -a -O _netdev"
That's not right, here's why
some_server:/goodmount /mnt/good nfs4 rw,_netdev
some_server:/badmount /mnt/will_fail nfs4 rw

line38: rc=32 : /badmount is bad and cannot be mount, but /goodmount succeed
line41: mount -O _netdev will only try to mount /goodmount only, as only that fs have the _netdev option set, and it is already mount, no other fs will be check.
so at line42: $rc=0
and while line38 return error 32, line42 now return 0 and openrc will tell user everything is ok.
line42 should be some kind of  if ["$rc" -eq 0]; then $rc=$?

4/ it seems strange (for me) that openrc, return 0 unconditionally for non linux system.
Do you know any non linux system where mount isn't reliably returning 0 on success and non 0 on errors?
I don't think it's nice that linux system have difference like that if there's no real reason to have one, i would prefer openrc running with exceptions for the ones that aren't linux and have a problem with something, instead of checking if system is Linux and allow some options only on it.
ignore_mount_options should be option for everyone, return code should be the same for everyone...
It would be better to add a "weird_non_linux" option, so user could set it if his system is not a linux one, and if his system differ that much that we cannot use _netdev or getting a viable return result from mount -a on it.

I think at least, the nofail should be better explain in the news, else many users will think like me that it could be use on any mount instead of network ones only.
Comment 4 William Hubbs gentoo-dev 2016-04-15 16:04:22 UTC
(In reply to nobody from comment #3)
> Thanks, i'll pickup the ignore_mount_error option.

The reason I do not recommend this is it will ignore syntax errors in fstab as well. The safer choice is to mark non-critical filesystems  as noauto in fstab.

> But trying to figure how "nofail" works, it raise other questions:
> 
> 1/ the news didn't speak about nofail be a network only option, news says
> localmount and netmount change to fail now if fs cannot be mount but news
> then says "nofail" will allow the mount to fail. But the news didn't says
> it's only for network, nor it says it's only for some specifics conditions.

The nofail option is a mount/fstab option; it isn't supported directly by OpenRC. Please see the fstab and mount man pages for more information about it.

> 2/ looking at netmount, i see no "nofail" check in it. So i don't see any
> "nofail" support, i don't see any also in localmount, but it's ok as you
> said it's a netmount option only. I suppose you handle it elsewhere.

As I said above, mount itself handles this, it isn't an OpenRC specific feature.

> 3/ netmount have a bug
> - line 38 : mount -at $fs
> - and on next line, it check if system is linux, and on linux only it try to
> "mount -a -O _netdev"
> That's not right, here's why
> some_server:/goodmount /mnt/good nfs4 rw,_netdev
> some_server:/badmount /mnt/will_fail nfs4 rw
>
> line38: rc=32 : /badmount is bad and cannot be mount, but /goodmount succeed
> line41: mount -O _netdev will only try to mount /goodmount only, as only
> that fs have the _netdev option set, and it is already mount, no other fs
> will be check.
> so at line42: $rc=0
> and while line38 return error 32, line42 now return 0 and openrc will tell
> user everything is ok.
> line42 should be some kind of  if ["$rc" -eq 0]; then $rc=$?

I want to address a couple of things here. First, yes, this is a good catch and I'll fix it, in 0.21, and maybe 0.20.6.

Second, the use of _netdev was confusing for me for a while too, but your example above is actually incorrect. You should remove the _netdev from the first line. The reason for this is that nfs is always a network file system. The _netdev mount option is only used for situations where it is not possible to tell from the file system type that you are working with a network file system. The example I can think of is ISCSI.

> 4/ it seems strange (for me) that openrc, return 0 unconditionally for non
> linux system.
> Do you know any non linux system where mount isn't reliably returning 0 on
> success and non 0 on errors?

No, and that is why I tried to preserve the current behavior for them.

> I don't think it's nice that linux system have difference like that if
> there's no real reason to have one, i would prefer openrc running with
> exceptions for the ones that aren't linux and have a problem with something,
> instead of checking if system is Linux and allow some options only on it.
> ignore_mount_options should be option for everyone, return code should be
> the same for everyone...
> It would be better to add a "weird_non_linux" option, so user could set it
> if his system is not a linux one, and if his system differ that much that we
> cannot use _netdev or getting a viable return result from mount -a on it.
> 
> I think at least, the nofail should be better explain in the news, else many
> users will think like me that it could be use on any mount instead of
> network ones only.

It isn't for network mounts only. You can use it on any mount. What it does is ignore the mount if the device the filesystem is on doesn't exist. Another good application of this is external hard drives.

It could be argued in your ntfs example that since the windows computer is hibernated the device where the file system is located shouldn't exist.
Comment 5 William Hubbs gentoo-dev 2016-04-15 16:43:14 UTC
https://github.com/openrc/openrc/1c3c2cf

This fixes netmount so that it fails on Linux if the first mount fails
rather than moving ahead and trying the mount -a -O _netdev.
Comment 6 William Hubbs gentoo-dev 2016-04-15 18:42:32 UTC
There was a typo on the URL in the previous comment:

https://github.com/openrc/openrc/commit/1c3c2cf
Comment 7 nobody 2016-04-15 23:11:32 UTC
Thanks for the explains.

Alas, i'm a bit disappointed by the option and just prefer keep going with the ignore_mount_error.

And you should think of turning that switch on per default and user can disable it to let his openrc goes into a "i'm a boot bugger" mode.

ignore_mount_error = true
- if user make a typo in fstab, his system will still boot properly, but of course because of typo, the mount point will not be mount.
Sure if the typo is on a fs that is critical to boot, it will fail to boot, but not because openrc has stop him, because that's a nasty typo on a critcal fs.

ignore_mount_error = false
- if user make a typo in fstab, openrc will not boot properly and stop because of a typo, mount point in trouble will of course not be mount but worst legit mount point will also not (as soon as localmount is at fault, all deps are waiting for it to succeed: it mean it also prevent many services, just <grep "need localmount" /etc/init.d/*> and you'll see the huge impact.)

i don't think it's a good idea to "trash" (until my english gets better to find a better word) anyone boot because openrc try to handle a typo in fstab.
it's better to let the error appears because of the typo, but no let openrc stop its work and causing such trouble just for a typo.

as you see like in my case, there will be many users that will get plague by that new behaviour of openrc, it should not stop booting for no real reason.

I'm sorry but if you keep answering anyone that this should be "fixed" by adding noauto in fstab, you'll sure will not make friends.

Of course as bugzilla is not a forum, i will stop speaking about it here, just please submit that question to QA team, as i don't think quality is limited to code but also include user experience.
Because from user experience pov, your default setup make openrc 0.20 worst than 0.16 (my previous version).
The second question to ask them is : as you have no real example of non linux system that act different than linux one, why such difference in handling them in openrc exist?
Comment 8 William Hubbs gentoo-dev 2016-04-17 17:52:50 UTC
In the future, i want to remove the ignore_mount_errors option, because
I think it is better to not boot into multiuser mode when a file system
can't be mounted that a service needs than to continue booting and
hope that things work.

I understand your concern, but I feel that it is more appropriate to
make the nofail option take this into account.

I'm sending this to the util-linux maintainers to have them take a look
at changing the behaviour of the nofail option.

@vapier:
See comment #0.
Is this another situation where nofail could be silent
about a file system similar to when the device or media does not exist?
Comment 9 SpanKY gentoo-dev 2016-04-18 15:11:11 UTC
(In reply to William Hubbs from comment #8)

based on the last upstream thread wrt nofail, i think the answer will be "no".  they wanted to keep it as the docs implied -- missing devices only.
Comment 10 William Hubbs gentoo-dev 2016-04-18 17:54:52 UTC
They added missing media in 2.28, so I hope they will be able to add
this case as well, I guess we'll see.
Comment 11 SpanKY gentoo-dev 2016-04-18 18:32:09 UTC
(In reply to William Hubbs from comment #10)

yes, they merged my patch for missing media, but as a subset of "missing media is like a missing disk".  the thread on the topic (referenced in the other bug) talked about a bunch of different nuances and they explicitly declined most of them.
Comment 12 William Hubbs gentoo-dev 2016-04-18 22:43:18 UTC
If they decline this, is the best answer to use the noauto option in
fstab?
Comment 13 SpanKY gentoo-dev 2016-04-19 06:02:24 UTC
(In reply to William Hubbs from comment #12)

probably, and most likely fits with the user's expected usage too.  i wonder if ntfs-3g will be more forgiving if you try using the ro mount option w/hibernate state.
Comment 14 nobody 2016-04-19 13:14:02 UTC
(In reply to SpanKY from comment #13)
> (In reply to William Hubbs from comment #12)
> 
> probably, and most likely fits with the user's expected usage too.  i wonder
> if ntfs-3g will be more forgiving if you try using the ro mount option
> w/hibernate state.


Thank you guys,
This is/was a great suggest!
>mount /mnt/windows
>Windows is hibernated, refused to mount.
>Failed to mount '/dev/sda4': Opération non permise
>The NTFS partition is in an unsafe state. Please resume and shutdown
>Windows fully (no hibernation or fast restarting), or mount the volume
>read-only with the 'ro' mount option.
># mount /mnt/windows -t ntfs-3g -o ro
>echo $?
>0

Because using it with noauto is really "dirty", while i could live with an automount ro, and remount rw if need.
Comment 15 nobody 2016-04-19 13:17:28 UTC
As i just see williamh open issue 316 about, it might help to know the return code
mount /mnt/windows
Windows is hibernated, refused to mount.
Failed to mount '/dev/sda4': Opération non permise
The NTFS partition is in an unsafe state. Please resume and shutdown
Windows fully (no hibernation or fast restarting), or mount the volume
read-only with the 'ro' mount option.
echo $?
14
Comment 16 nobody 2016-04-19 13:23:32 UTC
Created attachment 431230 [details]
as suggest per karelzak in openrc bug tracker

i only change -t ntfs with -t ntfs-3g to not use the kernel implementation but ntfs-3g, as it's the one i'm using.