Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 418463 - linuxrc in genkernel's initramfs does not properly deal with bind mounts
Summary: linuxrc in genkernel's initramfs does not properly deal with bind mounts
Status: RESOLVED NEEDINFO
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: genkernel (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Genkernel Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-01 00:42 UTC by Andreas Plesch
Modified: 2017-09-08 14:12 UTC (History)
2 users (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 Andreas Plesch 2012-06-01 00:42:46 UTC
I want to start using an initrd because of udev as recommended. 
On my system fstab I have bind mounts into other filesystems for efficient use of a ssd, for example:

/dev/sda1               /disk/fels/d3   ext4            noatime         0 0
/disk/fels/d3/usr/lib64 /usr/lib64      none bind

where /dev/sda is the ssd.

Following the gentoo handbook I used genkernel to build and install an initrd. After a while I found that it has the option of a /etc/initramfs.mounts which lists additional early mounts. I have  two lines in this file:

/disk/fels/d3
/usr/lib64

The initrd successfully mounts the first mountpoint under /newroot/disk/fels/d3. However, mounting under the second mountpoint fails because the mount command in the linuxrc script looks for /disk/fels/d3/usr/lib64 for the bind mount. Rather it should use /newroot/disk/fels/d3/usr/lib64 for the bind mount.

Since the /etc/initramfs.mounts file is explicitly there for more complex mounting situation and bind mounts, it would make sense to support the above situation.

Reproducible: Always

Steps to Reproduce:
1.have a system with bind mounts at /usr/lib
2.use genkernel to generate an initrd
3.edit /etc/initramfs.mounts properly and boot
Actual Results:  
bind mounts are not mounted early (at initrd)

Expected Results:  
bind mounts are mounted early (at initrd) to be available for udev

Portage 2.1.10.49 (default/linux/amd64/10.0/desktop, gcc-4.5.3, glibc-2.14.1-r3, 3.2.12-gentoo x86_64)
=================================================================
System uname: Linux-3.2.12-gentoo-x86_64-AMD_Opteron-tm-_Processor_256-with-gentoo-2.1
Timestamp of tree: Wed, 30 May 2012 14:05:01 +0000
app-shells/bash:          4.2_p20
dev-java/java-config:     2.1.11-r3
dev-lang/python:          2.7.3-r1, 3.2.3
dev-util/cmake:           2.8.7-r5
dev-util/pkgconfig:       0.26
sys-apps/baselayout:      2.1-r1
sys-apps/openrc:          0.9.8.4
sys-apps/sandbox:         2.5
sys-devel/autoconf:       2.13, 2.68
sys-devel/automake:       1.9.6-r3, 1.10.3, 1.11.1
sys-devel/binutils:       2.21.1-r1
sys-devel/gcc:            4.5.3-r2
sys-devel/gcc-config:     1.5-r2
sys-devel/libtool:        2.4-r1
sys-devel/make:           3.82-r1
sys-kernel/linux-headers: 3.1 (virtual/os-headers)
sys-libs/glibc:           2.14.1-r3
Repositories: gentoo enlightenment science sage-on-gentoo x-portage
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA dlj-1.1 skype-eula PUEL @EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=opteron -O2 -pipe -msse3"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-march=opteron -O2 -pipe -msse3"
DISTDIR="/usr/portage/distfiles"
FEATURES="assume-digests binpkg-logs distlocks ebuild-locks fail-clean fixlafiles news parallel-fetch protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"
FFLAGS=""
GENTOO_MIRRORS="http://mirrors.med.harvard.edu/gentoo ftp://mirror.datapipe.net/gentoo http://gentoo.mirrors.tds.net/gentoo http://gentoo.cites.uiuc.edu/pub/gentoo/"
LANG="en_US.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j3"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/var/lib/layman/enlightenment /var/lib/layman/science /var/lib/layman/sage-on-gentoo /usr/local/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="X a52 aac acl acpi alsa amd64 arts berkdb bluetooth branding bzip2 cairo cdda cdr cli consolekit cpudetection cracklib crypt cups cxx dbus dri dts dv dvd dvdr dvdread emacs emboss encode exif fam firefox flac flash font-server fortran gd gdbm gif gpm gtk iconv ieee1394 imap ipv6 jpeg kde lcms ldap libnotify live mad mjpeg mmx mng modules mp3 mp4 mpeg mudflap multilib ncurses nls nptl nptlonly odbc ogg opengl openmp pam pango pcre pdf plotutils png policykit postgres ppds pppd python qt qt3support qt4 readline samba sdl semantic-desktop session smp spell sse sse2 ssl startup-notification svg tcpd threads tiff truetype udev udisks unicode upower usb v4l v4l2 vorbis wmf wxwidgets x264 xcb xinerama xml xorg xulrunner xv xvid 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" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" 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 ubx" INPUT_DEVICES="mouse keyboard evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" PHP_TARGETS="php5-3" PYTHON_TARGETS="python3_2 python2_7" RUBY_TARGETS="ruby18 ruby19" USERLAND="GNU" VIDEO_CARDS="nv nvidia vesa fbdev" 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, INSTALL_MASK, LC_ALL, LINGUAS, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON
Comment 1 Andreas Plesch 2012-06-01 18:41:40 UTC
Dracut has a similar problem with bind mounts:

http://forums.gentoo.org/viewtopic-t-918146-start-0-postdays-0-postorder-
asc-highlight-.html

According to the post, it can be worked around because dracut uses a "full" fstab style file for the early mounts (/etc/fstab.sys). One can add the /newroot (or /sysroot in dracut) there manually.

Perhaps this approach could be adopted for genkernel as well ?
Comment 2 Sebastian Pipping gentoo-dev 2012-06-02 21:16:38 UTC
I have pushed a fix [1] to branch "bug-418463".  Please review and test the change.  For testing, this sequence of commands may be helpful:

  $ git clone git://git.overlays.gentoo.org/proj/genkernel.git
  $ cd genkernel
  $ git checkout -t origin/bug-418463
  $ sudo GK_SHARE="$PWD" ./genkernel initramfs


[1] http://git.overlays.gentoo.org/gitweb/?p=proj/genkernel.git;a=commitdiff;h=aed52e83827cff73e8f7ba5773ea8e0cd7c3c25b
Comment 3 Andreas Plesch 2012-06-04 18:06:48 UTC
Thanks for the quick response.

I tested the proposed patch and it works as expected on my system, eg. the bind mount are mounted now early and udev can use them.

I did notice that the mount table as produced with the mount command now lists the mount points with the bind mounts twice:

# mount

...
/dev/sda1 on /disk/fels/d3 type ext4 (rw,noatime,commit=0)
/dev/sda1 on /usr/x86_64-pc-linux-gnu type ext4 (ro,noatime,user_xattr,barrier=1)
/dev/sda1 on /usr/lib64 type ext4 (ro,noatime,user_xattr,barrier=1)
/dev/sda1 on /usr/lib32 type ext4 (ro,noatime,user_xattr,barrier=1)
/dev/sda1 on /usr/libexec type ext4 (ro,noatime,user_xattr,barrier=1)
/dev/sda1 on /usr/include type ext4 (ro,noatime,user_xattr,barrier=1)
...
/disk/fels/d3/usr/x86_64-pc-linux-gnu on /usr/x86_64-pc-linux-gnu type none (rw,bind,commit=0)
/disk/fels/d3/usr/lib64 on /usr/lib64 type none (rw,bind,commit=0)
/disk/fels/d3/usr/lib32 on /usr/lib32 type none (rw,bind,commit=0)
/disk/fels/d3/usr/libexec on /usr/libexec type none (rw,bind,commit=0)
/disk/fels/d3/usr/include on /usr/include type none (rw,bind,commit=0)

But this does not seem to have a negative effect sofar. It just produces df output which lists the ssd as mounted multiple times. As this doubled listing is not occuring without the initrd, it probably is related to the remounting at the end of the initrd, and may or may not be genkernel related. Perhaps it is normal.
Comment 4 Sebastian Pipping gentoo-dev 2012-06-04 19:42:23 UTC
(In reply to comment #3)
> Thanks for the quick response.
> 
> I tested the proposed patch and it works as expected on my system, eg. the
> bind mount are mounted now early and udev can use them.

Nice, thank you.


> I did notice that the mount table as produced with the mount command now
> lists the mount points with the bind mounts twice:

Interesting.  I assume that's another bug.  I'll need your help to track it down.  If you have will and time for that, please open a new dedicated bug for that.
Comment 5 Sebastian Pipping gentoo-dev 2012-06-04 20:02:53 UTC
+*genkernel-3.4.34 (04 Jun 2012)
+
+  04 Jun 2012; Sebastian Pipping <sping@gentoo.org> +genkernel-3.4.34.ebuild:
+  Bump to 3.4.34
+
Comment 6 Andreas Plesch 2012-06-05 14:14:44 UTC
Ok, I filed a new bug:

https://bugs.gentoo.org/show_bug.cgi?id=419773
Comment 7 Andreas Plesch 2012-06-06 19:07:31 UTC
Hm, after rebooting several times with the new initrd, now the bind mounts stay read-only consistently when the main system starts up:

# mount

...
/dev/sda1 on /usr/lib64 type ext4 (ro,noatime,user_xattr,barrier=1)
/dev/sda1 on /usr/lib32 type ext4 (ro,noatime,user_xattr,barrier=1)
/dev/sda1 on /usr/libexec type ext4 (ro,noatime,user_xattr,barrier=1)
/dev/sda1 on /usr/include type ext4 (ro,noatime,user_xattr,barrier=1)
...
/disk/fels/d3/usr/x86_64-pc-linux-gnu on /usr/x86_64-pc-linux-gnu type none (ro,bind)
/disk/fels/d3/usr/lib64 on /usr/lib64 type none (ro,bind)
/disk/fels/d3/usr/lib32 on /usr/lib32 type none (ro,bind)
/disk/fels/d3/usr/libexec on /usr/libexec type none (ro,bind)
/disk/fels/d3/usr/include on /usr/include type none (ro,bind)

This was not the case initially (see above) but I do not know what could have changed. Unfortunately, this way the system does not work very well, eg. cannot be updated.
So perhaps the status of this bug needs to be updated ?
Comment 8 Sebastian Pipping gentoo-dev 2012-06-10 17:26:22 UTC
(In reply to comment #7)
> This was not the case initially (see above) but I do not know what could
> have changed.

Please check your disk and file system for errors.  It was the disk last time an ext4 went read-only on me, just saying.


> Unfortunately, this way the system does not work very well,
> eg. cannot be updated.
> So perhaps the status of this bug needs to be updated ?

Re-opening.

Especially that "(ro,bind)" is puzzling me.  Any help is welcome.
Comment 9 Andreas Plesch 2012-06-15 17:41:52 UTC
I finally checked the ext4 filesystem in question for errors. fsck reported some dtime=0 (or similar) errors but after they were fixed the bind mounts are still read-only. 

I can easily remount them read-write without problems, so I do not think it is the filesystem. In fact that is what I put into "local" init section, eg. in /etc/local.d/remount_earlymounts.start (on gentoo), and it works well.
Comment 10 Andreas Plesch 2012-06-15 18:18:44 UTC
I went into the debug shell of the initrd to see what happens if I manually recreate the mounting there. After creating the mount points I did

$ mount /dev/sda1 /mnt/disk1
$ mount -t none -o bind /mnt/disk1/usr/lib64 /mnt/lib64

The bind mount is read-write at this point. So something must happen after that in the initrd, or early when the main system comes up. fsck reports the ext4 file system on /dev/sda1 as clean.
Comment 11 Richard Yao gentoo-dev 2012-07-21 17:30:17 UTC
(In reply to comment #8)
> (In reply to comment #7)
> > This was not the case initially (see above) but I do not know what could
> > have changed.
> 
> Please check your disk and file system for errors.  It was the disk last
> time an ext4 went read-only on me, just saying.
> 
> 
> > Unfortunately, this way the system does not work very well,
> > eg. cannot be updated.
> > So perhaps the status of this bug needs to be updated ?
> 
> Re-opening.
> 
> Especially that "(ro,bind)" is puzzling me.  Any help is welcome.

The first mount is mounted ro. The bind mount likely duplicates that property. Modifying the system fstab to specify rw on the bind mount should solve that.

Andreas, would you confirm that doing that works? If it does, this could be considered a documentation issue.