;;; Test for Guix System with root on LVM ;;; Copyright © 2025 (define-module (ruther tests lvm) #:use-module (gnu bootloader) #:use-module (gnu bootloader grub) #:use-module (gnu build marionette) #:use-module (gnu packages firmware) #:use-module (gnu packages virtualization) #:use-module (gnu services) #:use-module (gnu services base) #:use-module (gnu system) #:use-module (gnu system file-systems) #:use-module (gnu system mapped-devices) #:use-module (gnu system shadow) #:use-module (gnu system vm) #:use-module (gnu tests) #:use-module (gnu tests base) #:use-module (guix gexp) #:use-module (ruthless image) #:export (%test-root-lvm)) ;;; ;;; OS definition with root on LVM ;;; (define %lvm-root-os ;; Operating system with root filesystem on LVM. ;; Uses vg0/root as the root logical volume. (operating-system (host-name "lvmroot") (timezone "Europe/Berlin") (locale "en_US.UTF-8") (bootloader (bootloader-configuration (bootloader grub-efi-removable-bootloader) (targets '("/boot/efi")) (terminal-outputs '(console)))) (kernel-arguments '("console=ttyS0")) (mapped-devices (list (mapped-device (source "vg0") (targets '("vg0-root")) (type lvm-device-mapping)))) (file-systems (cons* (file-system (device "/dev/mapper/vg0-root") (mount-point "/") (type "ext4") (dependencies mapped-devices)) (file-system (device (file-system-label "ESP")) (mount-point "/boot/efi") (type "vfat")) %base-file-systems)) (users (cons (user-account (name "alice") (group "users") (supplementary-groups '("wheel"))) %base-user-accounts)) (services %base-services))) ;;; ;;; Test execution ;;; (define (run-lvm-root-test) "Run the basic test suite on an OS with root on LVM." (define os (marionette-operating-system %lvm-root-os #:imported-modules '((gnu services herd) (guix combinators)))) ;; Use the generic disk image builder with LVM initializer (define image (build-disk-image os #:disk-initializer lvm-disk-initializer #:disk-size (* 2048 1024 1024) ; 2 GiB #:uefi? #t #:name "lvm-root-image")) (define vm-command #~(list (string-append #$qemu-minimal "/bin/" #$(qemu-command)) "-m" "512" "-bios" #$(file-append ovmf-x86-64 "/share/firmware/ovmf_x64.bin") "-drive" (string-append "file=" #$image ",format=qcow2,if=virtio") "-snapshot" ; Use snapshot mode since image is in read-only store "-no-reboot" #$@(if (file-exists? "/dev/kvm") '("-enable-kvm") '()) "-nographic")) (run-basic-test os vm-command "lvm-root")) ;;; ;;; System test definition ;;; (define %test-root-lvm (system-test (name "lvm-root") (description "Test basic functionality of a Guix System with root on LVM.") (value (run-lvm-root-test))))