format rootfs in vm itself

This commit is contained in:
Jörg Thalheim 2024-02-09 16:50:58 +01:00
parent 07caab537f
commit 11ac50c17b
2 changed files with 9 additions and 23 deletions

View File

@ -35,21 +35,24 @@ let
boot.initrd.kernelModules = [ "virtiofs" ];
virtualisation.writableStore = false;
virtualisation.fileSystems = lib.mkForce ({
"/" = {
device = "/dev/disk/by-label/nixos";
fsType = "ext4";
options = [ "defaults" "x-systemd.makefs" ];
};
"/nix/store" = {
device = "nix-store";
options = [ "x-systemd.requires=systemd-modules-load.service" ];
fsType = "virtiofs";
};
"/" = {
device = "/dev/vda";
fsType = "ext4";
noCheck = true;
options = [ "defaults" "x-systemd.makefs" ];
};
"/vmstate" = {
device = "/dev/vdb";
options = ["x-systemd.makefs"];
options = [ "x-systemd.makefs" ];
noCheck = true;
fsType = "ext4";
};
${config.clanCore.secretsUploadDirectory} = {

View File

@ -194,7 +194,6 @@ def prepare_disk(
directory: Path,
disk_format: str = "raw",
size: str = "1024M",
label: str = "nixos",
file_name: str = "disk.img",
) -> Path:
disk_img = directory / file_name
@ -215,21 +214,6 @@ def prepare_disk(
error_msg=f"Could not create disk image at {disk_img}",
)
if disk_format == "raw":
cmd = nix_shell(
["nixpkgs#e2fsprogs"],
[
"mkfs.ext4",
"-L",
label,
str(disk_img),
],
)
run(
cmd,
log=Log.BOTH,
error_msg=f"Could not create ext4 filesystem at {disk_img}",
)
return disk_img
@ -357,7 +341,6 @@ def run_vm(vm: VmConfig, nix_options: list[str] = []) -> None:
file_name="state.qcow2",
disk_format="qcow2",
size="50G",
label="state",
)
virtiofsd_socket = Path(sockets) / "virtiofsd.sock"
qemu_cmd = qemu_command(