1 { kernelPackages ? null, mkXfsFlags ? "" }:
2 import ../make-test-python.nix ({ pkgs, lib, ... }: {
3 name = "lvm2-thinpool";
4 meta.maintainers = lib.teams.helsinki-systems.members;
6 nodes.machine = { pkgs, lib, ... }: {
7 virtualisation.emptyDiskImages = [ 4096 ];
9 boot.thin.enable = true;
10 dmeventd.enable = true;
12 environment.systemPackages = with pkgs; [ xfsprogs ];
13 environment.etc."lvm/lvm.conf".text = ''
14 activation/thin_pool_autoextend_percent = 10
15 activation/thin_pool_autoextend_threshold = 80
17 boot = lib.mkIf (kernelPackages != null) { inherit kernelPackages; };
21 mkXfsFlags = lib.optionalString (lib.versionOlder kernelPackages.kernel.version "5.10") " -m bigtime=0 -m inobtcount=0 "
22 + lib.optionalString (lib.versionOlder kernelPackages.kernel.version "5.19") " -i nrext64=0 ";
24 machine.succeed("vgcreate test_vg /dev/vdb")
25 machine.succeed("lvcreate -L 512M -T test_vg/test_thin_pool")
26 machine.succeed("lvcreate -n test_lv -V 16G --thinpool test_thin_pool test_vg")
27 machine.succeed("mkfs.xfs ${mkXfsFlags} /dev/test_vg/test_lv")
28 machine.succeed("mkdir /mnt; mount /dev/test_vg/test_lv /mnt")
29 assert "/dev/mapper/test_vg-test_lv" == machine.succeed("findmnt -no SOURCE /mnt").strip()
30 machine.succeed("dd if=/dev/zero of=/mnt/empty.file bs=1M count=1024")
31 machine.succeed("journalctl -u dm-event.service | grep \"successfully resized\"")
32 machine.succeed("umount /mnt")
33 machine.succeed("vgchange -a n")