-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
reproducible squashfs images: hard links #114331
Comments
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/what-are-your-goals-for-21-05/11559/4 |
confirmed with I don't see a way to tell mksquashfs to ignore hard links ( Whether it's better to replace a hard link with a symlink or with a duplicate file depends on the context, I think, so we probably shouldn't have a auto-hook but instead fix this on a per-package basis. |
The NAR archive format we use for cache.nixos.org does not preserve the information that some files might be hard links to each other. However, the squashfs format does preserve this information, which means when creating a squashfs image containing nix store paths that contain hard links, the squashfs image would be different depending on whether that nix store path was fetched from cache.nixos.org or built locally. For this reason I think we should avoid hard links in the nix store. For more background see NixOS#114331
The NAR archive format we use for cache.nixos.org does not preserve the information that some files might be hard links to each other. However, the squashfs format does preserve this information, which means when creating a squashfs image containing nix store paths that contain hard links, the squashfs image would be different depending on whether that nix store path was fetched from cache.nixos.org or built locally. For this reason I think we should avoid hard links in the nix store. For more background see NixOS#114331
This is also interesting IMO. Not sure where this difference comes from.
That explains it then and could be considered another problem (the Nix store FS would still have to support hard-links).
I wonder if that's a complete solution because we have
So I assume an optimised Nix store would replace copies with hard-links but the symlink approach should still work.
I wonder if we should contact upstream regarding this as this shouldn't only affect Nixpkgs (@raboof if you don't have time/motivation I could give it a try). From a quick look adding a flag to ignore hard links for r13y could be as easy as adding a conditional here: https://github.com/plougher/squashfs-tools/blob/57930cf4a1dc18a2cad221df40036cd801f85a09/squashfs-tools/mksquashfs.c#L2759 (though it could also break everything). @raboof anyway, this isn't an objection, feel free to continue with your approach, I'm mainly writing this because it seems like a good idea to "fix" this in |
This isn't really a Squashfs issue, as Mksquashfs does exactly what it is supposed to do. If the source has hardlinks then Mksquashfs preserves them. But, I can see a reason why the source might use hardlinks (saving space), and where it might be desirable to instead store them as duplicates in the Squashfs image, as Squashfs doesn't need to hardlink them to save space. So I have added a -no-hardlinks option here |
Great point, I didn't realize that.
I agree
Awesome, thanks! With that we can go back to pretending hardlinks are an 'invisible' optimization, which probably makes most sense in the end. |
Sorry, I didn't mean to imply that and agree that there's nothing wrong with the
@plougher Wow, that's totally awesome, thank you very very much! :) |
the nix store may contain hardlinks: derivations may output them directly, or users may be using store optimization which automatically hardlinks identical files in the nix store. The presence of these links are intended to be a 'transparent' optimization. However, when creating a squashfs image, the image will be different depending on whether hard links were present on the filesystem, leading to reproducibility problems. By passing '-no-hardlinks' to mksquashfs the files are stored as duplicates in the squashfs image. Since squashfs has support for duplicate files this does not lead to a larger image. For more details see NixOS#114331
the nix store may contain hardlinks: derivations may output them directly, or users may be using store optimization which automatically hardlinks identical files in the nix store. The presence of these links are intended to be a 'transparent' optimization. However, when creating a squashfs image, the image will be different depending on whether hard links were present on the filesystem, leading to reproducibility problems. By passing '-no-hardlinks' to mksquashfs the files are stored as duplicates in the squashfs image. Since squashfs has support for duplicate files this does not lead to a larger image. For more details see #114331
fixed in #114454 |
When building
jfsutils
locally,fsck.jfs
andjfs_fsck
are hard-linked to each other:However, when fetching the same package from the binary cache, they are separate files:
This would not be a problem, except that when creating a squashfs image containing this path, the image will also be different depending on whether these files are hard-linked or separate, making (for example) our installation ISO's not bit-by-bit reproducible: the image will be different depending on whether jfsutils was fetched from the cache or built locally.
The text was updated successfully, but these errors were encountered: