<html>
    <head>
      <base href="https://bugs.freedesktop.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Enable custom path to be ignored on shutdown umount cycle"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=56837">56837</a>
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>systemd-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Enable custom path to be ignored on shutdown umount cycle
          </td>
        </tr>

        <tr>
          <th>QA Contact</th>
          <td>systemd-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>major
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux (All)
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>aleksei.lissitsin@gmail.com
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>x86-64 (AMD64)
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>general
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>systemd
          </td>
        </tr></table>
      <p>
        <div>
        <pre>In systemd it should be possible to specify which mountpoints must not be
unmounted on shutdown.

I have the following setup:
Archlinux (guest) is installed into a file on an ntfs partition (host).

Initrd mounts the host (say, /dev/sda2) into its (initrd's) filesystem using
an executable whose name starts with @ (so that the process would not be killed
by systemd on shutdown).

Then initrd creates a loop device using the file on the host and proceeds to
start the guest using it as the root device.

But I still want to access the host from the guest, so initrd bind-mounts
the host to a path in guest's filesystem (I cannot mount it later from guest
because /dev/sda2 would be busy as already mounted).

This causes /dev/sda2 to appear in guest's mountinfo, so that systemd will try
(and succeed) to unmount it while there are still some processes writing to
guest's filesystem. --> BAD THINGS HAPPEN THEN

I currently solve the issue by the following patch 
(my host is mounted to /host in guest filesystem)

--- a/src/core/mount-setup.c
+++ b/src/core/mount-setup.c
@@ -127,7 +127,7 @@ bool mount_point_ignore(const char *path) {
                 if (path_equal(path, i))
                         return true;

-        return false;
+        return path_startswith(path, "/host");
 }

 static int mount_one(const MountPoint *p, bool relabel) {

But I think that using predefined prefixes is not the best solution and systemd
should allow one to somehow specify exactly which mountpoints not to unmount on
shutdown.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the QA Contact for the bug.</li>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>