1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
;;; 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))))