mirror of
https://github.com/CHN-beta/nixos.git
synced 2024-10-23 13:08:44 +08:00
整理完成 filesystem
This commit is contained in:
parent
f1200943bb
commit
a36922f81d
@ -136,7 +136,7 @@
|
|||||||
btrfs =
|
btrfs =
|
||||||
{
|
{
|
||||||
"/dev/disk/by-uuid/02e426ec-cfa2-4a18-b3a5-57ef04d66614"."/" = "/boot";
|
"/dev/disk/by-uuid/02e426ec-cfa2-4a18-b3a5-57ef04d66614"."/" = "/boot";
|
||||||
"/dev/mapper/root"."/nix" = "/nix";
|
"/dev/mapper/root" = { "/nix" = "/nix"; "/nix/rootfs/current" = "/"; };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
decrypt.auto =
|
decrypt.auto =
|
||||||
@ -148,6 +148,7 @@
|
|||||||
"ARRAY /dev/md/swap metadata=1.2 name=chn-PC:swap UUID=2b546b8d:e38007c8:02990dd1:df9e23a4";
|
"ARRAY /dev/md/swap metadata=1.2 name=chn-PC:swap UUID=2b546b8d:e38007c8:02990dd1:df9e23a4";
|
||||||
swap = [ "/dev/mapper/swap" ];
|
swap = [ "/dev/mapper/swap" ];
|
||||||
resume = "/dev/mapper/swap";
|
resume = "/dev/mapper/swap";
|
||||||
|
rollingRootfs = { device = "/dev/mapper/root"; path = "/nix/rootfs"; };
|
||||||
};
|
};
|
||||||
};}
|
};}
|
||||||
)
|
)
|
||||||
|
@ -3,12 +3,6 @@ inputs:
|
|||||||
config =
|
config =
|
||||||
{
|
{
|
||||||
# filesystem mount
|
# filesystem mount
|
||||||
fileSystems."/" =
|
|
||||||
{
|
|
||||||
device = "/dev/mapper/root";
|
|
||||||
fsType = "btrfs";
|
|
||||||
options = [ "subvol=nix/rootfs/current" "compress-force=zstd" ];
|
|
||||||
};
|
|
||||||
# sudo btrfs fi mkswapfile --size 64g --uuid clear swap
|
# sudo btrfs fi mkswapfile --size 64g --uuid clear swap
|
||||||
# sudo btrfs inspect-internal map-swapfile -r swap
|
# sudo btrfs inspect-internal map-swapfile -r swap
|
||||||
# sudo mdadm --create /dev/md/swap --level 0 --raid-devices 2 /dev/nvme1n1p5 /dev/nvme0n1p5
|
# sudo mdadm --create /dev/md/swap --level 0 --raid-devices 2 /dev/nvme1n1p5 /dev/nvme0n1p5
|
||||||
@ -99,29 +93,7 @@ inputs:
|
|||||||
# initrd, luks
|
# initrd, luks
|
||||||
boot.initrd =
|
boot.initrd =
|
||||||
{
|
{
|
||||||
systemd =
|
systemd.enable = true;
|
||||||
{
|
|
||||||
enable = true;
|
|
||||||
services.create-current-rootfs =
|
|
||||||
{
|
|
||||||
wantedBy = [ "local-fs-pre.target" ];
|
|
||||||
after = [ "cryptsetup.target" ];
|
|
||||||
before = [ "local-fs-pre.target" ];
|
|
||||||
unitConfig.DefaultDependencies = false;
|
|
||||||
serviceConfig.Type = "oneshot";
|
|
||||||
script =
|
|
||||||
''
|
|
||||||
mount /dev/mapper/root /mnt -m
|
|
||||||
if [ -f /mnt/nix/rootfs/current/.timestamp ]
|
|
||||||
then
|
|
||||||
mv /mnt/nix/rootfs/current /mnt/nix/rootfs/$(cat /mnt/nix/rootfs/current/.timestamp)
|
|
||||||
fi
|
|
||||||
btrfs subvolume create /mnt/nix/rootfs/current
|
|
||||||
echo $(date '+%Y%m%d%H%M%S') > /mnt/nix/rootfs/current/.timestamp
|
|
||||||
umount /mnt
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
# modules in initrd
|
# modules in initrd
|
||||||
# modprobe --show-depends
|
# modprobe --show-depends
|
||||||
availableKernelModules =
|
availableKernelModules =
|
||||||
|
@ -18,18 +18,11 @@ inputs:
|
|||||||
swap = mkOption { type = types.listOf types.nonEmptyStr; };
|
swap = mkOption { type = types.listOf types.nonEmptyStr; };
|
||||||
resume = mkOption { type = types.nullOr (types.str or (types.submodule { options =
|
resume = mkOption { type = types.nullOr (types.str or (types.submodule { options =
|
||||||
{ device = mkOption { type = types.nonEmptyStr; }; offset = mkOption { type = types.ints.unsigned; }; }; })); };
|
{ device = mkOption { type = types.nonEmptyStr; }; offset = mkOption { type = types.ints.unsigned; }; }; })); };
|
||||||
# cleanRootfs = mkOption { type = types.nullOr
|
rollingRootfs = mkOption { type = types.nullOr (types.submodule { options =
|
||||||
|
{
|
||||||
# swap and resume
|
device = mkOption { type = types.nonEmptyStr; };
|
||||||
# swap != resume.device if swap is a file
|
path = mkOption { type = types.nonEmptyStr; };
|
||||||
# swap = mkOption { type = types.nullOr types.str; };
|
}; }); };
|
||||||
# resume =
|
|
||||||
# {
|
|
||||||
# device = mkOption { type = types.nullOr types.str; };
|
|
||||||
# # sudo btrfs fi mkswapfile --size 64g --uuid clear swap
|
|
||||||
# # sudo btrfs inspect-internal map-swapfile -r swap
|
|
||||||
# offset = mkOption { type = types.nullOr types.ints.unsigned; };
|
|
||||||
# };
|
|
||||||
};
|
};
|
||||||
config =
|
config =
|
||||||
{
|
{
|
||||||
@ -91,6 +84,31 @@ inputs:
|
|||||||
if inputs.config.nixos.fileSystems.mdadm != null then
|
if inputs.config.nixos.fileSystems.mdadm != null then
|
||||||
{ services.swraid = { enable = true; mdadmConf = inputs.config.nixos.fileSystems.mdadm; }; }
|
{ services.swraid = { enable = true; mdadmConf = inputs.config.nixos.fileSystems.mdadm; }; }
|
||||||
else {}
|
else {}
|
||||||
|
)
|
||||||
|
// (
|
||||||
|
if inputs.config.nixos.fileSystems.rollingRootfs != null then
|
||||||
|
{
|
||||||
|
systemd.services.roll-rootfs =
|
||||||
|
{
|
||||||
|
wantedBy = [ "local-fs-pre.target" ];
|
||||||
|
after = [ "cryptsetup.target" ];
|
||||||
|
before = [ "local-fs-pre.target" ];
|
||||||
|
unitConfig.DefaultDependencies = false;
|
||||||
|
serviceConfig.Type = "oneshot";
|
||||||
|
script = let inherit (inputs.config.nixos.fileSystems.rollingRootfs) device path; in
|
||||||
|
''
|
||||||
|
mount ${device} /mnt
|
||||||
|
if [ -f /mnt${path}/current/.timestamp ]
|
||||||
|
then
|
||||||
|
mv /mnt${path}/current /mnt${path}/$(cat /mnt${path}/current/.timestamp)
|
||||||
|
fi
|
||||||
|
btrfs subvolume create /mnt${path}/current
|
||||||
|
echo $(date '+%Y%m%d%H%M%S') > /mnt${path}/current/.timestamp
|
||||||
|
umount /mnt
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else {}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// (
|
// (
|
||||||
|
Loading…
Reference in New Issue
Block a user