5
1
So...I did something bad. In Cygwin I wrote a bash script that took in two directories and copied the contents of one into the other. First, it called "rm -rf" to remove the contents of the second directory. I accidentally ran the script with no second argument provided, and it looks like Cygwin took that as the dreaded "rm -rf /".
I'm not sure what the damage is and I'm trying to assess it. As it was running before I stopped it, I saw a lot of "permission denied" messages.
The most visible damage was that my C:\cygwin64 folder was clobbered. All that was left in it was a few empty directories. I believe that there may have been some directories that were alphabetically above cygwin64 that were deleted because I don't remember it being the highest directory in the list, which it now is.
My computer is acting 100% normal and I haven't experienced anything strange yet. I just want to know if anyone has any experience with "rm -rf /" on Cygwin and whether this could clobber your entire drive like it would on Linux.
Part of the puzzle is that the root of Cygwin is beneath the c-drive, but it contains a reference to the c-drive in "cygdrive". I'm wondering if "rm -rf /" would actually go all the way through with deleting all of the contents of "/cygdrive" or if that is protected somehow.
EDIT: On a side note, does anyone know why "rm -rf " would be the same as "rm -rf /". I distinctly remember not supplying a path and leaving that parameter blank, so I don't know why it called rm on the root directory.
So you're asking whether
rm -rf
crosses mount points? – Ben Voigt – 2015-10-05T05:38:09.0632On linux, the answer would be, "Yes, it crosses mount points unless you pass
--one-file-system
" Cygwin appears to support the same option. – Ben Voigt – 2015-10-05T05:39:39.243Tried an "NTFS Undelete" type of program? – Ben Voigt – 2015-10-05T05:41:11.017
I have an SSD. Is NTFS Undelete still worth a shot? – JDN – 2015-10-05T05:44:50.603
That may depend on whether you have TRIM support :( – Ben Voigt – 2015-10-05T05:45:53.607
It's a modern SSD on a brand new Windows 10 computer. I'm pretty sure it has TRIM support. I've already tried Recuva and it found nothing with deep scan. – JDN – 2015-10-05T05:51:25.487
On my Windows 7 PC there are only user created folders before `C:\cywin", nothing from a standard installation. – DavidPostill – 2015-10-05T07:05:04.020
Do you have a backup? If not I suggest you start making them in future ;) – DavidPostill – 2015-10-05T07:05:58.513
I actually backed up all of my personal files earlier today. So I'm not too worried about my stuff. Nothing is acting strange so they probably were just non essential folders. – JDN – 2015-10-05T07:40:08.557
Try
find
what files or dir it will find and you can understand that what it did like thisfind /*
this list all files and dir recursively and you can look for anyfolder or files are relating to windows because you get permission denied and which files are denied you can see. – makgun – 2015-10-05T10:51:33.657@makgun I tried "find /* | grep denied" and saw that most system files and program files are denied. But many personal files it seems could potentially be deleted. I'm mostly just lucky I stopped the script so quickly I guess. – JDN – 2015-10-05T14:26:51.127
If you deleted your files accidentally you can use testdisk (it is available on windows) it recovers files with their names if you don't overwrite anyfiles – makgun – 2015-10-05T16:26:51.340
This is a fun question. If I still had any Windows around I might try it and see how much havoc cygwin can cause. :) – chicks – 2015-10-05T17:01:02.050
@chicks It would be fun if it was a theoretical question...but it actually happened to me and it wasn't that fun. – JDN – 2015-10-05T18:16:57.480
This is only slightly less scary results than an ISP that had an "rm -rf /home/$1", and then a new staff member ran the script without any parameters to try to see help. (Your case is only potentially less scary only because you didn't mention if anything important is on the system.) If Windows desktop was deleted, who knows what other important stuff was too? Note that some undelete programs may overwrite data when undeleting; it is highly recommended that you make a bit-for-bit "forensic" image of the entire drive before making any other changes, if recoverability is of serious interest. – TOOGAM – 2015-10-05T23:03:25.423
@TOOGAM I'm pretty sure it's fine. I stopped the script quickly and it operates alphabetically. It's been over 24 hours and zero issues have presented themselves so far. – JDN – 2015-10-05T23:29:06.773