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

Bug 454746

Summary: sys-fs/lvm2-2.02.97-r1, sys-fs/udev-197-r4: /dev/mapper entries absent for dm-crypt partitions mounted in initramfs
Product: Gentoo Linux Reporter: Roman Žilka <roman.zilka>
Component: [OLD] Core systemAssignee: Robin Johnson <robbat2>
Severity: minor CC: agk, alexander, cardoe, proxy-maint
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Package list:
Runtime testing required: ---

Description Roman Žilka 2013-01-30 22:29:07 UTC
This topic has been here a few times already, but never concluded with a solution.

I use the device mapper to mount encrypted partitions: / and /tmp, in my case. They are mounted in initramfs and are within it represented by the obligatory /dev/mapper/* entries. When initramfs finishes and Gentoo boots up, the /dev/mapper/* entries are not present, although the system runs and uses the filesystems.

# mount|grep mapper
/dev/mapper/root on / type ext4 (rw,noatime,nodiratime,data=ordered)
/dev/mapper/tmp on /tmp type ext4 (rw,data=ordered)
# ls /dev/mapper

As a result, the fsck initscript fails to check these for errors. Also, the fact of the root device not existing confuses e4defrag (fails to run when called on '/' or '/dev/dm-0') and I can imagine this is not the only such application.

I have to call 'dmsetup mknodes' manually to have the /dev/mapper/* entries re-created. But I think either udev or /etc/init.d/device-mapper should re-create them.

FWIW, I do not use LUKS, RAID or LVM. These are plain cryptsetup-based filesystems. From what I see on the net, however, the same problem applies for more complex setups as well.

Reproducible: Always
Comment 1 Roman Žilka 2013-01-30 22:32:33 UTC
# emerge --info lvm2 udev
Portage (hardened/linux/amd64, gcc-4.6.3, glibc-2.15-r3, 3.7.0 x86_64)
                        System Settings
System uname: Linux-3.7.0-x86_64-Intel-R-_Core-TM-_i5-2520M_CPU_@_2.50GHz-with-gentoo-2.1
Timestamp of tree: Wed, 30 Jan 2013 19:15:01 +0000
ld GNU ld (GNU Binutils) 2.22
app-shells/bash:          4.2_p37
dev-lang/python:          2.7.3-r2, 3.2.3
dev-util/cmake:           2.8.9
dev-util/pkgconfig:       0.27.1
sys-apps/baselayout:      2.1-r1
sys-apps/openrc:          0.11.8
sys-apps/sandbox:         2.5
sys-devel/autoconf:       2.13, 2.69
sys-devel/automake:       1.9.6-r3, 1.11.6
sys-devel/binutils:       2.22-r1
sys-devel/gcc:            4.6.3
sys-devel/gcc-config:     1.7.3
sys-devel/libtool:        2.4-r1
sys-devel/make:           3.82-r4
sys-kernel/linux-headers: 3.6 (virtual/os-headers)
sys-libs/glibc:           2.15-r3
Repositories: gentoo
CFLAGS="-O2 -pipe -fomit-frame-pointer -march=core2 -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -mavx -maes -mpclmul -mpopcnt -mcx16"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -pipe -fomit-frame-pointer -march=core2 -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -mavx -maes -mpclmul -mpopcnt -mcx16"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs candy collision-protect config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news noinfo parallel-fetch protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch usersync"
FFLAGS="-O2 -pipe"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,--as-needed"
PORTAGE_RSYNC_EXTRA_OPTS="--compress --compress-level=9"
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"
USE="X a52 aac acpi aes-ni alsa amd64 avx bash-completion berkdb bluetooth bzip2 cddb cjk cli cracklib crypt cxx dri encode ffmpeg flac fontconfig ftp gdbm geoip gif gnutls gps gzip hardened hddtemp iconv icu idn imap javascript jpeg jpeg2k justify libass lm_sensors lzma lzo matroska mbox mime mms mmx mmxext modules mp3 mp4 mpeg mplayer mudflap multilib musicbrainz ncurses nls nocd nptl ogg opengl pam pax_kernel pcre pda pdf png postscript quicktime raw readline recode session smp sockets sound spell sse sse2 sse3 sse4 sse4_1 sse4_2 ssl ssse3 svg syslog threads truetype udev unicode urandom usb v4l vdpau videos vim-syntax vorbis wifi x264 xcomposite xosd xscreensaver 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="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" 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="evdev keyboard mouse synaptics" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="en cs ja" PHP_TARGETS="php5-3" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_2" RUBY_TARGETS="ruby18 ruby19" USERLAND="GNU" VIDEO_CARDS="intel vesa" 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"

                        Package Settings

sys-fs/lvm2-2.02.97-r1 was built with the following:
USE="lvm1 readline thin udev (-clvm) (-cman) (-selinux) -static -static-libs"

sys-fs/udev-197-r4 was built with the following:
USE="kmod (multilib) openrc -acl -doc -gudev -hwdb -introspection -keymap (-selinux) -static-libs"
Comment 2 Alexander Tsoy 2013-01-31 03:10:27 UTC
How do you build an initramfs (genkernel, dracut, etc)?
I had similar issue after upgrade of udev: boot with udev-171, upgrade udev to 197, restart udev --> all symlinks from /dev/mapper dissapear (I can't remember what happened with device nodes /dev/dm-*).
Comment 3 Roman Žilka 2013-01-31 06:40:14 UTC
I make the initramfs myself: I populate the virtual root directory structure and call cpio|lzop on it. I have a static /dev there with an empty "/dev/mapper" directory which gets filled by cryptsetup once it decrypts the filesystem headers. I also have an empty mountpoint ready for the real root. Once that's mounted, switch_root is called on it and /sbin/init from within it takes over.

No udev from the past 2 years or so worked for me. I mean I didn't check often, but we can assume that with a good level of certainty. I update the executables in the initramfs that run the place (sort of) regularly, FWIW.

I do get the /dev/dm-* nodes after bootup. They're usless, however: even if I re-create these (as symlinks or actual block devices) in the initramfs and call mount on these, what's actually being mounted is /dev/mapper/* anyway. :)
Comment 4 Alexander Tsoy 2013-01-31 13:17:32 UTC
(In reply to comment #3)
> I make the initramfs myself: I populate the virtual root directory structure
> and call cpio|lzop on it. I have a static /dev there with an empty
> "/dev/mapper" directory which gets filled by cryptsetup once it decrypts the
> filesystem headers.

So you have CONFIG_DEVTMPFS_MOUNT disabled in kernel config, and your initramfs doesn't mount /dev as devtmpfs?
Comment 5 Roman Žilka 2013-01-31 13:42:54 UTC
(In reply to comment #4)
> So you have CONFIG_DEVTMPFS_MOUNT disabled in kernel config, and your
> initramfs doesn't mount /dev as devtmpfs?

That's right.

Do you think I could make progress by changing any of that? I'm completely new to the devtmpfs thing. I only just enabled it - because of udev-197.
Comment 6 Alexander Tsoy 2013-01-31 14:36:22 UTC
(In reply to comment #5)
> Do you think I could make progress by changing any of that? I'm completely
> new to the devtmpfs thing. I only just enabled it - because of udev-197.

Yes. /dev should be mounted as devtmpfs by kernel or by initramfs. switch_root moves already mounted /proc, /dev and /sys to newroot. If /dev is not mounted as devtmpfs, then udev-mount initscript do this and all changes made at the initramfs stage will be lost.
Comment 7 Alexander Tsoy 2013-01-31 14:41:01 UTC
Of course you should mount /dev before running cryptsetup. :)
Comment 8 Roman Žilka 2013-01-31 20:08:47 UTC
Thanks, that solved the issue in a cleaner manner! I have the entries now even after booting finishes.

I'm giving this bug low importance, but leaving it open. I still think it would be square of one of the initscripts (udev or device-mapper) to handle this. I consider this solution more of a work-around than a real, clean solution. Static /dev in the initramfs is nothing exotic, I think. Else, the udev or lvm2 ebuilds should warn upon install that you must have devtmpfs in the kernel not just because of udev-197, but also so that you can avoid this buggy situation.

Furthermore, I might be mounting devtmpfs (in the initramfs) with '-o something' which is okay for today's udev, but will not be okay for next year's udev. Of course, next year noone will remember that they should warn the users that they should replace '-o something' in their initramfs's with '-o something_else'. Instead, udev will suddenly and mysteriously stop working for certain people, making their systems unbootable.
Comment 9 Samuli Suominen (RETIRED) gentoo-dev 2013-09-12 23:15:00 UTC
Closing since it's all caused by insufficient custom initramfs