Why does unplugging a drive lead to data loss when moving files?

Solution 1:

Moving by cut & paste is not really that different from copying and deleting, no.

The explanation for the data loss is buffering. When you ask Finder to cut & paste (or copy and delete - doesn't matter) - all that Finder does it ask the operating system to copy data to the external drive and delete the file from the internal drive.

The operating system then asks the external data to write data to disk. Unfortunately that is quite slow - so if this was done naively, you would have to be sitting waiting for a long time not being able to use your computer for other stuff.

This is why operating systems for decades have implemented buffering and asynchronous I/O. This means that the data from your SSD is really moved into memory (RAM), and then slowly transferred to the external drive as its speed allows. From the user interface perspective, the operation has completed and you're free to do other stuff.

The problem is that if you then disconnect the disk without unmounting, the data wasn't really saved to the disk yet. In practical what happens is that the data is simply lost.

To make matters worse this can also happen at other levels - i.e. the external disk itself might also have buffers and caches - and if power is unexpectedly cut before things are saved to permanent storage - it is lost.

This is why you always need to unmount disks from the Finder before unplugging them from the computer. Unmounting takes as long as it takes to write everything out to permanent storage and be certain that it is really stored as it should. So when the disk is unmounted, you're free to disconnect it.

There's really no way of recovering the data that was lost this way from the external drive - as it really never touched that drive. If you need to do recovery, you'll need to do it on the internal SSD.

The chances of recovery here are much better as usually when you delete a file, you're not overwriting or "deleting" the actual data - instead you're just "marking" it as deleted in the file system. However, if you kept using the SSD for other stuff, eventually your files will be overwritten and the data permanently lost.