0

While wanting to upgrade MongoDB from 3.4 to 3.6 I went into the /etc/apt/sources.list.d directory. From there I wanted to move the mongodb-org-3.4.list and mongodb-org-3.4.list.save files to my home directory.

I first executed a mv mongodb-org-3.4 ~/*. For some reason I managed to move the wildcard to the end of the command. After seeing the notification mv: cannot stat 'mongodb-org-3.4': No such file or directory, I then "corrected" this by typing mv mongodb-org-3.4* ~/*, again with the wildcard at the end. I did not use sudo, I was not root.

As a response for mv mongodb-org-3.4* ~/* I got

mv: cannot remove 'mongodb-org-3.4.list': Permission denied
mv: cannot remove 'mongodb-org-3.4.list.save': Permission denied
mv: inter-device move failed: '/home/user/atlassian' to '/home/user/windows-storage/atlassian'; unable to remove target: Directory not empty
mv: inter-device move failed: '/home/user/data' to '/home/user/windows-storage/data'; unable to remove target: Directory not empty
mv: cannot create symbolic link '/home/user/windows-storage/dockervolumes/sharemanager': Read-only file system

I then went into the /home/user/windows-storage directory and ls'd it, only to find that probably all of my home directory got copied (???) to this mounted directory.

Have I damaged something? Or have I "only" copied the home directory to this mounted directory?

Why did this mv command somehow behave like cp?

Ok, turns out files were moved, but not all, since I Ctrl+\ because it was taking an unusually long time to finish

4

The asterisks were expanded by your shell, so the resulting command was

mv mongodb-org-3.4.list mongodb-org-3.4.list.save ... ~/atlassian ~/... ~/data ... ~/windows-storage

(based on the errors you posted). Thus you instructed mv to move all the listed files and directories into ~/windows-storage — your home directory’s contents haven’t been copied, they’ve been moved.

To recover, you’ll need to look at all the contents of ~/windows-storage, and move whatever is appropriate back (taking care with *).

  • Now I'm a bit scared. – Daniel F Dec 7 '17 at 10:34
  • 1
    This is one of the reasons I always have set -x in my interactive shell sessions... :-) – Kusalananda Dec 7 '17 at 10:35
  • @Daniel I don’t think you’ll have lost any of the data that was in your home directory, but you might well have overwritten data in ~/windows-storage. Whatever you do, don’t panic. – Stephen Kitt Dec 7 '17 at 10:37
  • Ok, i've lost file metadata since they got moved onto an ntfs volume, also the timestamps changed. On 100mb rrd (rrdtool) got lost, because during the mv I ctrl+\ 'd which probalbly was during the move of that file so it only got moved halfway, and when moving all back that truncated file probably overwrote the original one. At least I hope that this is the only problem. I had to chmod -R three dirs, which I hope won't cause any problems, since some were docker volumes mounted inside containers. Reminds me of my rm -rf ~ while trying to recursively delete a directory named ~... – Daniel F Dec 7 '17 at 12:21

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.