lxc-create -b is broken

Bug #968371 reported by Gary Poster
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lxc (Ubuntu)
Fix Released
High
Unassigned

Bug Description

The -b flag in current Precise lxc-create sets up an fstab that has "$homedir $homedir none bind 0 0" instead of "$homedir /var/lib/lxc/$container/rootfs/$homedir none bind 0 0". This doesn't seem to work, which is a regression.

I created a container with this:
$ sudo lxc-create -t ubuntu -n lptests -- -r lucid -a i386 -b gary

This resulted in an fstab for that container that looked like this:

$ cat /var/lib/lxc/lptests/fstab
proc proc proc nodev,noexec,nosuid 0 0
sysfs sys sysfs defaults 0 0
/home/gary /home/gary none bind 0 0

I expected to see an fstab that looked like this older instance:
$ cat /var/lib/lxc/lpdev/fstab
proc /var/lib/lxc/lpdev/rootfs/proc proc nodev,noexec,nosuid 0 0
sysfs /var/lib/lxc/lpdev/rootfs/sys sysfs defaults 0 0
/home/gary /var/lib/lxc/lpdev/rootfs//home/gary none bind 0 0

Starting the new container gives me an empty home directory, rather than my bound home directory from the host. If I edit fstab as follows then the new container does give me a bound home directory from the host as I expect.

$ cat /var/lib/lxc/lptests/fstab
proc proc proc nodev,noexec,nosuid 0 0
sysfs sys sysfs defaults 0 0
/home/gary /var/lib/lxc/lptests/rootfs/home/gary none bind 0 0

Related branches

Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

Ah, I see. It's because $homedir is an absolute path.

This will be a problem for regular containers as well.

The problem is that lxc takes an absolute path to mean that the path should be prefixed by the rootfs location. It's ok for directory backed containers as it accepts the source mount of the rootfs. But for lvm backed containers, /var/lib/lxc/$container/rootfs is *not* accepted as valid.

We can fix this firstly by removing the leading '/' from the second field in the fstab entry. That will do the right thing.

We can also still update lxc to accept /var/lib/lxc/$container/rootfs regardless of whether that has anything to do with its rootfs, and go back to the old style fstab entries.

Changed in lxc (Ubuntu):
status: New → Confirmed
importance: Undecided → High
Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

To be clear, the workaround I recomment for now is to update lxc-start-ephemeral locally to remove the leading '/' from the second field, so that the fstab looks like:

/home/gary home/gary none bind 0 0

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package lxc - 0.7.5-3ubuntu47

---------------
lxc (0.7.5-3ubuntu47) precise; urgency=low

  * 0065-fix-bindhome-relpath: use relative path as target for bind mount
    in lxc-ubuntu template (LP: #968371)
 -- Serge Hallyn <email address hidden> Thu, 29 Mar 2012 22:04:30 +0000

Changed in lxc (Ubuntu):
status: Confirmed → Fix Released
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.