Hacker News new | ask | show | jobs
by leroy-is-here 1161 days ago
Back in the old days, I had some sort of arcane chroot setup for FTP for this website. I used a hard link to resolve everything. Well, like a year into it, I forgot that I used a hard link. I needed to update a few things, so I just rm’d the supposed sym link and nuked the entire site.

Learned a hard lesson about backups that day. I did have some, but of course we still lost some data.

1 comments

Huh, if you had hard links, won't the second file pointing to the data on the disk still exist somewhere else? I.e. the file would still be intact? And the disk space wouldn't be marked free/be in danger of being overwritten?
If it was a hard link to a directory, rm -r could've removed all the files from it first, before removing the directory itself. This would remove everything from the original dir.

(Or at least I think so - not a Linux expert here)

What system can you hardlink a directory? At least on macOS and FreeBSD the man pages explicitly state that hard links can only be created on files.
Nit about macOS: HFS+ supports hard links to directories (added in 10.5 to support Time Machine), but APFS does not.
Interesting, thanks for the information. I had thought it was the same with HFS but guess it's been some time since I used it...
I believe you can do it on Windows.
Windows does not allow hardlinks to directories, but it does have the concept of junction points.

https://learn.microsoft.com/en-us/sysinternals/downloads/jun...