EDIT: The command completed and then I rebooted the VM, so I added more photos. Also changed my answer to include the fact that the machine wasn't totally clobbered.
EDIT 2: I still have the VM. Let me know in the comments if you have anything you want me to try on it out of curiosity.
EDIT 3: I decided to experiment a little more. I restored to a snapshot I took right before I ran the command, I put one folder above C:\cygwin
and one folder below. I then ran the command and did ctrl-c
very quickly. The cygwin folder still existed (inside it was mostly empty) but the folder above it was erased. The user generated folder below it was intact as well. Then I restored the state and ran the command again, this time for a little longer before ctrl-c
. Now it erased both the folder above cygwin, cygwin itself, and the folder below.
When I ran this on my computer in real life the C:\cygwin64
folder was intact, implying that everything below it alphabetically was safe. This gives me some peace of mind now knowing for certain that the only folders that were blown out were those above C:\cygwin64
, which usually are just temp folders or some other non-essential folders anyways.
TLDR: Don't run rm -rf /*
or rm -rf /
EVER.
TLDR2: I created a Windows 10 VM, installed Cygwin, and ran rm -rf /*
. VM got pretty messed up. To answer my own question: Yes, it would delete everything that it has permission to access on your hard drive. If I hadn't cancelled the command as fast as I did when this happened on my real machine it would have deleted all of my personal files. The general OS would still be intact though.
So, I decided to create a Windows 10 VM and try this from scratch. Here's what happened. Cygwin doesn't let you do rm -rf /
for safety reasons (there's an override option)...but rm -rf /*
is perfectly fine apparently with no warning.
I realized that in my original script I was deleting all of the files in a provided directory, so I used rm -rf $1/*
, so if $1
is empty...the dreaded destroy your hard-drive command is executed, and Cygwin doesn't even warn you!
About to hit enter...
cygwin64 is the first to get clobbered
Windows Explorer link is gone
Start Menu is still here
There goes the desktop image!
Notification center is still fine
Cortana Too!
Recycling bin is broken, but now I can access Windows Explorer!
C: Drive Contents, not much has changed here
General UI is still working fine
Start Menu no longer responds
Music lives! It's the only library left standing
The command has completed!
Not much new here in C:
Applications still work if launched from the executable, app data is still intact
I rebooted the machine. No problems booting up and logging in. Programs still work if you click on their direct executable. Still have internet access. It's hard to assess the permanent damage. Start still doesn't open.
fatal error - cygheap base mismatch detected.
This problem is probably due to using incompatible versions of the cygwin DLL.
This error is caused because the Git for Windows path is incompatible with Cywin.
They both use /bin
and /usr/bin
but these map to different directories (because they use different mount tables).
Cywin expects to find the dll in /usr/bin/cygwin1.dll
(and is not found in Git for Windows)
When you explicitly run any Cygwin command in a Git for Windows bash
shell Cygwin cannot find its dll and generates the error message above.
Notice below that the mount mapping for /
is different.
Git for Windows:
DavidPostill@Hal MINGW64 ~
$ mount
C:/temp on /tmp type ntfs (binary,noacl,posix=0,usertemp)
C:/apps/Git on / type ntfs (binary,noacl,auto)
C:/apps/Git/usr/bin on /bin type ntfs (binary,noacl,auto)
C: on /c type ntfs (binary,noacl,posix=0,user,noumount,auto)
E: on /e type vfat (binary,noacl,posix=0,user,noumount,auto)
F: on /f type ntfs (binary,noacl,posix=0,user,noumount,auto)
DavidPostill@Hal MINGW64 ~
$ which cygwin1.dll
which: no cygwin1.dll in (/c/Users/DavidPostill/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/mingw64/bin:/usr/bin:/c/Users/DavidPostill/bin:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/apps/WSCC/Sysinternals Suite:/c/apps/WSCC/NirSoft Utilities:/c/apps/Calibre:/cmd:/mingw64/bin:/usr/bin:/usr/bin/vendor_perl:/usr/bin/core_perl)
DavidPostill@Hal MINGW64 ~
$ /c/cygwin/bin/man
1 [main] man (608) C:\cygwin\bin\man.exe: *** fatal error - cygheap base mismatch detected - 0x180301408/0x180304408.
This problem is probably due to using incompatible versions of the cygwin DLL.
Search for cygwin1.dll using the Windows Start->Find/Search facility
and delete all but the most recent version. The most recent version *should*
reside in x:\cygwin\bin, where 'x' is the drive on which you have
installed the cygwin distribution. Rebooting is also suggested if you
are unable to find another cygwin DLL.
Segmentation fault
Cygwin:
$ mount
C:/cygwin/bin on /usr/bin type ntfs (binary,auto)
C:/cygwin/lib on /usr/lib type ntfs (binary,auto)
C:/cygwin on / type ntfs (binary,auto)
C: on /c type ntfs (binary,posix=0,user,noumount,auto)
E: on /e type vfat (binary,posix=0,user,noumount,auto)
F: on /f type ntfs (binary,posix=0,user,noumount,auto)
$ which cygwin1.dll
/usr/bin/cygwin1.dll
$ /c/cygwin/bin/man
What manual page do you want?
There is no solution, other than don't mix and match cygwin derived utilities. Pick one and stick with it.
Best Answer
I managed to sort this with yet another installation - this time I opted to download and install from the net (option 1 in the installer), instead of downloading the files separately and installing from the locally-stored folder (options 2 and 3). I can't be sure why selecting those options was providing me with an incomplete installation, but I'm now able to run
bash
without errors.