mountall / upstart handles /dev mounting badly

Bug #1336674 reported by Alex Bligh
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
mountall (Ubuntu)
New
Undecided
Unassigned

Bug Description

mountall / Upstart handles /dev mounting badly on trusty (14.04) when no initrd is used. This is a regression from Precise (12.04).

This bug occurs when an Ubuntu image is produced using debootstrap and a separate initrd is not used. More precisely, I am using debootstrap to produce a root filing system which I am running as an initrd from RAM entirely, i.e. no pivitroot, and upstart (as init) is the first thing run by the kernel.

If an essentially empty (apart from /proc) /etc/fstab is used, /dev will be on the root (RAM) filing system and will be as produced by debootstrap. This means udev gets confused about addition of device nodes. Specifically, /dev/net/tun never gets created.

If /etc/fstab has a devtmpfs /dev in, things go better from a udev point of view, but there are no pty's in the system as /dev/pts doesn't exist.

If /etc/fstab has a devtmpfs /dev in AND a devpts fs mounted on /dev/pts, the same happens because /dev/pts (the directory) does not exist when mountall runs (because it needs to be within the newly mounted /dev), and hence devpts does not get mounted and the pseudoterminals still do not work.

I suspect this works when you do have a separate initrd as something has already mounted /dev and/or /dev/pts

A workaround is to run a tiny shell script before init like this, which is deeply horrible.

        mv ${DIR}/sbin/init ${DIR}/sbin/init.real
        cat >> ${DIR}/sbin/init <<'__END__'
#!/bin/sh
/bin/mount -t proc -o rw,noexec,nosuid,nodev proc /proc
/bin/mount -t sysfs -o rw,noexec,nosuid,nodev sysfs /sys
/bin/mount -t devtmpfs -o rw,mode=0755 udev /dev
/bin/mkdir -p /dev/pts
/bin/mount -t devpts -o rw,noexec,nosuid,gid=5,mode=0620 devpts /dev/pts
/bin/mv /sbin/init.real /sbin/init && exec /sbin/init "$@"
__END__
        chmod 755 ${DIR}/sbin/init

I think the easiest fix to this is probably in mountall rather than upstart (though I think it's an upstart bug). This would be that if the mount point is within a tmpfs style filing system AND has already been mounted by mountall, it should mkdir -p the mountpoint. This is relatively harmless as such tmpfs style filing systems are (as far as I know) pretty much guaranteed not to have directories in, and clearly the user's intent is that the directory is used.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.