User: Password:
Subscribe / Log in / New account

Why not just not support hard links?

Why not just not support hard links?

Posted Sep 2, 2004 8:52 UTC (Thu) by Klavs (guest, #10563)
In reply to: Why not just not support hard links? by walles
Parent article: More notes on reiser4

Well vserver uses them to save space. If you have 10 vservers (virtual servers) on the same filesystem, mirrored from the same original - instead of having f.ex. 10*3gb of files - you would only have 3gb of files. And since vserver1 can't know of vserver2 or anything outside of the vserver - soft links would be bad.

The other nice thing, that I'm not sure if symlinks could implement (seing past the issues of symlinks to outside a vserver not being a good idea :) - is the new vserver fileattribute "Immutable-unlink" which means you can make all files immutable+Unlink in all vservers(two flags as far as I remember Immutable and Immutable-Unlink flag) - and if one vserver tries to change a file marked Immutable-Unlink - it will simply get a new file - and the old hardlink will be removed - meaning the other 9 vservers still share the same file.

To me this is clever use of hardlinks - but I'm no filesystem guru :)

(Log in to post comments)

Space savings should use COW

Posted Sep 2, 2004 9:48 UTC (Thu) by walles (guest, #954) [Link]

I think space savings would be better done by supporting copy-on-write semantics within the file system, which is just what you describe as Immutable-unlink. I imagine COW should be less error-prone than hard links, but just like you I'm no fs guru (or I wouldn't be asking these questions :-).

Something along these lines have been implemented at (which is a random project I found on Google, I don't know anything about it except what the web page says).

So do you (or anybody else for that part) know of any other uses for hard symlinks that don't have anything to do with space savings?

My use of hard links

Posted Sep 2, 2004 13:23 UTC (Thu) by utoddl (subscriber, #1232) [Link]

I have a script that makes good use of hard links -- not for space saving so much as time saving, but it saves a lot of space as well. I keep a copy of my RedHat/Fedora/whatever ISO images, and occasionally use wget to grab all the updates into another directory. These updates contain all 19 gazillion versions of the updated packages -- way more than will fit on a CD -- when what I really want of course is the latest version of each. So I use cpio to make a hard link duplicate tree of all those updates (i.e. real directories, hard linked files). That's pretty quick, 'cause it's not moving any data, just creating dir entries. Then my script throws out everything I don't want from that tree -- all the older versions of a given rpm -- and I'm left with a small enough set of rpms to fit onto a CD. I add my own favorite goodies that aren't on the distro (config files, utilities, etc.), and burn an ISO from that. That gives me the original distro CDs plus an extra CD with all current updates and my favorites all on CDs I can carry around so I can install on and update the various boxes I play with at home, work, friends' and family's houses, wherever. (Heck, I'll stick a copy of the scripts here if anybody wants to play with 'em.)

Using hardlinks for this was a natural. Having said that, I recall only using hardlinks once before, a long time ago, and that was specifically for space savings.

My use of hard links

Posted Sep 2, 2004 15:50 UTC (Thu) by fergal (guest, #602) [Link]

I think you could have used symlinks for this too. Then mkisofs -f which tells it to follow symlinks (it might break something that really was meant to be a symlink though).

Space savings should use COW

Posted Sep 10, 2004 0:46 UTC (Fri) by roelofs (guest, #2599) [Link]

So do you (or anybody else for that part) know of any other uses for hard symlinks that don't have anything to do with space savings?

Assuming you really meant "hard links," I use them to avoid accidentally deleting local mail files. Since such files get updated every day, usually several times a day, even daily incremental backups aren't sufficient to recover from an accidental deletion. But with hard-linked copies in a separate directory (e.g., ../.backups/foo.backup, etc.), you're safe. (And when you really do want to nuke the file, just truncate it to zero bytes--I wrote a trivial "trunc" utility that simply uses truncate() or ftruncate() for this purpose.) Of course, I suppose I could simply keep the "real" copy in the same hidden directory and use local symlinks to append to it...but with hard links you save one letter in every ls(1) command (i.e., -L). :-)

I've also occasionally used hard links to save a temporary MPEG or PDF file downloaded by Netscape; under some conditions, the temporary file will disappear as soon as the download is complete, but if you make a hard link at any point prior to that, the link will remain. For multi-megabyte downloads, that can be convenient, albeit not absolutely critical...


Space savings should use COW

Posted Sep 11, 2004 15:44 UTC (Sat) by khim (subscriber, #9252) [Link]

And this too can be covered by COW files. The fact is in almost all cases where I think about hardlink I found what I really need is COW file and hardlink is just poor substitute.

Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds