0

I have moved a file (results.txt) from source_path to destination_path, a path on the external hard disk, using the mv command in Mint18. After the moving was finished, I unplugged the disk to plug it to another system to check results.txt. However, the file exists neither in the destination_path nor in the source_path. Is the mv command run unsuccessfully and results.txt deleted? Is there any way to retrieve results.txt?

  • 3
    To find out what happened: did you umount the target filesystem after mv? or just pulled the plug out? – Kamil Maciorowski Feb 18 '20 at 6:30
  • I did not unmount it. I just plugged it out from the system and plugged again to another system. – Arghavan Mohammadhassani Feb 18 '20 at 6:31
  • you should umount before you unplug, but you didn't so the disk writing isn't really done, you lost your file. – 炸鱼薯条德里克 Feb 18 '20 at 6:41
  • Bad mistake! :( – Arghavan Mohammadhassani Feb 18 '20 at 6:42
  • 2
    @ArghavanMohammadhassani The mv command might have been done, but that just means that from the user's point of view, the file had moved. In the background, the filesystem does caching and buffering and other optimizations for performance, which means it may well wait to write the data to disk until some later time. Pulling the disk out, without letting the system write unwritten data to disk, would obviously be a cause of data loss and corruption. This is true on any system unless you use synchronous writes. – Kusalananda Feb 18 '20 at 7:06

Browse other questions tagged or ask your own question.