Fwd: Re: Hard links - How do they work

1 réponse [Dernière contribution]
Jonathan Matt Gresham
Hors ligne
A rejoint: 07/24/2023

Interesting thread I found on another server.

----- Forwarded message from Dan Ritter <name at domain> -----

> Date: Mon, 19 Feb 2024 06:56:38 -0500
> From: Dan Ritter <name at domain>
> To: Keith Bainbridge <name at domain>
> Cc: "debian-user@lists debian. org" <name at domain>
> Subject: Re: Hard links - How do they work
>
> Keith Bainbridge wrote:
> > As promised:
> > I said sometime in this thread that timeshift (and Back in Time) use hard
> > links to create progressive copies of the system. The more I think about how
> > hard links reportedly work, I reckon it can't be simply hard links.
> >
> > So I'm starting a new thread on that topic.
> >
> > My understanding is that a hard link (ln with no option) will list the file
> > in another directory, but the file remains the same no matter where I may
> > edit it. I use cp -lru as a quick and dirty way to protect me against
> > accident deleting a file. (Sym-link doesn't give that protection, but does
> > allow me to keep my home on a separate partition so that a fresh install is
> > a LOT easier; but that is another topic)
>
> A hard link is a name for a file -- it points to the first inode. Most
> files only have one name, but they can have many. Hard links can be in
> many directories, but must stay on the same filesystem. If you
> mv the file by any of its links on the same filesystem, all the
> links remain valid. When the last name for a file is deleted,
> the file is deleted. Now you know why deleting a file is
> sometimes called "unlinking".
>
> A symbolic link is a tiny file that contains a path to a file.
> The kernel reads the path, then looks for the substitute file.
> This can fail. But -- it can cross filesystems, even filesystems
> of completely different types. If you move the symbolic link, it
> continues to point to the same path. If you move the referenced
> file, the symbolic links are no longer valid.
>
>
> > Snapshots reportedly hard link the directory/ies (generally means / but not
> > limited ). a new snapshot copies the latest set and then updates any new
> > files in the base. The more I try to visualise that process the more I
> > reckon there must be more to it
>
> "snapshot" is not a single definition; the software you are using
> produces different results.
>
> rsnapshot/rsync, lvm, btrfs and zfs, for example, each use completely
> different mechanisms with different semantics.
>
> It looks like timeshift uses either rsync or btrfs snapshots,
> and backintime uses rsync, so first you would need to define which of those you are using
> and in what mode.
>
> -dsr-
>

----- End forwarded message -----

Magic Banana

I am a member!

I am a translator!

Hors ligne
A rejoint: 07/24/2010

I do not understand why "it can't be simply hard links" that Back In Time uses. Backups are on another filesystem (otherwise they are even useless in case of filesystem corruptions). If a file has not been modified since the latest snapshot, hard linking it works. If the file has been modified (or is brand new), it is copied to the newest snapshot.