I've covered this in other articles here, but when I went searching for something to point a customer at I had a little trouble finding it, so we'll do it here:
Let's say you have a system with a few filesystems. One of those systems is getting tight on space, but the other has plenty of room. You want to add a large amount of data, but it has to be in the file system that's low on space. For example, it's /home that is low on space, and it's /home/fred/drwaings that needs more room.
There are several ways to handle that. First you could just move that "drawings" directory to /bigdrive/drawings and leave it at that. Any scripts that use /home/fred/drawings would need to be updated and any users who need access would have to get used to looking on /bigdrive. You could also just move all of fred: ~fred could now be /bigdrive/users/fred or whatever. If only Fred used these, that might be an easy solution: move him over, edit /etc/passwd to change his home directory (or use "usermod" to do it for you). Or..
You could use a symbolic link. This method starts by moving "drawings" to /bigdrive as before:
Found an error or have a suggestion? Let us know and we'll review it.
mv /home/fred/drawings /bigdrive/drawings
And then:
ln -s /bigdrive/drawings /home/fred/drawings
For almost all uses, this is entirely transparent: no scripts need to be modified, no users need to be notified or retrained. Any action that accesses /home/fred/drawings will end up accessing /bigdrive/drawings instead. Well, almost any action - "ls -l" does work slightly differently after the move:
# before the link
$ ls -l drawings
total 53776
-rw-r--r-- 1 apl wheel 17086 Nov 12 09:46 01-04-06_0537.jpg
-rw-r--r-- 1 apl wheel 42590 Nov 12 09:46 12-28-05_0521.jpg
-rw-r--r-- 1 apl wheel 48270 Nov 12 09:46 12-28-05_1038.jpg
-rw-r--r-- 1 apl wheel 39134 Nov 12 09:46 12-28-05_1042.jpg
-rw-r--r-- 1 apl wheel 39138 Nov 12 09:46 12-28-05_1043.jpg
-rw-r--r-- 1 apl wheel 41874 Nov 12 09:46 12-28-05_1044.jpg
-rw-r--r-- 1 apl wheel 41578 Nov 12 09:45 12-28-05_1045.jpg
etc.
# after the link
$ ls -l drawings
lrwxr-xr-x 1 apl apl 9 Nov 22 08:10 tfoo -> /bigdrive/drawings
Also, "rm" won't complain if you just "rm /home/fred/drawings": it won't warn about this being a directory - but it doesn't remove /bigdrive/drawings, just the symbolic link in /home/fred. But watch out: some Unixes have slightly different treatments -
Suggest a Correction
Controlling Disk Space w/ Symbolic Links
0 views
Comments (0)
Please sign in to leave a comment.





No comments yet. Be the first to comment!