e2fsck: /dev/hda2 is mounted.
After a recent upgrade of a Debian system, I discovered that systems weren't rebooting; they would always halt in the automatic fsck of other file systems.
Upon investigation, it turned out that fsck didn't understand the kernel "root=302" parameter and was trying to run e2fsck on the root file system. This produced an error, causing the boot process to drop into a recovery shell.
System is i386, current Debian sid (unstable). But I compiled util-linux from the git sources to eliminate Debianisms from the problem.
Running the v2.28-rc1 release (8c97556ecfc0af358d35dc7a842aaadde5eeafd3) I got some compile warnings (appended for reference), but a working execurable which could be run as follows:
LIBMOUNT_DEBUG=all LIBBLKID_DEBUG=all ./fsck -C -M -A -V
32305: libmount: INIT: library debug mask: 0xffff 32305: libmount: INIT: library version: 2.28. 32305: libmount: INIT: feature: btrfs 32305: libmount: INIT: feature: assert 32305: libmount: INIT: feature: debug Available "LIBMOUNT_DEBUG=<name>[,...]|<mask>" debug masks: all [0xffff] : info about all subsystems cache [0x0004] : paths and tags cache cxt [0x0200] : library context (handler) diff [0x0400] : mountinfo changes tracking fs [0x0040] : FS abstraction help [0x0001] : this help locks [0x0010] : mtab and utab locking loop [0x2000] : loop devices routines options [0x0008] : mount options parsing tab [0x0020] : fstab, mtab, mounninfo routines update [0x0080] : mtab, utab updates utils [0x0100] : misc library utils monitor [0x0800] : mount tables monitor btrfs [0x1000] : btrfs specific routines 32305: libmount: CACHE: [0x983a048]: alloc lt-fsck from util-linux 2.28-rc1 32305: libmount: TAB: [0x983a068]: alloc 32305: libmount: TAB: [0x983a068]: /etc/fstab: start parsing [entries=0, filter=not] 32305: libmount: TAB: [0x983a068]: add entry: /dev/hda1 none 32305: libmount: TAB: [0x983a068]: add entry: /dev/hda2 / 32305: libmount: TAB: [0x983a068]: add entry: proc /proc 32305: libmount: TAB: [0x983a068]: add entry: tmpfs /tmp 32305: libmount: TAB: [0x983a068]: add entry: /dev/fd0 /a 32305: libmount: TAB: [0x983a068]: add entry: /dev/hdc /cd 32305: libmount: TAB: [0x983a068]: add entry: /dev/hdd /dvd 32305: libmount: TAB: [0x983a068]: add entry: /dev/hda3 /home 32305: libmount: FS: [0x983a9c8]: free [refcount=0] 32305: libmount: TAB: [0x983a068]: /etc/fstab: stop parsing (8 entries) 32305: libmount: TAB: [0x983a068]: parsing done [filename=/etc/fstab, rc=0] 32305: libmount: CACHE: [0x983a048]: canonicalize path /dev/hda2 32305: libmount: CACHE: [0x983a048]: add entry [ 1] (path): /dev/hda2: /dev/hda2 32305: libmount: CACHE: [0x983a048]: canonicalize path /dev/hda3 32305: libmount: CACHE: [0x983a048]: add entry [ 2] (path): /dev/hda3: /dev/hda3
Checking all file systems.
32305: libmount: TAB: [0x983a068]: lookup TARGET: '/'
32305: libmount: TAB: [0x983a160]: alloc
32305: libmount: UTILS: mtab: /etc/mtab
32305: libmount: UTILS: /etc/mtab: irregular/non-writable
32305: libmount: TAB: [0x983a160]: mtab parse: #1 read mountinfo 32305: libmount: TAB: [0x983a160]: /proc/self/mountinfo: start parsing [entries=0, filter=not] 32305: libmount: TAB: [0x983a160]: add entry: /dev/root /
32305: libmount: CACHE: canonicalize path /proc/self/mountinfo
32305: libmount: TAB: TID for /proc/self/mountinfo is 32305
32305: libmount: TAB: [0x983a160]: root FS: 302
32305: libmount: CACHE: [0x983a048]: canonicalize path 302
32305: libmount: CACHE: [0x983a048]: add entry [ 3] (path): 302: 302
32305: libmount: TAB: [0x983a160]: canonical root FS: 302 32305: libmount: TAB: [0x983a160]: add entry: sysfs /sys 32305: libmount: TAB: [0x983a160]: add entry: tmpfs /run 32305: libmount: TAB: [0x983a160]: add entry: tmpfs /run/lock 32305: libmount: TAB: [0x983a160]: add entry: proc /proc 32305: libmount: TAB: [0x983a160]: add entry: devtmpfs /dev 32305: libmount: TAB: [0x983a160]: add entry: tmpfs /run/shm 32305: libmount: TAB: [0x983a160]: add entry: devpts /dev/pts 32305: libmount: TAB: [0x983a160]: add entry: tmpfs /tmp 32305: libmount: TAB: [0x983a160]: add entry: /dev/hda3 /home 32305: libmount: FS: [0x983ddc8]: free [refcount=0] 32305: libmount: TAB: [0x983a160]: /proc/self/mountinfo: stop parsing (10 entries) 32305: libmount: TAB: [0x983a160]: parsing done [filename=/proc/self/mountinfo, rc=0] 32305: libmount: TAB: [0x983a160]: mtab parse: #2 read utab 32305: libmount: TAB: [0x983a160]: lookup SOURCE: '/dev/hda2' 32305: libmount: TAB: [0x983a160]: lookup SRCPATH: '/dev/hda2' 32305: libmount: TAB: [0x983a160]: lookup canonical SRCPATH: '/dev/hda2'
/dev/hda2 is not mounted
[/sbin/fsck.ext4 (1) -- /] fsck.ext4 -C0 /dev/hda2
32318: libblkid: INIT: library debug mask: 0xffff
32318: libblkid: INIT: library version: 2.27.0 [02-Nov-2015]
Available "LIBBLKID_DEBUG=<name>[,...]|<mask>" debug masks:
all [0xffff] : info about all subsystems cache [0x0004] : blkid tags cache config [0x0008] : config file utils dev [0x0010] : device utils devname [0x0020] : /proc/partitions evaluation devno [0x0040] : convertions to device name evaluate [0x0080] : tags resolving help [0x0001] : this help lowprobe [0x0100] : superblock/raids/partitions probing probe [0x0200] : devices verification read [0x0400] : cache parsing save [0x0800] : cache writing tag [0x1000] : tags utils
32318: libblkid: CACHE: creating blkid cache (using default cache)
32318: libblkid: CONFIG: reading config file: /etc/blkid.conf.
32318: libblkid: CONFIG: /etc/blkid.conf: does not exist, using built-in default
32318: libblkid: TAG: looking for /dev/hda2 in cache
e2fsck 1.43-WIP (18-May-2015)/dev/hda2 is mounted.
e2fsck: Cannot continue, aborting.
I'm not quite sure where in the code this is *supposed* to be parsed so I haven't found the bug yet. It *used* to work, but I fear it's been months since my last reboot and I don't have a list of everything that changed.
Other problems encountered during compilation:
checking linux/gsmmux.h usability... no
checking linux/gsmmux.h presence... yes
configure: WARNING: linux/gsmmux.h: present but cannot be compiled
configure: WARNING: linux/gsmmux.h: check for missing prerequisite headers?
configure: WARNING: linux/gsmmux.h: see the Autoconf documentation
configure: WARNING: linux/gsmmux.h: section "Present But Cannot Be Compiled"
configure: WARNING: linux/gsmmux.h: proceeding with the compiler's result
configure: WARNING: ## ------------------------------ ##
configure: WARNING: ## Report this to [email protected] ##
configure: WARNING: ## ------------------------------ ##
checking for linux/gsmmux.h... no
The details from config.log look more like a problem with the headers rather than util-linux, but it says report it, so I am:
configure:18012: checking linux/gsmmux.h usability configure:18012: gcc -c -g -O2 conftest.c >&5 In file included from /usr/include/linux/gsmmux.h:4:0,
from conftest.c:79:
/usr/include/linux/if.h:211:19: error: field 'ifru_addr' has incomplete type
struct sockaddr ifru_addr;
^
/usr/include/linux/if.h:212:19: error: field 'ifru_dstaddr' has incomplete type
struct sockaddr ifru_dstaddr;
^
/usr/include/linux/if.h:213:19: error: field 'ifru_broadaddr' has incomplete type
struct sockaddr ifru_broadaddr;
^
/usr/include/linux/if.h:214:19: error: field 'ifru_netmask' has incomplete type
struct sockaddr ifru_netmask;
^
/usr/include/linux/if.h:215:20: error: field 'ifru_hwaddr' has incomplete type
struct sockaddr ifru_hwaddr;
^configure:18012: $? = 1
There were also two batches of complaints about mismatched types in printf:
CC libfdisk/src/libfdisk_la-alignment.lo
In file included from libfdisk/src/fdiskP.h:25:0,
from libfdisk/src/alignment.c:7:libfdisk/src/alignment.c: In function 'fdisk_align_lba':libfdisk/src/alignment.c:115:29: warning: format '%ju' expects argument of type 'uintmax_t', but argument 6 has type 'long unsigned int' [-Wformat=]
DBG(CXT, ul_debugobj(cxt, "LBA %ju -aligned-%s-> %ju [grain=%jus]",
^
./include/debug.h:63:4: note: in definition of macro '__UL_DBG'
x; \
^libfdisk/src/alignment.c:115:3: note: in expansion of macro 'DBG'
DBG(CXT, ul_debugobj(cxt, "LBA %ju -aligned-%s-> %ju [grain=%jus]", ^
CC sys-utils/lsns-lsns.o
In file included from sys-utils/lsns.c:45:0:sys-utils/lsns.c: In function 'add_namespace':sys-utils/lsns.c:346:26: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'ino_t {aka long long unsigned int}' [-Wformat=]
DBG(NS, ul_debugobj(ns, "new %s[%lu]", ns_names[type], ino));
^
./include/debug.h:63:4: note: in definition of macro '__UL_DBG'
x; \
^sys-utils/lsns.c:346:2: note: in expansion of macro 'DBG'
DBG(NS, ul_debugobj(ns, "new %s[%lu]", ns_names[type], ino));
^sys-utils/lsns.c: In function 'add_process_to_namespace':sys-utils/lsns.c:362:26: warning: format '%lu' expects argument of type 'long unsigned int', but argument 6 has type 'ino_t {aka long long unsigned int}' [-Wformat=]
DBG(NS, ul_debugobj(ns, "add process [%p] pid=%d to %s[%lu]", proc, proc->pid,
^
./include/debug.h:63:4: note: in definition of macro '__UL_DBG'
x; \
^sys-utils/lsns.c:362:2: note: in expansion of macro 'DBG'
DBG(NS, ul_debugobj(ns, "add process [%p] pid=%d to %s[%lu]", proc, proc->pid,
^sys-utils/lsns.c: In function 'add_scols_line':sys-utils/lsns.c:440:20: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'ino_t {aka long long unsigned int}' [-Wformat=]
xasprintf(&str, "%lu", ns->id);
^I dug back through the commit log, and discovered that reverting 7a4f98854283a5b98e76902b12685ad1999b2802
fixes the regression.
I assume reverting this isn't the preferred solution, but it at least narrows down the issue.
Karel Zak
maintainerQuoted 24 lines · George Spelvin
32305: libmount: TAB: [
0x983a160]:/proc/self/mountinfo: start parsing [entries=0, filter=not]
32305: libmount: TAB: [0x983a160]: add entry:/dev/root/
32305: libmount: CACHE: canonicalize path/proc/self/mountinfo
32305: libmount: TAB: TID for/proc/self/mountinfois 32305
32305: libmount: TAB: [0x983a160]: root FS: 302
32305: libmount: CACHE: [0x983a048]: canonicalize path 302
32305: libmount: CACHE: [0x983a048]: add entry [ 3] (path): 302: 30232305: libmount: TAB: [0x983a160]: canonical root FS: 302 32305: libmount: TAB: [0x983a160]: add entry: sysfs /sys 32305: libmount: TAB: [0x983a160]: add entry: tmpfs /run 32305: libmount: TAB: [0x983a160]: add entry: tmpfs /run/lock 32305: libmount: TAB: [0x983a160]: add entry: proc /proc 32305: libmount: TAB: [0x983a160]: add entry: devtmpfs /dev 32305: libmount: TAB: [0x983a160]: add entry: tmpfs /run/shm 32305: libmount: TAB: [0x983a160]: add entry: devpts /dev/pts 32305: libmount: TAB: [0x983a160]: add entry: tmpfs /tmp 32305: libmount: TAB: [0x983a160]: add entry: /dev/hda3 /home 32305: libmount: FS: [0x983ddc8]: free [refcount=0] 32305: libmount: TAB: [0x983a160]: /proc/self/mountinfo: stop parsing (10 entries) 32305: libmount: TAB: [0x983a160]: parsing done [filename=/proc/self/mountinfo, rc=0] 32305: libmount: TAB: [0x983a160]: mtab parse: #2 read utab 32305: libmount: TAB: [0x983a160]: lookup SOURCE: '/dev/hda2' 32305: libmount: TAB: [0x983a160]: lookup SRCPATH: '/dev/hda2' 32305: libmount: TAB: [0x983a160]: lookup canonical SRCPATH: '/dev/hda2'
Quoted 1 line
/dev/hda2is not mounted
Can you send me your /proc/self/mountinfo? (or at least root fs entry from the file)
Thanks,
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
Thanks for the help. I don't quite understand the structure of libmount well enough to know where a fix *should* go.
Quoted 2 lines
Can you send me your
/proc/self/mountinfo? (or at least root fs entry from the file)
12 0 3:2 / / rw,relatime - ext4 /dev/root rw,errors=remount-ro,data=ordered
13 12 0:12 / /sys rw,nosuid,nodev,noexec,relatime - sysfs sysfs rw
14 12 0:13 / /run rw,nosuid,noexec,relatime - tmpfs tmpfs rw,size=207448k,mode=755 15 14 0:14 / /run/lock rw,nosuid,nodev,noexec,relatime - tmpfs tmpfs rw,size=5120k 16 12 0:4 / /proc rw,nosuid,nodev,noexec,relatime - proc proc rw
17 12 0:6 / /dev rw,nosuid,relatime - devtmpfs devtmpfs rw,size=10240k,nr_inodes=221580,mode=755 18 14 0:15 / /run/shm rw,nosuid,nodev,noexec,relatime - tmpfs tmpfs rw,size=1391640k 19 17 0:11 / /dev/pts rw,nosuid,noexec,relatime - devpts devpts rw,gid=5,mode=620 20 12 0:16 / /tmp rw,noexec,relatime - tmpfs tmpfs rw,size=524288k
21 12 3:3 / /home rw,relatime - ext4 /dev/hda3 rw,data=ordered
And here's /etc/mtab -> /proc/mounts:
/dev/root / ext4 rw,relatime,errors=remount-ro,data=ordered 0 0
sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0
tmpfs /run tmpfs rw,nosuid,noexec,relatime,size=207448k,mode=755 0 0 tmpfs /run/lock tmpfs rw,nosuid,nodev,noexec,relatime,size=5120k 0 0
proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
devtmpfs /dev devtmpfs rw,nosuid,relatime,size=10240k,nr_inodes=221580,mode=755 0 0 tmpfs /run/shm tmpfs rw,nosuid,nodev,noexec,relatime,size=1391640k 0 0 devpts /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620 0 0 tmpfs /tmp tmpfs rw,noexec,relatime,size=524288k 0 0/dev/hda3 /home ext4 rw,relatime,data=ordered 0 0 16,0-1 All
Quoted 3 lines · George Spelvin
There were also two batches of complaints about mismatched types in printf:
[...]
These warnings are fixed already in e1a15f8f. They are indicating that you are using a 32bit system. Maybe that's important to reproduce the bug.
cu,
Rudi
Quoted 8 lines · George Spelvin
Thanks for the help. I don't quite understand the structure of libmount well enough to know where a fix *should* go.
Quoted 2 lines
Can you send me your
/proc/self/mountinfo? (or at least root fs entry from the file)12 0 3:2 / / rw,relatime - ext4
/dev/root
[...]
Maybe it's not related but I've noticed a similar issue where getmntent() was not able to parse long lines in /proc/mounts. It was with musl and I've asked there
http://permalink.gmane.org/gmane.linux.lib.musl.general/9548
I've got no reply, so maybe it was a stupid question and we are doing something wrong ;)
cu,
Rudi
Karel Zak
maintainerQuoted 10 lines · Ruediger Meier
Quoted 8 lines · George Spelvin
Thanks for the help. I don't quite understand the structure of libmount well enough to know where a fix *should* go.
Quoted 2 lines
Can you send me your
/proc/self/mountinfo? (or at least root fs entry from the file)12 0 3:2 / / rw,relatime - ext4
/dev/root
[...]
Quoted 7 lines
Maybe it's not related but I've noticed a similar issue where
getmntent()was not able to parse long lines in/proc/mounts. It was with musl and I've asked there
http://permalink.gmane.org/gmane.linux.lib.musl.general/9548I've got no reply, so maybe it was a stupid question and we are doing something wrong ;)
The problem in this case is /dev/root, libmount tries to convert it to the real device name by root= command line option, but the conversion is pretty poor and it does not support all relevant use-cases.
I'll try to improve it. It also seems that in many cases (except btrfs) we can follow maj:min from mountinfo entry rather than parse the complicated root= option.
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
Karel Zak
maintainerQuoted 4 lines · George Spelvin
Upon investigation, it turned out that fsck didn't understand the kernel "root=302" parameter and was trying to run e2fsck on the root file system. This produced an error, causing the boot process to drop into a recovery shell.
...
Quoted 3 lines
Running the v2.28-rc1 release (
8c97556ecfc0af358d35dc7a842aaadde5eeafd3) I got some compile warnings (appended for reference), but a working execurable which could be run as follows:
The problem should be fixed, git pull, make and re-test, please.
Thanks
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
Quoted 1 line
The problem should be fixed, git pull, make and re-test, please.
After a bit of screwing around with Debian dependencies (the fix ends up in the libmount package, not the util-linux package, and util-linux only depends on libmount >= 2.25), I can confirm that it works.
Thank you very much!
LIBMOUNT_DEBUG=all LIBBLKID_DEBUG=all fsck -C -M -A -V
3411: libmount: INIT: library debug mask: 0xffff 3411: libmount: INIT: library version: 2.28. 3411: libmount: INIT: feature: selinux 3411: libmount: INIT: feature: btrfs 3411: libmount: INIT: feature: force-mountinfo 3411: libmount: INIT: feature: assert 3411: libmount: INIT: feature: debug Available "LIBMOUNT_DEBUG=<name>[,...]|<mask>" debug masks: all [0xffff] : info about all subsystems cache [0x0004] : paths and tags cache cxt [0x0200] : library context (handler) diff [0x0400] : mountinfo changes tracking fs [0x0040] : FS abstraction help [0x0001] : this help locks [0x0010] : mtab and utab locking loop [0x2000] : loop devices routines options [0x0008] : mount options parsing tab [0x0020] : fstab, mtab, mounninfo routines update [0x0080] : mtab, utab updates utils [0x0100] : misc library utils monitor [0x0800] : mount tables monitor btrfs [0x1000] : btrfs specific routines 3411: libmount: CACHE: [0x8d84048]: alloc fsck from util-linux 2.28-rc1 3411: libmount: TAB: [0x8d84068]: alloc 3411: libmount: TAB: [0x8d84068]: /etc/fstab: start parsing [entries=0, filter=not] 3411: libmount: TAB: [0x8d84068]: add entry: /dev/hda1 none 3411: libmount: TAB: [0x8d84068]: add entry: /dev/hda2 / 3411: libmount: TAB: [0x8d84068]: add entry: proc /proc 3411: libmount: TAB: [0x8d84068]: add entry: tmpfs /tmp 3411: libmount: TAB: [0x8d84068]: add entry: /dev/fd0 /a 3411: libmount: TAB: [0x8d84068]: add entry: /dev/hdc /cd 3411: libmount: TAB: [0x8d84068]: add entry: /dev/hdd /dvd 3411: libmount: TAB: [0x8d84068]: add entry: /dev/hda3 /home 3411: libmount: FS: [0x8d849c8]: free [refcount=0] 3411: libmount: TAB: [0x8d84068]: /etc/fstab: stop parsing (8 entries) 3411: libmount: TAB: [0x8d84068]: parsing done [filename=/etc/fstab, rc=0] 3411: libmount: CACHE: [0x8d84048]: canonicalize path /dev/hda2 3411: libmount: CACHE: [0x8d84048]: add entry [ 1] (path): /dev/hda2: /dev/hda2 3411: libmount: CACHE: [0x8d84048]: canonicalize path /dev/hda3 3411: libmount: CACHE: [0x8d84048]: add entry [ 2] (path): /dev/hda3: /dev/hda3 Checking all file systems. 3411: libmount: TAB: [0x8d84068]: lookup TARGET: '/' 3411: libmount: TAB: [0x8d84160]: alloc 3411: libmount: TAB: [0x8d84160]: mtab parse: ignore mtab 3411: libmount: TAB: [0x8d84160]: mtab parse: #1 read mountinfo 3411: libmount: TAB: [0x8d84160]: /proc/self/mountinfo: start parsing [entries=0, filter=not] 3411: libmount: TAB: [0x8d84160]: add entry: /dev/root /
3411: libmount: CACHE: canonicalize path /proc/self/mountinfo
3411: libmount: TAB: TID for /proc/self/mountinfo is 3411
3411: libmount: UTILS: guessing system root [devno 3:2]
3411: libmount: UTILS: devno converted to /dev/hda2
3411: libmount: TAB: [0x8d84160]: canonical root FS: /dev/hda2 3411: libmount: TAB: [0x8d84160]: add entry: sysfs /sys 3411: libmount: TAB: [0x8d84160]: add entry: tmpfs /run 3411: libmount: TAB: [0x8d84160]: add entry: tmpfs /run/lock 3411: libmount: TAB: [0x8d84160]: add entry: proc /proc 3411: libmount: TAB: [0x8d84160]: add entry: devtmpfs /dev 3411: libmount: TAB: [0x8d84160]: add entry: tmpfs /run/shm 3411: libmount: TAB: [0x8d84160]: add entry: devpts /dev/pts 3411: libmount: TAB: [0x8d84160]: add entry: tmpfs /tmp 3411: libmount: TAB: [0x8d84160]: add entry: /dev/hda3 /home 3411: libmount: FS: [0x8d87dc8]: free [refcount=0] 3411: libmount: TAB: [0x8d84160]: /proc/self/mountinfo: stop parsing (10 entries) 3411: libmount: TAB: [0x8d84160]: parsing done [filename=/proc/self/mountinfo, rc=0] 3411: libmount: TAB: [0x8d84160]: mtab parse: #2 read utab 3411: libmount: TAB: [0x8d84160]: lookup SOURCE: '/dev/hda2' 3411: libmount: TAB: [0x8d84160]: lookup SRCPATH: '/dev/hda2'
/dev/hda2 is mounted
3411: libmount: TAB: [0x8d84160]: lookup SOURCE: '/dev/hda3'
3411: libmount: TAB: [0x8d84160]: lookup SRCPATH: '/dev/hda3'/dev/hda3 is mounted
Quoted 3 lines
The problem in this case is
/dev/root, libmount tries to convert it to the real device name by root= command line option, but the conversion is pretty poor and it does not support all relevant use-cases.
Yes, that is a bit annoying. It also breaks e4defrag. I have a kludgey script on my systems that parses /etc/fstab and creates a /dev/root symlink, but of course there's no guarantee that fstab matches the kernel root= command line.
If you feel like creating a makedevroot(8) utility (which creates a symlink if it can, or a device node if it can't), I suspect it would be appreciated.