Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 337579 - checkroot may leave the root filesystem mounted as R/O in some circumstances
Summary: checkroot may leave the root filesystem mounted as R/O in some circumstances
Status: RESOLVED NEEDINFO
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-16 01:05 UTC by Alessandro Salvatori
Modified: 2011-03-09 07:54 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 Alessandro Salvatori 2010-09-16 01:05:34 UTC
in my case with nilfs2, and either a passno of 0 or 1, and a bogus fsck.nilfs2 that always succeeds, the root filesystem is left mounted R/O after checkroot...

Reproducible: Always

Steps to Reproduce:
1. create a nilfs2 filesystem
2. edit your /etc/fstab to use the nilfs2 filesystem as /, with either passno 1 or 0
2b. create a symlink from /sbin/fsck.nilfs2 to /bin/true (given there's inherently no need for an fsck for nilfs2, and hence that toold doesn't exist)
3. reboot... and see what happens...
Comment 1 Alessandro Salvatori 2010-09-16 01:06:41 UTC
emerge --info
Portage 2.1.9.5 (default/linux/amd64/10.0, gcc-4.4.3, glibc-2.11.2-r0, 2.6.34.1-dvaos x86_64)
=================================================================
System uname: Linux-2.6.34.1-dvaos-x86_64-Intel-R-_Core-TM-_i5_CPU_M_520_@_2.40GHz-with-gentoo-1.12.13
Timestamp of tree: Tue, 14 Sep 2010 01:45:01 +0000
app-shells/bash:     4.0_p37
dev-lang/python:     2.6.5-r3, 3.1.2-r4
sys-apps/baselayout: 1.12.13
sys-apps/sandbox:    1.6-r2
sys-devel/autoconf:  2.65
sys-devel/automake:  1.11.1
sys-devel/binutils:  2.20.1-r1
sys-devel/gcc:       4.4.1, 4.4.2, 4.4.3-r2, 4.5.1
sys-devel/gcc-config: 1.4.1
sys-devel/libtool:   2.2.6b
sys-devel/make:      3.81-r2
virtual/os-headers:  2.6.30-r1 (sys-kernel/linux-headers)
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gconf /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="assume-digests buildpkg distlocks fixlafiles fixpackages news parallel-fetch protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="acl amd64 berkdb bzip2 cli cracklib crypt cscope cups cxx dri gdbm gpm iconv ipv6 lto mmx modules mudflap multilib multislot multitarget multiuser ncurses nls nptl nptlonly openmp pam pcre perl pppd python readline reflection session sse sse2 ssl sysfs tcpd unicode xorg zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="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" ELIBC="glibc" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="fbdev glint intel mach64 mga neomagic nouveau nv r128 radeon savage sis tdfx trident vesa via vmware voodoo" 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:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, LANG, LC_ALL, LINGUAS, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, PORTDIR_OVERLAY
Comment 2 Alessandro Salvatori 2010-09-16 01:07:55 UTC
please also refer to 337577 and 321423.
Comment 3 DEMAINE Benoît-Pierre, aka DoubleHP 2010-09-16 01:20:09 UTC
This bug fucusses on this aspect: when remounting / RW fails, this should be stated clearly; leaving / RO, and showing green stars at boot is a lie. When / is RO, most services can't start. I d suggest that boot process should be stopped. But at least, fact remount RW failed should be CLEARLY explicitely stated , with a red star !!!

unless fstab clearly states that / can be left RO ... of course. Still, in this particular case, a small warning could be pleasant.
Comment 4 SpanKY gentoo-dev 2010-09-18 09:49:12 UTC
that isnt true at all.  i boot a r/o root on my server by design and it works just fine.  that's because i have a r/w /var path for the services to use.

what exactly does your boot output say ?  faking out the result of fsck is irrelevant to the remount check.  might want to add some echos to the checkroot script to see what code paths are being executed.

although, declaring anything other than 0 as the fstab's passno is an error on your part when doing fsck on the fs makes no sense.
Comment 5 DEMAINE Benoît-Pierre, aka DoubleHP 2010-09-19 22:59:51 UTC
He had to put 0, because with 1, the init script does not find fsck.linfs2 ... so, the checkall/checkroot script fails ...

The bug is that, "mount -o rw" should not depend on the fact fsck is run; i can understand that remount is not done when fck fails; not when fsck is not found, or, not searched at all (due to passno 0).

And, whatever the reason, when / is not remounted RW "dispite fstab asking for it", the initscript should state it, and give the reason.

Allessandro, please, remove your fake fsck, and do what they ask.
Comment 6 SpanKY gentoo-dev 2010-09-19 23:47:07 UTC
are you reading the right file ?  nowhere in checkroot is the logic to remount the root dependent upon fsck.  they are completely different blocks.

...
    # Should we mount root rw ?  the touch check is to see if the / is
    # already mounted rw in which case there's nothing for us to do
    if mount -vf -o remount / 2> /dev/null | \
       awk '{ if ($6 ~ /rw/) exit 0; else exit 1; }' && \
       ! touch -c / >& /dev/null
    then
...

nothing fsck related there
Comment 7 Artur Apatryda 2011-03-09 07:54:31 UTC
The problem lies in mentioned lines in the checkroot script:

    # Should we mount root rw ?  the touch check is to see if the / is
    # already mounted rw in which case there's nothing for us to do
    if mount -vf -o remount / 2> /dev/null | \
       awk '{ if ($6 ~ /rw/) exit 0; else exit 1; }' && \
       ! touch -c / >& /dev/null
    then

to be precise in the 'mount -vf -o remount /' part.

Normaly 'mount -vf -o remount' should return something like:

/dev/sda3 on / type ext3 (rw,noatime)

but when using mount.nilfs2 the output (stdout) not only depends on circumstances, but also includes some additional lines.
When issued on a 'rw' mounted system it returns something like:

    mount.nilfs2: kill cleanerd (pid=3728) on /dev/sda2
    mount.nilfs2: cleanerd (pid=3728) stopped
    mount.nilfs2: started nilfs_cleanerd
    /dev/sda2 on / type nilfs2 (rw,noatime,gcpid=3734)

(and it is all in stdout - stderr has been passed to /dev/null)

As for 'ro' mounted systems the output is a single line:

    nilfs_cleanerd not started


My solution is to change the script like this:

    # Should we mount root rw ?  the touch check is to see if the / is
    # already mounted rw in which case there's nothing for us to do
    # if mount -vf -o remount / 2> /dev/null | \
    #    awk '{ if ($6 ~ /rw/) exit 0; else exit 1; }' && \
    if \
       ! touch -c / >& /dev/null
    then

I'm not sure if I could call it a good solution, but it seems like one, especially that '! touch -c / >& /dev/null' should be enough to check if the filesystem is mounted readonly.