[lxc-users] LXC not starting with already mounted LV as read-only mount

Fajar A. Nugraha list at fajar.net
Thu Nov 27 03:42:59 UTC 2014


I'm pretty sure it's NOT lxc's fault.

For starters, have you tried testing the same (i.e. mount rw, and then
mount again ro) in normal, non-lxc setup? That does not work, and does
indeed fail with a message like this

mount: /dev/zd208 already mounted or /mnt/tmp2 busy
mount: according to mtab, /dev/zd208 is mounted on /mnt/tmp

So lxc does the right thing: it says "Device or resource busy - failed to
mount".


A more relevant question would be "can you mount something in a path rw,
while it's ro in another path at the same time". The answer is, AFAIK, no.
Not directly, or  with bind-mount. Either both will be rw, or both will be
ro.

A workaround would probably be to use an additional fs layer on top of it,
like nfs or aufs, and then mount that additional layer ro.

-- 
Fajar


On Wed, Nov 26, 2014 at 7:29 PM, Claudio Kuenzler <ck at claudiokuenzler.com>
wrote:

> I made a couple of mistakes in my modified patch - so please ignore
> that.But the basic idea of it was to handle special mount flags (in this
> case RDONLY) before it hits
>
> if (mount(fsname, target, fstype, mountflags & ~MS_REMOUNT, data))
>
> Will be glad to test additional patches for you.
>
> On Wed, Nov 26, 2014 at 11:19 AM, Claudio Kuenzler <ck at claudiokuenzler.com
> > wrote:
>
>> I applied the patch but it does not work for the read only mount.
>>
>>       lxc-start 1416993491.172 INFO     lxc_conf -
>> conf.c:check_autodev:3821 - Autodev not required.
>>       lxc-start 1416993491.172 ERROR    lxc_conf -
>> conf.c:mount_entry:1916 - Device or resource busy - failed to mount
>> '/dev/vglxc/apps' on '/usr/local/lib/lxc/rootfs/mnt/apps'
>>
>> I have modified the patch order a bit. Please note that I'm not a
>> developer so this might be plain wrong:
>>
>> 1901 static int mount_entry(const char *fsname, const char *target,
>> 1902                        const char *fstype, unsigned long mountflags,
>> 1903                        const char *data, int optional)
>> 1904 {
>> 1905 #ifdef HAVE_STATVFS
>> 1906         struct statvfs sb;
>> 1907 #endif
>> 1908
>> 1909         if ((mountflags & MS_REMOUNT) || (mountflags & MS_BIND)) {
>> 1910                 DEBUG("remounting %s on %s to respect bind or
>> remount options",
>> 1911                       fsname ? fsname : "(none)", target ? target :
>> "(none)");
>> 1912                 unsigned long rqd_flags = 0;
>> 1913                 if (mountflags & MS_RDONLY)
>> 1914                         rqd_flags |= MS_RDONLY;
>> 1915
>> 1916
>> 1917         else if (mount(fsname, target, fstype, mountflags &
>> ~MS_REMOUNT, data)) {
>> 1918                 if (optional) {
>> 1919                         INFO("failed to mount '%s' on '%s'
>> (optional): %s", fsname,
>> 1920                              target, strerror(errno));
>> 1921                         return 0;
>> 1922                 }
>> 1923                 else {
>> 1924                         SYSERROR("failed to mount '%s' on '%s'",
>> fsname, target);
>> 1925                         return -1;
>> 1926                 }
>> 1927         }
>> 1928
>> 1929 #ifdef HAVE_STATVFS
>>
>> This time the LV was mounted:
>>
>>       lxc-start 1416996121.708 INFO     lxc_conf -
>> conf.c:check_autodev:3823 - Autodev not required.
>>       lxc-start 1416996121.708 DEBUG    lxc_conf -
>> conf.c:mount_entry:1975 - mounted '/dev/vglxc/apps' on
>> '/usr/local/lib/lxc/rootfs/mnt/apps', type 'ext4'
>>       lxc-start 1416996121.708 INFO     lxc_conf -
>> conf.c:mount_file_entries:2224 - mount points have been setup
>>
>> But I got different errors - which could be because of the modified code
>> or because of something else:
>>
>>       lxc-start 1416996121.730 DEBUG    lxc_conf -
>> conf.c:setup_rootfs_pivot_root:1082 - pivot_root syscall to
>> '/usr/local/lib/lxc/rootfs' successful
>>       lxc-start 1416996121.731 INFO     lxc_conf - conf.c:setup_pts:1641
>> - created new pts instance
>>       lxc-start 1416996121.731 INFO     lxc_conf -
>> conf.c:setup_personality:1658 - set personality to '0x0'
>>       lxc-start 1416996121.731 ERROR    lxc_conf - conf.c:setup_caps:2339
>> - unknown capability mac_admin
>>       lxc-start 1416996121.731 ERROR    lxc_conf - conf.c:lxc_setup:4174
>> - failed to drop capabilities
>>       lxc-start 1416996121.731 ERROR    lxc_start - start.c:do_start:688
>> - failed to setup the container
>>       lxc-start 1416996121.731 ERROR    lxc_sync - sync.c:__sync_wait:51
>> - invalid sequence number 1. expected 2
>>       lxc-start 1416996121.731 WARN     lxc_conf -
>> conf.c:lxc_delete_network:3175 - failed to remove interface '(null)'
>>       lxc-start 1416996121.758 ERROR    lxc_start -
>> start.c:__lxc_start:1088 - failed to spawn 'mycontainer'
>>       lxc-start 1416996121.759 WARN     lxc_commands -
>> commands.c:lxc_cmd_rsp_recv:172 - command get_init_pid failed to receive
>> response
>>       lxc-start 1416996121.759 WARN     lxc_cgmanager -
>> cgmanager.c:cgm_get:963 - do_cgm_get exited with error
>>       lxc-start 1416996126.764 ERROR    lxc_start_ui -
>> lxc_start.c:main:342 - The container failed to start.
>>       lxc-start 1416996126.765 ERROR    lxc_start_ui -
>> lxc_start.c:main:344 - To get more details, run the container in foreground
>> mode.
>>       lxc-start 1416996126.765 ERROR    lxc_start_ui -
>> lxc_start.c:main:346 - Additional information can be obtained by setting
>> the --logfile and --logpriority options.
>>
>> Will try to redo this in a clean installation.
>>
>> On Wed, Nov 26, 2014 at 7:31 AM, Claudio Kuenzler <ck at claudiokuenzler.com
>> > wrote:
>>
>>> I've read that mailing list post yesterday, too and was actually hoping
>>> this could solve the mount issue. When I looked at it, it seems that this
>>> patch hasnt been merged into the github repo yet, correct?
>>>
>>> Will try it and let you know.
>>> On Nov 26, 2014 6:35 AM, "Serge Hallyn" <serge.hallyn at ubuntu.com> wrote:
>>>
>>>> Quoting Claudio Kuenzler (ck at claudiokuenzler.com):
>>>> > Hello all,
>>>> >
>>>> > OS: Ubuntu 14.04.1 LTS
>>>> > LXC Version: 1.0.6-0ubuntu0.1
>>>> >
>>>> > Experienced a weird issue when I tried to launch a container which
>>>> mounts
>>>> > an additional logical volume (ext4 formatted) through the container's
>>>> fstab
>>>> > file:
>>>> >
>>>> > # cat /var/lib/lxc/mycontainer/fstab
>>>> > /dev/vglxc/apps mnt/apps ext4 ro 0 0
>>>> >
>>>> > This LV is already mounted on the physical host:
>>>> >
>>>> > # mount /dev/vglxc/apps /mnt
>>>> >
>>>> > Now when I try to launch the container, I get the following error:
>>>> >
>>>> > # lxc-start -n mycontainer -l trace -o mycontainer.out
>>>> > lxc-start: Device or resource busy - failed to mount
>>>> '/dev/vglxc/apps' on
>>>> > '/usr/lib/x86_64-linux-gnu/lxc/mnt/apps'
>>>> > lxc-start: failed to setup the mounts for 'mycontainer'
>>>> > lxc-start: failed to setup the container
>>>> > lxc-start: invalid sequence number 1. expected 2
>>>> > lxc-start: failed to spawn 'mycontainer'
>>>> > lxc-start: The container failed to start.
>>>> > lxc-start: Additional information can be obtained by setting the
>>>> --logfile
>>>> > and --logpriority options.
>>>> >
>>>> > In the output file the following information is shown:
>>>> >
>>>> >       lxc-start 1416921918.699 INFO     lxc_conf - Autodev not
>>>> required.
>>>> >       lxc-start 1416921918.699 ERROR    lxc_conf - Device or resource
>>>> busy
>>>> > - failed to mount '/dev/vglxc/apps' on
>>>> > '/usr/lib/x86_64-linux-gnu/lxc/mnt/apps'
>>>> >       lxc-start 1416921918.699 ERROR    lxc_conf - failed to setup the
>>>> > mounts for 'mycontainer'
>>>> >
>>>> > When I change the mount option in the container's fstab file from
>>>> "ro" to
>>>> > "defaults"  (or basically "rw"), the container starts up:
>>>> >
>>>> > # cat /var/lib/lxc/mycontainer/fstab
>>>> > /dev/vglxc/apps mnt/apps ext4 defaults 0 0
>>>> >
>>>> > # lxc-start -n mycontainer -l trace -o mycontainer.out
>>>> >
>>>> >       lxc-start 1416921799.912 INFO     lxc_conf - Autodev not
>>>> required.
>>>> >       lxc-start 1416921799.912 DEBUG    lxc_conf - mounted
>>>> > '/dev/vglxc/apps' on '/usr/lib/x86_64-linux-gnu/lxc/mnt/apps', type
>>>> 'ext4'
>>>> >
>>>> > If the LV /dev/vglxc/apps is nowhere mounted yet, the container
>>>> starts up -
>>>> > with the read only mount option, too.
>>>> >
>>>> > Is this a (known) bug I ran into?
>>>>
>>>> I think it is.  Can you please try with this patch:
>>>>
>>>>
>>>> https://lists.linuxcontainers.org/pipermail/lxc-devel/2014-November/010876.html
>>>>
>>>> applied?
>>>> _______________________________________________
>>>> lxc-users mailing list
>>>> lxc-users at lists.linuxcontainers.org
>>>> http://lists.linuxcontainers.org/listinfo/lxc-users
>>>
>>>
>>
>
> _______________________________________________
> lxc-users mailing list
> lxc-users at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20141127/5f234051/attachment-0001.html>


More information about the lxc-users mailing list