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
nixos/initrd: Add thin-provisioning-tools binaries #46541
Conversation
This enables usage of thin and cache volumes without ugly hacks (see NixOS#15516). With my conifiguration on 18.03, size of initrd before this change is 12470611 and after is 13542353, only 8.6% increase. These files are added to extra-utils: lrwxrwxrwx 11 result/bin/cache_check -> pdata_tools lrwxrwxrwx 11 result/bin/cache_dump -> pdata_tools lrwxrwxrwx 11 result/bin/cache_metadata_size -> pdata_tools lrwxrwxrwx 11 result/bin/cache_repair -> pdata_tools lrwxrwxrwx 11 result/bin/cache_restore -> pdata_tools lrwxrwxrwx 11 result/bin/era_check -> pdata_tools lrwxrwxrwx 11 result/bin/era_dump -> pdata_tools lrwxrwxrwx 11 result/bin/era_invalidate -> pdata_tools lrwxrwxrwx 11 result/bin/era_restore -> pdata_tools -r-xr-xr-x 1350576 result/bin/pdata_tools lrwxrwxrwx 11 result/bin/thin_check -> pdata_tools lrwxrwxrwx 11 result/bin/thin_delta -> pdata_tools lrwxrwxrwx 11 result/bin/thin_dump -> pdata_tools lrwxrwxrwx 11 result/bin/thin_ls -> pdata_tools lrwxrwxrwx 11 result/bin/thin_metadata_size -> pdata_tools lrwxrwxrwx 11 result/bin/thin_repair -> pdata_tools lrwxrwxrwx 11 result/bin/thin_restore -> pdata_tools lrwxrwxrwx 11 result/bin/thin_rmap -> pdata_tools lrwxrwxrwx 11 result/bin/thin_trim -> pdata_tools -r-xr-xr-x 7016 result/lib/libaio.so.1 -r-xr-xr-x 221072 result/lib/libexpat.so.1 -r--r--r-- 100608 result/lib/libgcc_s.so.1 -r-xr-xr-x 1558864 result/lib/libstdc++.so.6 Fixes NixOS#15516
I run a system with thin lvm. To boot my system, initrd doesn't need all of these tools, only Also I think adding thin lvm tools should be made conditional on actually using thin lvm instead of adding them "just in case". IMO the best solution is a new NixOS options |
@xeji I just managed to bring my system back up after migration to thin volumes using this hack:
just adding All other binaries are just symlinks to As for adding another option, I though about that, but after I found out that size of initrd doesn't change much, decided to push it without option first. I guess I'll add smth like What do you think? |
Right, I didn't realize that, so adding them all is fine. I like the idea to have one option to activate both the kernel module and necessary tools. My personal preference would be to have simple boolean options, sth like: Let's wait a little and see what other people think about the 1MB increase in initrd size first. |
This makes me wonder why stuff like |
Yep, |
I think we should make initrd fully configurable, defaulting to current state. This way if one cares one can strip it down to only what is needed for one's config. We'll have to carve things out of stage1 as well though. |
|
We could do that, and I would, but there are strong objections to such uses of |
I only see limited values in making it optional but disabled by default. Most people will keep it then also they do not ever need it. Is it not possible to detect if mdadm or lvm are actually needed? |
It is possible to add such detection functionality to |
Any updates on this pull request, please? |
Thank you for your contributions.
|
I have tried the release-2020.09, nixpkgs.git hash c6fa7bb today. The boot works, though I see following (transcribed from screen shot so end lines are cut off):
The cache check is skipped but it doesn't seem to be critical for the boot to progress. |
@ajs124, I didn't have it there, so I've added it. No difference though. Rechecked it is enabled:
I've also replaced thin_check with cache_check:
... to see if would help, but nope... Still the same:
This looks to me like some lvm binary, which is trying to execute cache_check, is not properly adjusted. The old hack which replaces strings within binaries using perl voodoo:
works fine though. |
I marked this as stale due to inactivity. → More info |
thin-provisioning-tools has a _huge_ closure size (hundreds of megabytes) and the only reference in the output of the lvm2 package is a _comment_ in the etc/lvm.conf The lvm2 package thus does not seem to depend on thin-provisoning-tools in any way. Reverts 9326a89 thin provisoning is broken with or without this change: NixOS#15516 A proper fix is here: NixOS#46541 References: $ nix why-depends nixpkgs#lvm2 nixpkgs#thin-provisioning-tools /nix/store/n7zwwxi0ihjks7qk9bq5lbkniligfcqc-lvm2-2.03.11 └───etc/lvm.conf: …_check_executable = "/nix/store/w5an38q6byfr1sihks66srbqdii9hnsd-thin-prov> → /nix/store/w5an38q6byfr1sihks66srbqdii9hnsd-thin-provisioning-tools-0.9.0 $ ag thin-provisioning-tools --search-binary etc/lvm.conf 1093: # (See package device-mapper-persistent-data or thin-provisioning-tools) 1095: # thin_check_executable = "/nix/store/w5an38q6byfr1sihks66srbqdii9hnsd-thin-provisioning-tools-0.9.0/bin/thin_check" 1100: # (See package device-mapper-persistent-data or thin-provisioning-tools) 1102: # thin_dump_executable = "/nix/store/w5an38q6byfr1sihks66srbqdii9hnsd-thin-provisioning-tools-0.9.0/bin/thin_dump" 1108: # (See package device-mapper-persistent-data or thin-provisioning-tools) 1110: # thin_repair_executable = "/nix/store/w5an38q6byfr1sihks66srbqdii9hnsd-thin-provisioning-tools-0.9.0/bin/thin_repair" 1155: # (See package device-mapper-persistent-data or thin-provisioning-tools) 1157: # cache_check_executable = "/nix/store/w5an38q6byfr1sihks66srbqdii9hnsd-thin-provisioning-tools-0.9.0/bin/cache_check" 1162: # (See package device-mapper-persistent-data or thin-provisioning-tools) 1164: # cache_dump_executable = "/nix/store/w5an38q6byfr1sihks66srbqdii9hnsd-thin-provisioning-tools-0.9.0/bin/cache_dump" 1170: # (See package device-mapper-persistent-data or thin-provisioning-tools) 1172: # cache_repair_executable = "/nix/store/w5an38q6byfr1sihks66srbqdii9hnsd-thin-provisioning-tools-0.9.0/bin/cache_repair"
thin-provisioning-tools has a _huge_ closure size (hundreds of megabytes) and the only reference in the output of the lvm2 package is a _comment_ in the etc/lvm.conf The lvm2 package thus does not seem to depend on thin-provisoning-tools in any way. Reverts 9326a89 thin provisoning is broken with or without this change: #15516 A proper fix is here: #46541 References: $ nix why-depends nixpkgs#lvm2 nixpkgs#thin-provisioning-tools /nix/store/n7zwwxi0ihjks7qk9bq5lbkniligfcqc-lvm2-2.03.11 └───etc/lvm.conf: …_check_executable = "/nix/store/w5an38q6byfr1sihks66srbqdii9hnsd-thin-prov> → /nix/store/w5an38q6byfr1sihks66srbqdii9hnsd-thin-provisioning-tools-0.9.0 $ ag thin-provisioning-tools --search-binary etc/lvm.conf 1093: # (See package device-mapper-persistent-data or thin-provisioning-tools) 1095: # thin_check_executable = "/nix/store/w5an38q6byfr1sihks66srbqdii9hnsd-thin-provisioning-tools-0.9.0/bin/thin_check" 1100: # (See package device-mapper-persistent-data or thin-provisioning-tools) 1102: # thin_dump_executable = "/nix/store/w5an38q6byfr1sihks66srbqdii9hnsd-thin-provisioning-tools-0.9.0/bin/thin_dump" 1108: # (See package device-mapper-persistent-data or thin-provisioning-tools) 1110: # thin_repair_executable = "/nix/store/w5an38q6byfr1sihks66srbqdii9hnsd-thin-provisioning-tools-0.9.0/bin/thin_repair" 1155: # (See package device-mapper-persistent-data or thin-provisioning-tools) 1157: # cache_check_executable = "/nix/store/w5an38q6byfr1sihks66srbqdii9hnsd-thin-provisioning-tools-0.9.0/bin/cache_check" 1162: # (See package device-mapper-persistent-data or thin-provisioning-tools) 1164: # cache_dump_executable = "/nix/store/w5an38q6byfr1sihks66srbqdii9hnsd-thin-provisioning-tools-0.9.0/bin/cache_dump" 1170: # (See package device-mapper-persistent-data or thin-provisioning-tools) 1172: # cache_repair_executable = "/nix/store/w5an38q6byfr1sihks66srbqdii9hnsd-thin-provisioning-tools-0.9.0/bin/cache_repair"
@ajs124 could you take a look at this? |
@SnVIZQ do you also have dm-cache mappings? |
@ajs124 I'm not sure what exactly you mean by "dm-cache mappings", but my gut feeling is the answer is yes. The basic topology si like this: There's LUKS on low level - on SSDs and HDDs, on top of that is LVM, where HDDs use cache residing on SSD - the standard lvmcache(7) approach. |
That's what I meant, yes. LVM2 manages device mapper things for you. We currently only support booting from thin pools or lvmthin(7), but not lvmcache(7). Can you try if this works: diff --git a/nixos/modules/tasks/lvm.nix b/nixos/modules/tasks/lvm.nix
index 98a0e2ddef9..a4311c6baa9 100644
--- a/nixos/modules/tasks/lvm.nix
+++ b/nixos/modules/tasks/lvm.nix
@@ -48,11 +48,13 @@ in {
extraUtilsCommands = ''
copy_bin_and_libs ${pkgs.thin-provisioning-tools}/bin/pdata_tools
copy_bin_and_libs ${pkgs.thin-provisioning-tools}/bin/thin_check
+ copy_bin_and_libs ${pkgs.thin-provisioning-tools}/bin/cache_check
'';
};
environment.etc."lvm/lvm.conf".text = ''
global/thin_check_executable = "${pkgs.thin-provisioning-tools}/bin/thin_check"
+ global/cache_check_executable = "${pkgs.thin-provisioning-tools}/bin/cache_check"
'';
})
(mkIf (cfg.dmeventd.enable || cfg.boot.thin.enable) {
@@ -61,6 +63,7 @@ in {
cat << EOF >> /etc/lvm/lvm.conf
${optionalString cfg.boot.thin.enable ''
global/thin_check_executable = "$(command -v thin_check)"
+ global/cache_check_executable = "$(command -v cache_check)"
''}
${optionalString cfg.dmeventd.enable ''
dmeventd/executable = "$(command -v false)" |
I have applied your patch (addition of cache_check stuff to lvm.nix) on top of b1ee3bc commit (release-21.05 branch from 2021-08-04_10-54-24), removed the "old hack" (extension of extraUtilsCommands{,Test} from my older post above), set the services.lvm.boot.thin.enable to true, rebuilt and activated this configuration and I can confirm it booted just fine. So I'd vote for having the patch applied because it solves my issue. :-) |
We could do that, although the option kind of has a misleading name, then. Then again, I'll open a PR. |
Motivation for this change
This enables usage of thin and cache volumes without ugly hacks (see #15516). With my conifiguration on 18.03, size of initrd before this change is 12470611 and after is 13542353, only 8.6% increase.
These files are added to extra-utils:
Fixes #15516
Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)nix path-info -S
before and after)