lxc-create -b is broken
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/
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/
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/
proc /var/lib/
sysfs /var/lib/
/home/gary /var/lib/
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/
proc proc proc nodev,noexec,nosuid 0 0
sysfs sys sysfs defaults 0 0
/home/gary /var/lib/
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.