<div dir="ltr">I have reduced the problem I described in my previous message to a much smaller test case. Here is an LXC config file that bind-mounts a single file, /other_file, from the host's root filesystem on top of another file, /empty, also from the host's root filesystem:<div><br></div><div><div>lxc.console = none<br></div><div><div>lxc.rootfs = /</div><div>lxc.mount.entry=/other_file empty none rw,bind 0 0</div><div><br></div><div>While the container is running, the host's /empty cannot be unlinked:</div></div><div><br></div><div><div><div>host# rm /empty /other_file</div><div>host# touch /empty /other_file</div><div>host# lxc-execute -n test -f test.config -- sleep 30 &</div><div>[1] 2419</div><div>host# strace -o rm.out rm /empty</div><div>rm: cannot remove `/empty': Device or resource busy</div><div>host# grep EBUSY rm.out</div><div>unlinkat(AT_FDCWD, "/empty", 0) = -1 EBUSY (Device or resource busy)</div><div>host# fg</div><div>lxc-execute -n test -f test.config -- sleep 30</div><div>^C</div><div>host# rm /empty</div><div>host#</div></div></div><div><br></div><div>Can anyone explain why the host's /empty cannot be unlinked even though it is bind-mounted out of the running container? Why is it "busy"?</div><div><br></div><div>Thanks,</div><div>Barry</div><div><br></div><div><br></div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 8, 2014 at 5:53 PM, Barry Jaspan <span dir="ltr"><<a href="mailto:barry.jaspan@acquia.com" target="_blank">barry.jaspan@acquia.com</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div dir="ltr">I'm using LXC on Ubuntu 12.04 (Precise) on EC2. I am creating a container that uses the host's root filesystem. In the lxc config, I am bind-mounting a different passwd file on top of /etc/passwd:<div><br></div><div><div>lxc.mount.entry=/container/passwd etc/passwd none rw,bind 0 0</div><div><br></div><div>As expected, /etc/passwd on the host and /etc/passwd in the container are different inodes:</div><div><br></div><div>host# ls -i /etc/passwd</div><div>58046 /etc/passwd</div><div>host# ls -i /container/passwd</div><div>287145 /container/passwd</div><div><br></div><div>container# ls -i /etc/passwd</div><div>287145 /etc/passwd</div><div><br></div><div>What I did not expect is that now it is not possible to unlink /etc/passwd at the host level (or inside the container, although I don't care about that):</div><div><br></div><div>host# rm /etc/passwd</div><div><div>rm: cannot remove `/etc/passwd': Device or resource busy<br></div></div><div><div>host# chsh -s /bin/false root</div><div>chsh: failure while writing changes to /etc/passwd</div></div><div><br></div><div>strace confirms that unlinkat() and rename() are returning EBUSY. (chsh creates a replacement for /etc/passwd and then rename()'s it into place.)</div><div><br></div><div>So, somehow, the fact that the host's /etc/passwd is *not* present in the container marks its inode as busy. I do not think it is as simple as "an inode that has been bind-mounted out of a namespace is busy" because a simple bind-mount test case does not reproduce it:</div><div><br></div><div><div># echo foo > foo</div><div># touch bar</div><div># mount --bind ./foo ./bar</div><div># cat bar</div><div>foo</div><div># touch new</div><div># mv new foo</div><div>#</div></div><div><br></div><div>This seems related to <a href="http://lwn.net/Articles/570338/" target="_blank">http://lwn.net/Articles/570338/</a>. However, in that article, a file which is bind-mounted into another namespace causes EBUSY from unlink/rename(). In my case, a file which is *not* bind-mounted into another namespace is causing EBUSY.</div><div><br></div><div>Can someone explain what is going on?</div><div><br></div><div>Thanks,</div><div><br></div><div>Barry</div><span class="HOEnZb"><font color="#888888"><span><font color="#888888"><div><br></div></font></span></font></span></div></div></div><span class="HOEnZb"><font color="#888888">-- <br><div>Barry Jaspan<br><font size="1"><span style="color:rgb(102,102,102)">Senior Architect | </span><a style="color:rgb(102,102,102)" href="http://acquia.com" target="_blank">Acquia</a><br style="color:rgb(102,102,102)"><a style="color:rgb(102,102,102)" href="mailto:barry.jaspan@acquia.com" target="_blank">barry.jaspan@acquia.com</a><span style="color:rgb(102,102,102)"> | (c) <a href="tel:617.905.2208" value="+16179052208" target="_blank">617.905.2208</a> | (w) <a href="tel:781-313-8298" value="+17813138298" target="_blank">781-313-8298</a></span><br style="color:rgb(102,102,102)"><br style="color:rgb(102,102,102)"><font><a href="http://www.acquia.com/dev-cloud" target="_blank">Acquia Dev Cloud: You build killer websites. We do the rest.</a><a href="http://acquia.com/dev-cloud" target="_blank"></a></font></font><br><a href="http://www.acquia.com/about-us/newsroom/press-releases/inc-magazine-unveils-31st-annual-list-america-s-fastest-growing" target="_blank"><span style="font-size:13px;font-family:Arial;color:#1155cc;background-color:transparent;font-weight:bold;font-style:normal;font-variant:normal;text-decoration:underline;vertical-align:baseline">Acquia</span><span style="font-size:13px;font-family:Arial;color:#1155cc;background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:underline;vertical-align:baseline"> ranked #1 Software Vendor on the 2012 Inc 500</span></a><br><br></div>
</font></span></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Barry Jaspan<br><font size="1"><span style="color:rgb(102,102,102)">Senior Architect | </span><a style="color:rgb(102,102,102)" href="http://acquia.com" target="_blank">Acquia</a><br style="color:rgb(102,102,102)"><a style="color:rgb(102,102,102)" href="mailto:barry.jaspan@acquia.com" target="_blank">barry.jaspan@acquia.com</a><span style="color:rgb(102,102,102)"> | (c) 617.905.2208 | (w) 781-313-8298</span><br style="color:rgb(102,102,102)"><br style="color:rgb(102,102,102)"><font><a href="http://www.acquia.com/dev-cloud" target="_blank">Acquia Dev Cloud: You build killer websites. We do the rest.</a><a href="http://acquia.com/dev-cloud" target="_blank"></a></font></font><br><a href="http://www.acquia.com/about-us/newsroom/press-releases/inc-magazine-unveils-31st-annual-list-america-s-fastest-growing" target="_blank"><span style="font-size:13px;font-family:Arial;color:#1155cc;background-color:transparent;font-weight:bold;font-style:normal;font-variant:normal;text-decoration:underline;vertical-align:baseline">Acquia</span><span style="font-size:13px;font-family:Arial;color:#1155cc;background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:underline;vertical-align:baseline"> ranked #1 Software Vendor on the 2012 Inc 500</span></a><br><br></div>
</div>