From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id OD7ACppedl/8QAAA0tVLHw (envelope-from ) for ; Thu, 01 Oct 2020 22:56:26 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id ON5qBppedl98XAAAB5/wlQ (envelope-from ) for ; Thu, 01 Oct 2020 22:56:26 +0000 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 9AB119402B1 for ; Thu, 1 Oct 2020 22:56:25 +0000 (UTC) Received: from localhost ([::1]:43318 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kO7Ut-0001GH-HD for larch@yhetil.org; Thu, 01 Oct 2020 18:56:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49898) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kO7UY-0001Eu-WB for guix-patches@gnu.org; Thu, 01 Oct 2020 18:56:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:55388) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kO7UY-0002r9-MI for guix-patches@gnu.org; Thu, 01 Oct 2020 18:56:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kO7UY-0001tP-M3 for guix-patches@gnu.org; Thu, 01 Oct 2020 18:56:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#41143] [PATCH v2 2/2] mapped-devices: Add 'lvm-device-mapping'. Resent-From: Mikhail Tsykalov Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 01 Oct 2020 22:56:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41143 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: ludo@gnu.org Cc: 41143@debbugs.gnu.org, Mikhail Tsykalov Received: via spool by 41143-submit@debbugs.gnu.org id=B41143.16015929217220 (code B ref 41143); Thu, 01 Oct 2020 22:56:02 +0000 Received: (at 41143) by debbugs.gnu.org; 1 Oct 2020 22:55:21 +0000 Received: from localhost ([127.0.0.1]:38700 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kO7Tt-0001sO-Cl for submit@debbugs.gnu.org; Thu, 01 Oct 2020 18:55:21 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:37106) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kO7Tr-0001rx-Ha for 41143@debbugs.gnu.org; Thu, 01 Oct 2020 18:55:20 -0400 Received: by mail-lj1-f196.google.com with SMTP id n25so244226ljj.4 for <41143@debbugs.gnu.org>; Thu, 01 Oct 2020 15:55:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EzzJoW38mrHAJcbDTO+pguDrvkrr2cfTztT1WG67MdY=; b=VV5upk4QG0caFQlCyzNT2WKjxg1PSxH9PjYlRm3z82PjclMc9tKlcDJ6muI3qBNxQs Oh6/8o1HoVbQ3uCIoY5FlUo61AOiZW6zijkFMFmPTFlxZtNSkKNYAHtVjpy/x42s++P5 9kZRk6EgoL71S4sei8lwlhLdrTp7wrTmMpAqBN/eJRZEhrNfBtTCp2R+IO1wJAyq8OvQ lAKOe3rL24QCti7LhLvSD7QY6iVpnSrOKaiggyj4CV5E9xRm2gAFc+PRyt07zqUMX4vc Ex+9rzhtCgl5oztRE4kNWPP3+OPqWX+Ktz6HldUxXN1EnxGecPxkEa77srC0iULr3c/g 9IAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EzzJoW38mrHAJcbDTO+pguDrvkrr2cfTztT1WG67MdY=; b=cVeeb44sAAgjb5B/7/PgUwfVFHrBL8yZNUg1rOnA5DliJMQxqi8rwfW4locvwd1ljy 3D2B9LoJ6YicDV+z6eSftWRE1M9n5jBtXcCsl260rOhE1UWCUMOj4bTWUAnIhSFo8iv8 +vuY/hrivKOVx0dpCKA6XcRXPTe0ZupVq2yIKIT/5n4bw+fsLfIbeaWTeUI4z3i6sTSJ 01tksEwHoAGGNeI+RA9nfft4YX9PeuOPugY/MYfQ5bAeAWDqsRXMMZ8ylC765VqQUY2Q ESccoXnljrhbY5w6R/A52Fja7FhAkanND6d8yVljNfok4DpzrFTcnJSYNgxugc9n6jer pZgw== X-Gm-Message-State: AOAM530PHGaaLmIltC2drjnzhJs6xzT19N8tKvClfWfZ5BIkuvl4Tks0 NNX86+U4UFlcstqVGIb4Bjo= X-Google-Smtp-Source: ABdhPJyEBd+JEjxKK8B1iWjbqCxrcU1dYGcHpHEjm19OIOC2zvY+cGqe8tmty+XeImVJoGmZp2uyjQ== X-Received: by 2002:a2e:8e30:: with SMTP id r16mr3276478ljk.304.1601592913489; Thu, 01 Oct 2020 15:55:13 -0700 (PDT) Received: from localhost.localdomain ([88.201.200.148]) by smtp.googlemail.com with ESMTPSA id 68sm748795lfe.27.2020.10.01.15.55.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 15:55:13 -0700 (PDT) From: Mikhail Tsykalov Date: Fri, 2 Oct 2020 01:49:00 +0300 Message-Id: <20201001224900.28989-2-tsymsh@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201001224900.28989-1-tsymsh@gmail.com> References: <87pn69j09o.fsf@gnu.org> <20201001224900.28989-1-tsymsh@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -1.0 (-) 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" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=fail (body hash did not verify) header.d=gmail.com header.s=20161025 header.b=VV5upk4Q; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Spam-Score: 5.09 X-TUID: 7e9bz2MGAvX9 * gnu/system/mapped-devices.scm (lvm-device-mapping, open-lvm-device, close-lvm-device): New variables. * gnu/tests/install.scm (%lvm-separate-home-os, %lvm-separate-home-os-source, %lvm-separate-home-installation-script, %test-lvm-separate-home-os): New variables. * gnu/system/linux-initrd.scm (raw-initrd): Add (srfi srfi-1) to initrd expression. --- gnu/system/linux-initrd.scm | 1 + gnu/system/mapped-devices.scm | 25 +++++++++- gnu/tests/install.scm | 87 +++++++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+), 2 deletions(-) diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm index db02059a26..41cbe28c3c 100644 --- a/gnu/system/linux-initrd.scm +++ b/gnu/system/linux-initrd.scm @@ -217,6 +217,7 @@ upon error." (gnu system file-systems) ((guix build utils) #:hide (delete)) (guix build bournish) ;add the 'bournish' meta-command + (srfi srfi-1) (srfi srfi-26) ;; FIXME: The following modules are for diff --git a/gnu/system/mapped-devices.scm b/gnu/system/mapped-devices.scm index 8622418fcf..8088bd99a3 100644 --- a/gnu/system/mapped-devices.scm +++ b/gnu/system/mapped-devices.scm @@ -36,7 +36,7 @@ #:autoload (gnu build linux-modules) (missing-modules) #:autoload (gnu packages cryptsetup) (cryptsetup-static) - #:autoload (gnu packages linux) (mdadm-static) + #:autoload (gnu packages linux) (mdadm-static lvm2-static) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) #:use-module (srfi srfi-34) @@ -64,7 +64,8 @@ check-device-initrd-modules ;XXX: needs a better place luks-device-mapping - raid-device-mapping)) + raid-device-mapping + lvm-device-mapping)) ;;; Commentary: ;;; @@ -296,4 +297,24 @@ TARGET (e.g., \"/dev/md0\"), using 'mdadm'." (open open-raid-device) (close close-raid-device))) +(define (open-lvm-device source targets) + #~(and + (zero? (system* #$(file-append lvm2-static "/sbin/lvm") + "vgchange" "--activate" "ay" #$source)) + ; /dev/mapper nodes are usually created by udev, but udev may be unavailable at the time we run this. So we create them here. + (zero? (system* #$(file-append lvm2-static "/sbin/lvm") + "vgscan" "--mknodes")) + (every file-exists? (map (lambda (file) (string-append "/dev/mapper/" file)) + '#$targets)))) + + +(define (close-lvm-device source targets) + #~(zero? (system* #$(file-append lvm2-static "/sbin/lvm") + "vgchange" "--activate" "n" #$source))) + +(define lvm-device-mapping + (mapped-device-kind + (open open-lvm-device) + (close close-lvm-device))) + ;;; mapped-devices.scm ends here diff --git a/gnu/tests/install.scm b/gnu/tests/install.scm index dee2b870e8..84fe8bda78 100644 --- a/gnu/tests/install.scm +++ b/gnu/tests/install.scm @@ -65,6 +65,7 @@ %test-btrfs-root-on-subvolume-os %test-jfs-root-os %test-f2fs-root-os + %test-lvm-separate-home-os %test-gui-installed-os %test-gui-installed-os-encrypted @@ -794,6 +795,92 @@ build (current-guix) and then store a couple of full system images.") (run-basic-test %encrypted-root-os command "encrypted-root-os" #:initialization enter-luks-passphrase))))) + +;;; +;;; 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)) + + (operating-system + (host-name "separate-home-on-lvm") + (timezone "Europe/Paris") + (locale "en_US.utf8") + + (bootloader (bootloader-configuration + (bootloader grub-bootloader) + (target "/dev/vdb"))) + (kernel-arguments '("console=ttyS0")) + + (mapped-devices (list (mapped-device + (source "vg0") + (target "vg0-home") + (type lvm-device-mapping)))) + (file-systems (cons* (file-system + (device (file-system-label "root-fs")) + (mount-point "/") + (type "ext4")) + (file-system + (device "/dev/mapper/vg0-home") + (mount-point "/home") + (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-separate-home-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 ext2 3M 1.6G \\ + mkpart primary 1.6G 3.2G \\ + set 1 boot on \\ + set 1 bios_grub on +pvcreate /dev/vdb3 +vgcreate vg0 /dev/vdb3 +lvcreate -L 1.6G -n home vg0 +vgchange -ay +mkfs.ext4 -L root-fs /dev/vdb2 +mkfs.ext4 /dev/mapper/vg0-home +mount /dev/vdb2 /mnt +mkdir /mnt/home +mount /dev/mapper/vg0-home /mnt/home +df -h /mnt /mnt/home +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-separate-home-os + (system-test + (name "lvm-separate-home-os") + (description + "Test functionality of an OS installed with a LVM /home partition") + (value + (mlet* %store-monad ((image (run-install %lvm-separate-home-os + %lvm-separate-home-os-source + #:script + %lvm-separate-home-installation-script + #:packages (list lvm2-static) + #:target-size (* 3200 MiB))) + (command (qemu-command/writable-image image))) + (run-basic-test %lvm-separate-home-os + `(,@command) "lvm-separate-home-os"))))) + ;;; ;;; Btrfs root file system. -- 2.28.0