Filesystem Misinformation [was Re: Homebrew]
Jordan K. Hubbard
jkh at apple.com
Tue May 18 18:32:18 PDT 2010
On May 18, 2010, at 6:09 PM, Arno Hautala wrote:
> I decided to check these out:
>
>
>> 1. Hard links don't play nicely with Time Machine
>
> The don't. As an example, below is the output from some hard linked
> files I created. First on my system and then on my TimeMachine
> Backup.
I think you may be getting confused by the fact that TM does not create individual file links to your "level zero backup" (assuming files that do not change) if it can also create a directory hard link one level up. The directory hard link "feature" is unique to time machine and can significantly screw with your existing assumptions if you're used to the way Unix has traditionally done things. Try modifying an existing file in one of these directories-containing-hardlinks and do another backup to see how this is dealt with in turn.
> It's also interesting that 'ls' doesn't seem to be hardlink aware
> either as it lists a total of 20 MB for the directory, whereas 'du'
> lists the correct 2 MB.
Correct. I don't think making ls(1) be aware of hardlinks was seen to have any special value given that folks who really care about these things are already using the -i flag to see when the same inodes are being used.
> Hardlinks can't span volumes and they aren't retained when copied to
> other volumes.
That depends. No, they can't span volumes since each volume obviously has its own inode table, but a number of archivers / file copy utilities on MacOSX will happily preserve hard links, as you can readily prove by creating a large file and then n hardlinks to that file within a single directory hierarchy and then making a tarball out of it. You'll see the same results as with du(1) - only one copy is archived and accounted for.
> It'd be nice if TimeMachine was smart enough to keep
> these (CarbonCopyCloner does [1]), but it currently doesn't.
> This should be reported to Apple (re. TimeMachine, ls, others?).
Time Machine is making its own copy of your hierarchy, since it wouldn't be much of a backup utility if it did not, but it's still using links (both directory and file) under its own control to keep the number of copies reduced to just those files/directories which have changed from backup to backup. I think you're also getting fooled into thinking that TM's job is to recreate your filesystem hierarchy exactly in another location - it's not. TM's job is to provide a *backup* of your files in such a fashion that they can be restored back exactly the way they were, hardlinks and symlinks included, and it does.
> As indicated above, du correctly reports the size, though confusingly
> only prints each linked file once. Ideally, in my view, each file
> would be listed, with some indication that it was a hardlink to an
> already listed file.
du's output is mandated by the UNIX03 specification, to which Mac OS X conforms. Complain to The Open Group. :-)
- Jordan
More information about the macports-dev
mailing list