Recover data from folder that was target of mount

Mounting does not erase data, but it might hide data since the contents of the mountpoint are replaced with the mounted filesystem (which may be empty). Of course, there may be side effects (programs that behave differently depending on how things are mounted), so things can still go horribly wrong when you mismanage your mountpoints.

If you mounted an empty filesystem in the wrong place, simply umounting would do:

umount /acme

If you want to see what is below a mountpoint without umounting it, you can bind-mount the parent filesystem elsewhere:

mkdir /mnt/root
mount --bind / /mnt/root
ls /mnt/root/acme

It's more difficult if there are more filesystem layers mounted over one another. Use lsblk and cat /proc/mounts to figure out the structure. You can bind-mount each layer separately in a temporary directory and check out the contents.

Note those bind-mounts are writable by default so it's possible to change, rename and remove files. For a read-only view, just add --read-only.


Easy,

umount /acme

Your original /acme directory is simply "hidden" under the mount point.

If nothing prevents you to umount the dir, you can umount it, copy the data elsewhere and remount it.


If you can't unmount the mounted filesystem the original can still be reached by mounting it on a temporary mount point and accessing the files that way.

Tags:

Mount