<div dir="ltr"><div><div><div>Fajar, thanks for your response and you're right. <br><br></div>I did some testing on the physical host before I wrote to the mailing list but mounted twice the same LV as rw. <br></div>Now I just did as you said and tried to do a rw mount followed by a ro mount. Indeed the same behavior:<br><br># mount /dev/mapper/vglxc-apps /mnt/1<br># mount -o ro /dev/mapper/vglxc-apps /mnt/2<br>mount: /dev/mapper/vglxc-apps already mounted or /mnt/2 busy<br>mount: according to mtab, /dev/mapper/vglxc-apps is mounted on /mnt/1<br><br></div>So its not LXC's fault (which I'm glad for!). Very interesting though that this happens in general.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 27, 2014 at 4:42 AM, Fajar A. Nugraha <span dir="ltr"><<a href="mailto:list@fajar.net" target="_blank">list@fajar.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I'm pretty sure it's NOT lxc's fault.<div><br></div><div>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</div><div><br></div><div><div>mount: /dev/zd208 already mounted or /mnt/tmp2 busy</div><div>mount: according to mtab, /dev/zd208 is mounted on /mnt/tmp</div></div><div><br></div><div>So lxc does the right thing: it says "Device or resource busy - failed to mount".</div><div><br></div><div><br></div><div>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.</div><div><br></div><div>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.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>-- </div><div>Fajar</div><div><br></div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 26, 2014 at 7:29 PM, Claudio Kuenzler <span dir="ltr"><<a href="mailto:ck@claudiokuenzler.com" target="_blank">ck@claudiokuenzler.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>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 <br><span><br>if (mount(fsname, target, fstype, mountflags & ~MS_REMOUNT, data))<br><br></span></div><div>Will be glad to test additional patches for you.<br></div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 26, 2014 at 11:19 AM, Claudio Kuenzler <span dir="ltr"><<a href="mailto:ck@claudiokuenzler.com" target="_blank">ck@claudiokuenzler.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div>I applied the patch but it does not work for the read only mount.<br><br>      lxc-start 1416993491.172 INFO     lxc_conf - conf.c:check_autodev:3821 - Autodev not required.<br>      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'<br><br></div>I have modified the patch order a bit. Please note that I'm not a developer so this might be plain wrong:<br><br>1901 static int mount_entry(const char *fsname, const char *target,<br>1902                        const char *fstype, unsigned long mountflags,<br>1903                        const char *data, int optional)<br>1904 {<br>1905 #ifdef HAVE_STATVFS<br>1906         struct statvfs sb;<br>1907 #endif<br>1908 <br>1909         if ((mountflags & MS_REMOUNT) || (mountflags & MS_BIND)) {<br>1910                 DEBUG("remounting %s on %s to respect bind or remount options",<br>1911                       fsname ? fsname : "(none)", target ? target : "(none)");<br>1912                 unsigned long rqd_flags = 0;<br>1913                 if (mountflags & MS_RDONLY)<br>1914                         rqd_flags |= MS_RDONLY;<br>1915 <br>1916 <br>1917         else if (mount(fsname, target, fstype, mountflags & ~MS_REMOUNT, data)) {<br>1918                 if (optional) {<br>1919                         INFO("failed to mount '%s' on '%s' (optional): %s", fsname,<br>1920                              target, strerror(errno));<br>1921                         return 0;<br>1922                 }<br>1923                 else {<br>1924                         SYSERROR("failed to mount '%s' on '%s'", fsname, target);<br>1925                         return -1;<br>1926                 }<br>1927         }<br>1928 <br>1929 #ifdef HAVE_STATVFS<br><br></div>This time the LV was mounted:<br><br>      lxc-start 1416996121.708 INFO     lxc_conf - conf.c:check_autodev:3823 - Autodev not required.<br>      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'<br>      lxc-start 1416996121.708 INFO     lxc_conf - conf.c:mount_file_entries:2224 - mount points have been setup<br><br></div>But I got different errors - which could be because of the modified code or because of something else:<br><br>      lxc-start 1416996121.730 DEBUG    lxc_conf - conf.c:setup_rootfs_pivot_root:1082 - pivot_root syscall to '/usr/local/lib/lxc/rootfs' successful<br>      lxc-start 1416996121.731 INFO     lxc_conf - conf.c:setup_pts:1641 - created new pts instance<br>      lxc-start 1416996121.731 INFO     lxc_conf - conf.c:setup_personality:1658 - set personality to '0x0'<br>      lxc-start 1416996121.731 ERROR    lxc_conf - conf.c:setup_caps:2339 - unknown capability mac_admin<br>      lxc-start 1416996121.731 ERROR    lxc_conf - conf.c:lxc_setup:4174 - failed to drop capabilities<br>      lxc-start 1416996121.731 ERROR    lxc_start - start.c:do_start:688 - failed to setup the container<br>      lxc-start 1416996121.731 ERROR    lxc_sync - sync.c:__sync_wait:51 - invalid sequence number 1. expected 2<br>      lxc-start 1416996121.731 WARN     lxc_conf - conf.c:lxc_delete_network:3175 - failed to remove interface '(null)'<br>      lxc-start 1416996121.758 ERROR    lxc_start - start.c:__lxc_start:1088 - failed to spawn 'mycontainer'<br>      lxc-start 1416996121.759 WARN     lxc_commands - commands.c:lxc_cmd_rsp_recv:172 - command get_init_pid failed to receive response<br>      lxc-start 1416996121.759 WARN     lxc_cgmanager - cgmanager.c:cgm_get:963 - do_cgm_get exited with error<br>      lxc-start 1416996126.764 ERROR    lxc_start_ui - lxc_start.c:main:342 - The container failed to start.<br>      lxc-start 1416996126.765 ERROR    lxc_start_ui - lxc_start.c:main:344 - To get more details, run the container in foreground mode.<br>      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.<br><br></div>Will try to redo this in a clean installation.<br></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 26, 2014 at 7:31 AM, Claudio Kuenzler <span dir="ltr"><<a href="mailto:ck@claudiokuenzler.com" target="_blank">ck@claudiokuenzler.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">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?</p>
<p dir="ltr">Will try it and let you know.</p><div><div>
<div class="gmail_quote">On Nov 26, 2014 6:35 AM, "Serge Hallyn" <<a href="mailto:serge.hallyn@ubuntu.com" target="_blank">serge.hallyn@ubuntu.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Quoting Claudio Kuenzler (<a href="mailto:ck@claudiokuenzler.com" target="_blank">ck@claudiokuenzler.com</a>):<br>
> Hello all,<br>
><br>
> OS: Ubuntu 14.04.1 LTS<br>
> LXC Version: 1.0.6-0ubuntu0.1<br>
><br>
> Experienced a weird issue when I tried to launch a container which mounts<br>
> an additional logical volume (ext4 formatted) through the container's fstab<br>
> file:<br>
><br>
> # cat /var/lib/lxc/mycontainer/fstab<br>
> /dev/vglxc/apps mnt/apps ext4 ro 0 0<br>
><br>
> This LV is already mounted on the physical host:<br>
><br>
> # mount /dev/vglxc/apps /mnt<br>
><br>
> Now when I try to launch the container, I get the following error:<br>
><br>
> # lxc-start -n mycontainer -l trace -o mycontainer.out<br>
> lxc-start: Device or resource busy - failed to mount '/dev/vglxc/apps' on<br>
> '/usr/lib/x86_64-linux-gnu/lxc/mnt/apps'<br>
> lxc-start: failed to setup the mounts for 'mycontainer'<br>
> lxc-start: failed to setup the container<br>
> lxc-start: invalid sequence number 1. expected 2<br>
> lxc-start: failed to spawn 'mycontainer'<br>
> lxc-start: The container failed to start.<br>
> lxc-start: Additional information can be obtained by setting the --logfile<br>
> and --logpriority options.<br>
><br>
> In the output file the following information is shown:<br>
><br>
>       lxc-start 1416921918.699 INFO     lxc_conf - Autodev not required.<br>
>       lxc-start 1416921918.699 ERROR    lxc_conf - Device or resource busy<br>
> - failed to mount '/dev/vglxc/apps' on<br>
> '/usr/lib/x86_64-linux-gnu/lxc/mnt/apps'<br>
>       lxc-start 1416921918.699 ERROR    lxc_conf - failed to setup the<br>
> mounts for 'mycontainer'<br>
><br>
> When I change the mount option in the container's fstab file from "ro" to<br>
> "defaults"  (or basically "rw"), the container starts up:<br>
><br>
> # cat /var/lib/lxc/mycontainer/fstab<br>
> /dev/vglxc/apps mnt/apps ext4 defaults 0 0<br>
><br>
> # lxc-start -n mycontainer -l trace -o mycontainer.out<br>
><br>
>       lxc-start 1416921799.912 INFO     lxc_conf - Autodev not required.<br>
>       lxc-start 1416921799.912 DEBUG    lxc_conf - mounted<br>
> '/dev/vglxc/apps' on '/usr/lib/x86_64-linux-gnu/lxc/mnt/apps', type 'ext4'<br>
><br>
> If the LV /dev/vglxc/apps is nowhere mounted yet, the container starts up -<br>
> with the read only mount option, too.<br>
><br>
> Is this a (known) bug I ran into?<br>
<br>
I think it is.  Can you please try with this patch:<br>
<br>
<a href="https://lists.linuxcontainers.org/pipermail/lxc-devel/2014-November/010876.html" target="_blank">https://lists.linuxcontainers.org/pipermail/lxc-devel/2014-November/010876.html</a><br>
<br>
applied?<br>
_______________________________________________<br>
lxc-users mailing list<br>
<a href="mailto:lxc-users@lists.linuxcontainers.org" target="_blank">lxc-users@lists.linuxcontainers.org</a><br>
<a href="http://lists.linuxcontainers.org/listinfo/lxc-users" target="_blank">http://lists.linuxcontainers.org/listinfo/lxc-users</a></blockquote></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
lxc-users mailing list<br>
<a href="mailto:lxc-users@lists.linuxcontainers.org" target="_blank">lxc-users@lists.linuxcontainers.org</a><br>
<a href="http://lists.linuxcontainers.org/listinfo/lxc-users" target="_blank">http://lists.linuxcontainers.org/listinfo/lxc-users</a><br></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
lxc-users mailing list<br>
<a href="mailto:lxc-users@lists.linuxcontainers.org">lxc-users@lists.linuxcontainers.org</a><br>
<a href="http://lists.linuxcontainers.org/listinfo/lxc-users" target="_blank">http://lists.linuxcontainers.org/listinfo/lxc-users</a><br></blockquote></div><br></div>