I came across a strange mistake, I have some data on machine1
at
/temp/user1/data/
I want to share it with another machine2
, so I created same directory as
mkdir /temp/user1/data/
then on machine1, I do
sshfs /temp/user1/data user1@machine2:/temp/user1/data
it prompts
fuse: mountpoint is not empty
fuse: if you are sure this is safe, use the 'nonempty' mount option
then I do
sshfs -o nonempty /temp/user1/data user1@machine2:/temp/user1/data
suddenly, my data on machine1
under /temp/user1/data
are all gone, leaving an empty folder! all data lossed! what is wrong, can I got my data back?
You've mounted the remote machine's (empty)
/temp/user1/data
over the local machine's/temp/user1/data
. All should be good if you simply unmount the SSHFS mount (usingfusermount
, sincesshfs
usesfuse
under the hood).Ex. we have a non-empty local directory
then we mistakenly mount a remote directory over it:
Now when we list
vm
, we see the contents of the remotedir
instead:but if we unmount the SSHFS filesystem the local directory contents become visible again: