From 11ac50c17b69a303e1ed1dead7721b8e3efa7459 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Fri, 9 Feb 2024 16:50:58 +0100 Subject: [PATCH] format rootfs in vm itself --- nixosModules/clanCore/vm.nix | 15 +++++++++------ pkgs/clan-cli/clan_cli/vms/run.py | 17 ----------------- 2 files changed, 9 insertions(+), 23 deletions(-) diff --git a/nixosModules/clanCore/vm.nix b/nixosModules/clanCore/vm.nix index cf98e1725..479d23afb 100644 --- a/nixosModules/clanCore/vm.nix +++ b/nixosModules/clanCore/vm.nix @@ -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} = { diff --git a/pkgs/clan-cli/clan_cli/vms/run.py b/pkgs/clan-cli/clan_cli/vms/run.py index 36ad1868a..80bacd65f 100644 --- a/pkgs/clan-cli/clan_cli/vms/run.py +++ b/pkgs/clan-cli/clan_cli/vms/run.py @@ -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(