File overwrites directory
by hareksu from LinuxQuestions.org on (#566FP)
Hi all,
I have experienced a bizarre error, which I didn't know was possible. I'm running ubuntu 18.04 on my laptop, and I used vlc to take a screenshot of a video file. Now I must have messed something up in the file saving dialog, because afterwards I noticed that instead of my 'Pictures' directory in which I intended to save, I had an image file named 'Pictures', which was indeed the screenshot. I can imagine how that worked, but I wasn't aware that it was possible to overwrite a directory with a file.
Anyway, so I lost all my pictures in that directory, some of which weren't backed up. I recovered a lot of files using the brute force approach of running magicrescue on the partition, and I'm now sorting through the mess of files I got out of that. I noticed it too late, so the file system (ext4) was still active and some files are probably lost.
Now I was wondering if there are any better ways of recovering something like this? I played arount with Sleuthkit and ext4undelete, but that only gives me access of deleted files, and these ones weren't deleted.
What exactly happens on a file system level when a directory is overwritten by a file?


I have experienced a bizarre error, which I didn't know was possible. I'm running ubuntu 18.04 on my laptop, and I used vlc to take a screenshot of a video file. Now I must have messed something up in the file saving dialog, because afterwards I noticed that instead of my 'Pictures' directory in which I intended to save, I had an image file named 'Pictures', which was indeed the screenshot. I can imagine how that worked, but I wasn't aware that it was possible to overwrite a directory with a file.
Anyway, so I lost all my pictures in that directory, some of which weren't backed up. I recovered a lot of files using the brute force approach of running magicrescue on the partition, and I'm now sorting through the mess of files I got out of that. I noticed it too late, so the file system (ext4) was still active and some files are probably lost.
Now I was wondering if there are any better ways of recovering something like this? I played arount with Sleuthkit and ext4undelete, but that only gives me access of deleted files, and these ones weren't deleted.
What exactly happens on a file system level when a directory is overwritten by a file?