From e5ffe0d2484eb6cbcefcaeb5d52020b1130871a5 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 13 Jun 2013 21:56:23 -0700 Subject: [PATCH] ceph-disk: do not use mount --move (or --bind) The kernel does not let you mount --move when the parent mount is shared (see, e.g., https://bugzilla.redhat.com/show_bug.cgi?id=917008 for another person this also confused). We can't use --bind either since that (on RHEL at least) screws up /etc/mtab so that the final result looks like /var/lib/ceph/tmp/mnt.HNHoXU /var/lib/ceph/osd/ceph-0 none rw,bind 0 0 Instead, mount the original dev in the final location and then umount from the old location. Signed-off-by: Sage Weil --- src/ceph-disk | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/ceph-disk b/src/ceph-disk index 1d1a1501e79e0..127d809902db0 100755 --- a/src/ceph-disk +++ b/src/ceph-disk @@ -1248,6 +1248,7 @@ def auth_key( def move_mount( + dev, path, cluster, osd_id, @@ -1259,15 +1260,30 @@ def move_mount( '{cluster}-{osd_id}'.format(cluster=cluster, osd_id=osd_id), ) maybe_mkdir(osd_data) + + # we really want to mount --move, but that is not supported when + # the parent mount is shared, as it is by default on RH, Fedora, + # and probably others. Also, --bind doesn't properly manipulate + # /etc/mtab, which *still* isn't a symlink to /proc/mounts despite + # this being 2013. Instead, mount the original device at the final + # location. subprocess.check_call( args=[ '/bin/mount', - '--move', '--', - path, + dev, osd_data, ], ) + subprocess.check_call( + args=[ + '/bin/umount', + '-l', # lazy, in case someone else is peeking at the + # wrong moment + '--', + path, + ], + ) def start_daemon( @@ -1405,6 +1421,7 @@ def mount_activate( raise Error('another %s osd.%s already mounted in position (old/different cluster instance?); unmounting ours.' % (cluster, osd_id)) else: move_mount( + dev=dev, path=path, cluster=cluster, osd_id=osd_id, -- 2.39.5