Skip to main content
added 3 characters in body
Source Link
sebasth
  • 15.8k
  • 6
  • 53
  • 71

If you are using Linux

You can test if a directory is a mount point using mountpoint.

To avoid mount point appearing/disappearing between test and rm -r, you need to run the script in a separate mount namespacemount namespace with private subtreeprivate subtree (mounts do not propagate from/to new name spacenamespace). This can be accomplished with unshare.

unshare -m --propagation private -- "<delete script>"

Everything in same script:

#!/bin/sh

unshare -m --propagation private -- sh -e <<EOF

if ! mountpoint -q "<path>"; then
    rm -r "<path>"
fi

EOF

If you are using Linux

You can test if a directory is a mount point using mountpoint.

To avoid mount point appearing/disappearing between test and rm -r, you need to run the script in a separate mount namespace with private subtree (mounts do not propagate from/to new name space). This can be accomplished with unshare.

unshare -m --propagation private -- "<delete script>"

Everything in same script:

#!/bin/sh

unshare -m --propagation private -- sh -e <<EOF

if ! mountpoint -q "<path>"; then
    rm -r "<path>"
fi

EOF

If you are using Linux

You can test if a directory is a mount point using mountpoint.

To avoid mount point appearing/disappearing between test and rm -r, you need to run the script in a separate mount namespace with private subtree (mounts do not propagate from/to new namespace). This can be accomplished with unshare.

unshare -m --propagation private -- "<delete script>"

Everything in same script:

#!/bin/sh

unshare -m --propagation private -- sh -e <<EOF

if ! mountpoint -q "<path>"; then
    rm -r "<path>"
fi

EOF
added 13 characters in body
Source Link
sebasth
  • 15.8k
  • 6
  • 53
  • 71

If you are using Linux

You can test if a directory is a mount point using mountpointmountpoint.

On Linux, toTo avoid mount point appearing/disappearing between test and rm -r, you need to run the script in a separate mount namespace with private subtree (mounts do not propagate from/to new name space). This can be accomplished with unshare.

unshare -m --propagation private -- "<delete script>"

Everything in same script:

#!/bin/sh

unshare -m --propagation private -- sh -e <<EOF

if ! mountpoint -q "<path>"; then
    rm -r "<path>"
fi

EOF

You can test if a directory is a mount point using mountpoint.

On Linux, to avoid mount point appearing/disappearing between test and rm -r, you need to run the script in a separate mount namespace with private subtree (mounts do not propagate from/to new name space). This can be accomplished with unshare.

unshare -m --propagation private -- "<delete script>"

Everything in same script:

#!/bin/sh

unshare -m --propagation private -- sh -e <<EOF

if ! mountpoint -q "<path>"; then
    rm -r "<path>"
fi

EOF

If you are using Linux

You can test if a directory is a mount point using mountpoint.

To avoid mount point appearing/disappearing between test and rm -r, you need to run the script in a separate mount namespace with private subtree (mounts do not propagate from/to new name space). This can be accomplished with unshare.

unshare -m --propagation private -- "<delete script>"

Everything in same script:

#!/bin/sh

unshare -m --propagation private -- sh -e <<EOF

if ! mountpoint -q "<path>"; then
    rm -r "<path>"
fi

EOF
added 13 characters in body
Source Link
sebasth
  • 15.8k
  • 6
  • 53
  • 71

You can test if a directory is a mount point using mountpoint.

ToOn Linux, to avoid mount point appearing/disappearing between test and rm -r, you need to run the script in a separate mount namespace with private subtree (mounts do not propagate from/to new name space). This can be accomplished with unshare.

unshare -m --propagation private -- "<delete script>"

OrEverything in asame script:

#!/bin/sh

unshare -m --propagation private -- sh -e <<EOF 

if ! mountpoint -q "<path>"; then
    rm -r "<path>"
fi

EOF

You can test if a directory is a mount point using mountpoint.

To avoid mount point appearing/disappearing between test and rm -r, you need to run the script in a separate mount namespace with private subtree (mounts do not propagate from/to new name space). This can be accomplished with unshare.

unshare -m --propagation private -- "<delete script>"

Or in a script:

#!/bin/sh

unshare -m --propagation private -- sh -e <<EOF
if ! mountpoint -q "<path>"; then
    rm -r "<path>"
fi

EOF

You can test if a directory is a mount point using mountpoint.

On Linux, to avoid mount point appearing/disappearing between test and rm -r, you need to run the script in a separate mount namespace with private subtree (mounts do not propagate from/to new name space). This can be accomplished with unshare.

unshare -m --propagation private -- "<delete script>"

Everything in same script:

#!/bin/sh

unshare -m --propagation private -- sh -e <<EOF 

if ! mountpoint -q "<path>"; then
    rm -r "<path>"
fi

EOF
added 71 characters in body
Source Link
sebasth
  • 15.8k
  • 6
  • 53
  • 71
Loading
added 71 characters in body
Source Link
sebasth
  • 15.8k
  • 6
  • 53
  • 71
Loading
Post Undeleted by sebasth
added 71 characters in body
Source Link
sebasth
  • 15.8k
  • 6
  • 53
  • 71
Loading
added 71 characters in body
Source Link
sebasth
  • 15.8k
  • 6
  • 53
  • 71
Loading
Post Deleted by sebasth
Source Link
sebasth
  • 15.8k
  • 6
  • 53
  • 71
Loading