mountvirtfs does not mkdir /var/run and /var/lock

Bug #173180 reported by Marc MERLIN
4
Affects Status Importance Assigned to Milestone
sysvinit (Ubuntu)
Invalid
Undecided
Unassigned
Nominated for Dapper by Andrew Pollock

Bug Description

Here's the full problem.

If /var is made to be a separate partition, and therefore /var is an empty directory on the root partition, mounting /var/run fails, which in turns causes ifup lo to fail later because /var/run is now a directory on the new /var partition and isn't wiped from boot to boot, causing a stale network state file to still be there, and lo not to come up, which in turn breaks a lot of things like portmapper, nfs and others.

As far as I can tell, the fix is simply to do what the file in the comment already says, but doesn't do for some reason. Mmmh, I think I see why, it's because it's a bit difficult since / is likely still read only at the time.
If you don't like this, you could put that mkdir at unmount time after /var is umounted, and before the system reboots

--- mountvirtfs.orig 2007-11-30 18:55:55.000000000 -0800
+++ mountvirtfs 2007-11-30 19:35:30.000000000 -0800
@@ -42,6 +42,14 @@

        # Mount /var/run and /var/lock as tmpfs.
        # /var may be on another drive so create /var/run if we need to
+ if [ ! -d /var/run -o ! -d /var/lock ]; then
+ # unfortunately, / is still likely still read only for now
+ if ! mkdir -p /var/run /var/lock 2>/dev/null; then
+ mount -n -o remount,rw /
+ mkdir -p /var/run /var/lock
+ mount -n -o remount,ro /
+ fi
+ fi
        domount tmpfs /var/run "-o mode=0755"
        domount tmpfs /var/lock "-o mode=1777"

The problem occured at least on dapper, but as far as I can tell, gutsy has the same problem.

Revision history for this message
Scott James Remnant (Canonical) (canonical-scott) wrote :

You can't make a directory there because the filesystem is read-only at that point.

Those directories are already made on shutdown in /etc/init.d/umountroot

Changed in sysvinit:
status: New → Invalid
Revision history for this message
Liam Bedford (lbedford-deactivatedaccount) wrote :

This does not appear to be true for dapper, which apollock nominated this bug for:
from the umountroot init script:
do_stop () {
    [ "$VERBOSE" != no ] && log_action_begin_msg "Mounting root filesystem read-only"
    mount -n -o remount,ro /
    [ "$VERBOSE" != no ] && log_action_end_msg $?
}

Revision history for this message
Scott James Remnant (Canonical) (canonical-scott) wrote :

dapper was released a long time ago, normally development effort only focuses on current releases (in this case, hardy). gutsy shipped with the fix.

Revision history for this message
Andrew Pollock (apollock) wrote :

Okay, so LTS release aside, I'm just trying to understand this...

You shipped a release, multiple releases by the sounds of it, that didn't support having /var as a separate filesystem? At all? Not even on a server? I'm struggling to come to terms with this. It seems a perfectly valid (and not uncommon) use case, and I'm surprised that it wasn't picked up prior to release, or sooner than this after release.

Revision history for this message
Scott James Remnant (Canonical) (canonical-scott) wrote :

No, they support it just fine provided you make /var/run and /var/lock on the root filesystem; which all of our tools did.

About the only way to get into this situation was install Ubuntu without a separate /var, and then move it onto a separate partition later.

That was sufficiently rare that it took a release or two before it was noticed (I think it was reported very very late in edgy -- which was a short release anyway, and fixed in feisty so that we made the directory underneath on shutdown).

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.