Part of my migration strategy of moving to Amazon EC2 for our servers involves making use of symlinks to keep installs and files in their 'standard' locations on the servers but the actual storage of logs files, data, etc. on EBS storage, for persistence. After the server starts up, I run scripts that create symlinks to the config files and data stored on the EBS to 'convert' the server to the setup I need.
Since I'm not a true Linux sysadmin (small company developer), I'm nervous about any sort of gotchas I might be unaware of by using symlinks. Things like breaking software packages or other difficulties where the applications might not like utilizing symlinks are what I'm concerned about.
Are there any common gotchas using symlinks or are they pretty foolproof?
If you are only soft symlinking directories - rather than files - then they should for the most part behave entirely transparently.
The only issue that you may stumble across is some applications which resolve and then continue to refer to the real path of the link. Which can cause issues if you choose to change the source of the link at a later stage.
Yeah, stay away from "hard" links, as you can easily create chaos with them. Hard symlinks are just a "re-appearance" of the same file in a different part of the filesystem, i.e. it literally creates a 2nd entry in the directory structure of the filesystem with a direct link to the file data. They have their uses but generally speaking, you're better off with "Soft" symlinks, which are akin to Windows shortcuts (although much different in implementation) in that they are just a pointer back to the original file. These are your best bet.
Deleting a soft symlink deletes the link. Deleting a hard symlink can delete the file if you're not careful.
Hard links, as someone pointed out, make second entries in the file system. You can only use that on the same partition and for files, not directories. If you delete all the hard links to a file then the file does get deleted.
Soft links, ie, symbolic links, just make an entry in the directory which lets you easily see, ONE DIRECTION, where the real file is stored.
What you don't get is any knowledge at the other end that multiple symlinks point to a file. If you move or delete the file all the symlinks break.
Used in moderation, symlinks are fine. You should think hard if you find that a symlink points to a symlink which points to yet another symlink before reaching the real file. You are probably doing something wrong then...