From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id wIjRFz+Qr2P4GQEAbAwnHQ (envelope-from ) for ; Sat, 31 Dec 2022 02:28:31 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id sHPUFj+Qr2OJQAAAG6o9tA (envelope-from ) for ; Sat, 31 Dec 2022 02:28:31 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id EF65A203E0 for ; Sat, 31 Dec 2022 02:28:30 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pBQfN-0007ne-WE; Fri, 30 Dec 2022 20:28:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pBQfL-0007nR-KD for guix-patches@gnu.org; Fri, 30 Dec 2022 20:28:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pBQfL-00045W-2Z for guix-patches@gnu.org; Fri, 30 Dec 2022 20:28:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pBQfK-0001HQ-Fd for guix-patches@gnu.org; Fri, 30 Dec 2022 20:28:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#60442] [PATCH] bootloader: grub: Add support for root on lvm. Resent-From: Michael Rohleder Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 31 Dec 2022 01:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 60442 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 60442@debbugs.gnu.org Cc: Michael Rohleder X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16724500414869 (code B ref -1); Sat, 31 Dec 2022 01:28:02 +0000 Received: (at submit) by debbugs.gnu.org; 31 Dec 2022 01:27:21 +0000 Received: from localhost ([127.0.0.1]:36311 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pBQee-0001GR-Al for submit@debbugs.gnu.org; Fri, 30 Dec 2022 20:27:20 -0500 Received: from lists.gnu.org ([209.51.188.17]:43092) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pBQec-0001GJ-66 for submit@debbugs.gnu.org; Fri, 30 Dec 2022 20:27:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pBQeb-0007kY-4U for guix-patches@gnu.org; Fri, 30 Dec 2022 20:27:17 -0500 Received: from sxb1nlsmtp02.prod.sxb1.secureserver.net ([92.204.71.190]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pBQeY-0003wL-9x for guix-patches@gnu.org; Fri, 30 Dec 2022 20:27:16 -0500 Received: from 122.164.205.92.host.secureserver.net ([92.205.164.122]) by : HOSTING RELAY : with ESMTP id BQdTpVZeH3oQVBQdUpFyP5; Fri, 30 Dec 2022 18:26:08 -0700 X-SECURESERVER-ACCT: 92.205.164.122 x-originating-ip: 92.205.164.122 X-CMAE-Analysis: v=2.4 cv=SfYxNNdu c=1 sm=1 tr=0 ts=63af8fb0 a=B/z3iHJ5y0TSvJOmeNZOnw==:117 a=IkcTkHD0fZMA:10 a=sHyYjHe8cH0A:10 a=mDV3o1hIAAAA:8 a=TBl5w1EdAAAA:8 a=dPDPl_EnAAAA:8 a=AdZ5fGlyAAAA:8 a=pGLkceISAAAA:8 a=_he-KxU42j6O13qn8SUA:9 a=QEXdDO2ut3YA:10 a=_FVE-zBwftR9WsbkzFJk:22 a=5WwPNqJOUSiJ-goaxTcI:22 a=bd0dmHXOa7EyMKz6Wi46:22 a=KE2k9AvrBXY8Rl8PC8rS:22 Received: from [192.168.1.3] (helo=micha.rohleder.de) by 122.164.205.92.host.secureserver.net with esmtp (Exim 4.94.2) (envelope-from ) id 1pBQdT-006USN-37; Sat, 31 Dec 2022 02:26:07 +0100 From: Michael Rohleder Date: Sat, 31 Dec 2022 02:25:11 +0100 Message-Id: <20221231012511.5031-1-mike@rohleder.de> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-CMAE-Envelope: MS4xfHmEW3T7gXAStLVQ2Ghn4ASQPmGkYQV/fjEpF4illE787ZoL1+bx9glPh6IxuM958/YJTFR7ErG/8xPSAOf7P/QAHYyGadbc19qAO+2I++MoVO/qCaHr DbkfBysqdNkQQsbIxjGoe0Nnzr42Fyfn+662nkg8Yz9KR21Y0lEiPWH9r+RZlGoKhSFahNpmk0XfVD16G7z4+jk5UYsk3l4dBRGoHCCuv0k3XN8oU1xZxjMr da6p1J+SgGoSZQBzNGmKCQ== Received-SPF: permerror client-ip=92.204.71.190; envelope-from=mike@rohleder.de; helo=sxb1nlsmtp02.prod.sxb1.secureserver.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, T_SPF_PERMERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1672450111; a=rsa-sha256; cv=none; b=Lm95fzbW6rPKOFZdBfz3oHEoV7E+iEN7PuNaXEfLk15moYTgLyI6eCz9akqHETljLJ0xXF b5+2Jq+1w75fWDq28M1ngIzq6pPTzacFDZk0c8OHQT0CYIyVKX2Z/4V0YznuqEmlneRSe/ kQYul4hC5G2V8v9+AK2k2+PX3Vl/miD3yK/YeXX6U23ki2dfH9cbVu3OU8h+GiqFg7Hnnt b5UtgH1jPJ3dfWvU4uvTZ3oz8WGvGpQW9norCncwc+J9Pn7PkuIAWOg8WWDNyz+e5rYz1V g+YzzeJpvQOCi3zZCr0XKH4Hfq3jYyCvfCpbEPfWyX4PG/mbUCQ/jyqNfrn/3A== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1672450111; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=/uIyq0IfVggiPjpF83gKO/e3E4IEN1hbe5l5Um7WHB4=; b=rloTIaa9zOas5UqlosbQzdcYBrjBTPGV1FyZI5Z/Y7mds5AkEwHdqEQWRNyBF5POzIHMzg 0Ep/XmoEr/jTjud5knH9FNvL9eYeLiOIhvAQAZik+ZpQd1qIVv1Jnwo2QsD5uG7YWHcxjH mhyngevjCNjiOUd8aSRBW44nZLcpSg+TLXWxii1W0LhBc/otYYnqDxQ5m9ITLd9LuJyllI KONm1hGSoh7fYqJTQh1f34E6IVWnlj+JryLYh7Vv31QedGzM4O7IGdnHjrgglKwbBcy0iq 3MRaxW8rNftNVhWXxGTA4Vg88AILlNp6BhaRChzaBXFGU8KwX5t9vajHbRC4Ig== X-Spam-Score: -2.04 X-Migadu-Queue-Id: EF65A203E0 Authentication-Results: aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=none X-Migadu-Scanner: scn0.migadu.com X-Migadu-Spam-Score: -2.04 X-TUID: SlJyYF0nXHFY This fixes . * gnu/bootloader/grub.scm (install-grub) (install-grub-efi) (install-grub-efi-removable) (install-grub-efi32): Add setting GRUB_PRELOAD_MODULES to lvm. * gnu/tests/install.scm (test-lvm-root-os): New variable. --- gnu/bootloader/grub.scm | 9 +++++ gnu/tests/install.scm | 81 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 89 insertions(+), 1 deletion(-) diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm index ecd44e7f3c..1e2d142452 100644 --- a/gnu/bootloader/grub.scm +++ b/gnu/bootloader/grub.scm @@ -9,6 +9,7 @@ ;;; Copyright © 2020 Stefan ;;; Copyright © 2022 Karl Hallsby ;;; Copyright © 2022 Denis 'GNUtoo' Carikli +;;; Copyright © 2022 Michael Rohleder ;;; ;;; This file is part of GNU Guix. ;;; @@ -557,6 +558,8 @@ (define install-grub ;; Tell 'grub-install' that there might be a LUKS-encrypted ;; /boot or root partition. (setenv "GRUB_ENABLE_CRYPTODISK" "y") + ;; Let us boot from lvm + (setenv "GRUB_PRELOAD_MODULES" "lvm") ;; Hide potentially confusing messages from the user, such as ;; "Installing for i386-pc platform." @@ -629,6 +632,8 @@ (define install-grub-efi ;; Tell 'grub-install' that there might be a LUKS-encrypted /boot or ;; root partition. (setenv "GRUB_ENABLE_CRYPTODISK" "y") + ;; Let us boot from lvm + (setenv "GRUB_PRELOAD_MODULES" "lvm") (invoke/quiet grub-install "--boot-directory" install-dir "--bootloader-id=Guix" "--efi-directory" target-esp))))) @@ -652,6 +657,8 @@ (define install-grub-efi-removable ;; Tell 'grub-install' that there might be a LUKS-encrypted /boot or ;; root partition. (setenv "GRUB_ENABLE_CRYPTODISK" "y") + ;; Let us boot from lvm + (setenv "GRUB_PRELOAD_MODULES" "lvm") (invoke/quiet grub-install "--boot-directory" install-dir "--removable" ;; "--no-nvram" @@ -675,6 +682,8 @@ (define install-grub-efi32 ;; Tell 'grub-install' that there might be a LUKS-encrypted /boot or ;; root partition. (setenv "GRUB_ENABLE_CRYPTODISK" "y") + ;; Let us boot from lvm + (setenv "GRUB_PRELOAD_MODULES" "lvm") (invoke/quiet grub-install "--boot-directory" install-dir "--bootloader-id=Guix" (cond ((target-x86?) "--target=i386-efi") diff --git a/gnu/tests/install.scm b/gnu/tests/install.scm index 4e0e274e66..f9d34c1e28 100644 --- a/gnu/tests/install.scm +++ b/gnu/tests/install.scm @@ -5,6 +5,7 @@ ;;; Copyright © 2020 Danny Milosavljevic ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen ;;; Copyright © 2020, 2021, 2022 Maxim Cournoyer +;;; Copyright © 2022 Michael Rohleder ;;; ;;; This file is part of GNU Guix. ;;; @@ -76,6 +77,7 @@ (define-module (gnu tests install) %test-jfs-root-os %test-f2fs-root-os %test-xfs-root-os + %test-lvm-root-os %test-lvm-separate-home-os %test-gui-installed-os @@ -831,7 +833,6 @@ (define %test-encrypted-root-os ;;; Separate /home on LVM ;;; -;; Since LVM support in guix currently doesn't allow root-on-LVM we use /home on LVM (define-os-with-source (%lvm-separate-home-os %lvm-separate-home-os-source) (use-modules (gnu) (gnu tests)) @@ -913,6 +914,84 @@ (define %test-lvm-separate-home-os `(,@command) "lvm-separate-home-os"))))) + +;;; +;;; LVM root device. +;;; + +(define-os-with-source (%lvm-root-os %lvm-root-os-source) + (use-modules (gnu) (gnu tests)) + + (operating-system + (host-name "root-os-on-lvm") + (timezone "Europe/Paris") + (locale "en_US.utf8") + + (bootloader (bootloader-configuration + (bootloader grub-bootloader) + (targets (list "/dev/vdb")))) + (kernel-arguments '("console=ttyS0")) + + (mapped-devices (list (mapped-device + (source "vg0") + (target "vg0-root") + (type lvm-device-mapping)))) + (file-systems (cons* (file-system + (device "/dev/mapper/vg0-root") + (mount-point "/") + (type "ext4") + (dependencies mapped-devices)) + %base-file-systems)) + (users %base-user-accounts) + (services (cons (service marionette-service-type + (marionette-configuration + (imported-modules '((gnu services herd) + (guix combinators))))) + %base-services)))) + +(define %lvm-root-os-installation-script + "\ +. /etc/profile +set -e -x +guix --version + +export GUIX_BUILD_OPTIONS=--no-grafts +parted --script /dev/vdb mklabel gpt \\ + mkpart primary ext2 1M 3M \\ + mkpart primary 3M 1.7G \\ + set 1 boot on \\ + set 1 bios_grub on +pvcreate /dev/vdb2 +vgcreate vg0 /dev/vdb2 +lvcreate -l 100%FREE -n root vg0 +vgchange -ay +mkfs.ext4 -L root-fs /dev/mapper/vg0-root +mount /dev/mapper/vg0-root /mnt +herd start cow-store /mnt +mkdir /mnt/etc +cp /etc/target-config.scm /mnt/etc/config.scm +guix system init /mnt/etc/config.scm /mnt --no-substitutes +sync +reboot\n") + +(define %test-lvm-root-os + (system-test + (name "lvm-root-os") + (description + "Test functionality of an OS installed with a LVM / partition") + (value + (mlet* %store-monad ((image (run-install %lvm-root-os + %lvm-root-os-source + #:script + %lvm-root-os-installation-script + #:packages (list lvm2-static))) + (command (qemu-command* image + #:memory-size 512))) + (run-basic-test %lvm-root-os + `(,@command) "lvm-root-os"))))) + + + ;;; ;;; LUKS-encrypted /home, unencrypted root. ;;; -- 2.38.1