From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: [PATCH] DISCUSSION: Jookia's Libreboot+LUKS+LVM FDE patch. Date: Tue, 15 Mar 2016 15:40:46 +0100 Message-ID: <87r3fbpzwx.fsf@gnu.org> References: <56e0c4cf.08d0190a.6a127.0d35@mx.google.com> <87r3fitiu6.fsf@gnu.org> <20160310211149.GA17073@novena-choice-citizen.lan> <871t7h140d.fsf@gnu.org> <20160311164236.GB28593@novena-choice-citizen.lan> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51376) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1afq9U-0001CE-Hk for guix-devel@gnu.org; Tue, 15 Mar 2016 10:40:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1afq9R-0000E7-6m for guix-devel@gnu.org; Tue, 15 Mar 2016 10:40:52 -0400 In-Reply-To: <20160311164236.GB28593@novena-choice-citizen.lan> (Jookia's message of "Sat, 12 Mar 2016 03:42:36 +1100") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: Jookia <166291@gmail.com> Cc: guix-devel@gnu.org Jookia <166291@gmail.com> skribis: > On Fri, Mar 11, 2016 at 03:30:10PM +0100, Ludovic Court=C3=A8s wrote: >> Jookia <166291@gmail.com> skribis: >>=20 >> > I'd really like to discuss how much I needed to break to get the mappe= d-devices, >> > file-systems and swap-devices to just 'work'. I even had to make a fun= ction to >> > return a mapped-device type, and have swap-devices not do dependency t= ests since >> > I technically don't use a device I've defined. >> > >> > It'd be much much better if I could do something like this in my servi= ces: >> > >> > (devices (list (file-system >> > (uses '("/dev/matrix/root")) >> > (creates '("/")) >> > (device "/dev/matrix/root") >> > (mount-point "/") >> > (type "ext4")) >> > (swap-device >> > (uses '("/dev/mapper/matrix-swap")) >> > (creates '())) >> > (device "/dev/mapper/matrix-swap") >> > (lvm-device >> > (uses '("/dev/mapper/hdd" "/dev/sdb")) >> > (creates '("/dev/matrix/" >> > "/dev/mapper/matrix-swap")) >> > (devices '("/dev/mapper/hdd" "/dev/sdb"))) >> > (luks-device >> > (uses '("UUID=3D4dab5feb-d176-45de-b287-9b0a6e4c01c= b")) >> > (creates '("/dev/mapper/hdd")) >> > (device "UUID=3D4dab5feb-d176-45de-b287-9b0a6e4c01c= b") >> > (name "hdd") >> > (key-file "...")))) >> > >> > The issue is that it has a lot of duplicate information as I'm not sure >> > uses/creates could always map to device/mount-point, like LUKS names. = But this >> > should satisfy most dependency issues automatically, I hope. >>=20 >> There are several issues being addressed here, IIUC: >>=20 >> 1. How to refer to block devices (in the Unix sense) using UUIDs, >> labels, or /dev file names in general, and not just for >> =E2=80=98file-system=E2=80=99. > > Yes, this is one of the major problems. > >> 2. How to determine dependencies among all these things. > > Shouldn't be too hard if we have inputs and outputs for each. > >> 3. How to handle mapped devices that lead to several /dev nodes, as is >> the case with LVM. > > Well, it's a bit more complex than that. We end up with filesystems that = use > multiple devices too, like Btrfs. OK. Would a =E2=80=98mapped-device=E2=80=99 type where both =E2=80=98source=E2= =80=99 and =E2=80=98target=E2=80=99 are lists adequately model Linux=E2=80=99s notion of mapped devices? > I was also showing another point: It'd be nicer to have file-system, > swap-device, lvm-device, luks-device as functions rather than data struct= ures. > I was a bit tired when writing and realized later on that the functions c= ould > automatically create the uses/creates stuff as output. I'll show another > hypothetical, though I see interest in keeping the existing way. Keeping thing purely declarative, with high-level data structures such as =E2=80=98file-system=E2=80=99 and =E2=80=98mapped-device=E2=80=99 is pre= tty nice IMO. It allows users to easily inspect the config, map over the various bits, etc. >> For #1, I would like to have a general =E2=80=98device=E2=80=99 type, so= one could >> write: >>=20 >> (operating-system >> ;; =E2=80=A6 >> (file-systems (list (file-system >> (source (device (title 'label) >> (name "my-root"))) >> (mount-point "/")))) >> (swap (list (device >> (title 'uuid) >> (name (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb"))))) >>=20 >> For that to work, we ideally need code to recognize swap signatures, >> similar to what we do for ext2 in (gnu build file-systems). > > This would work, but not all file-systems use devices. Bind/union mounts,= for > one, which is why having them as paths would be perhaps easier to resolve= . I'm > skeptical we could have a single file-system data structure that could ac= count > for all this, Note that it already handles bind mounts and other pseudo file systems (see (gnu system file-systems)). Basically, =E2=80=98file-system=E2=80=99 = directly corresponds to the =E2=80=98mount=E2=80=99 system call. > which is why I'd much rather like functions that output stuff: > > (devices (list (file-system > #:device "/dev/matrix/root" > #:mount-point "/" > #:type "ext4") > (swap-device > #:device "/dev/mapper/matrix-swap") > (lvm-device > #:targets '("/dev/matrix/" > "/dev/mapper/matrix-swap") > #:devices (list "/dev/mapper/hdd" "/dev/sdb")) > (luks-device > #:device "UUID=3D4dab5feb-d176-45de-b287-9b0a6e4c01cb" > #:name "hdd" > #:key-file "..."))) > > which could output this tree: > > (devices (list (device > (uses '("/dev/matrix/root")) > (creates '("/")) > (init-function ...) > (destroy-function ...)) > (swap-device > (uses '("/dev/mapper/matrix-swap")) > (creates '())) > (init-function ...) > (destroy-function ...)) > (lvm-device > (uses '("/dev/mapper/hdd" "/dev/sdb")) > (creates '("/dev/matrix/" > "/dev/mapper/matrix-swap")) > (init-function ...) > (destroy-function ...)) > (luks-device > (uses '("UUID=3D4dab5feb-d176-45de-b287-9b0a6e4c01cb")) > (creates '("/dev/mapper/hdd")) > (init-function ...) > (destroy-function ...))) > > Though this is a bit of a dream in my case. Hmm it seems to me that these are roughly to different ways to write the same thing (with the 2nd one making dependencies explicit.) I=E2=80=99m not sure there=E2=80=99s an intermediate representation that fi= le systems, swap devices, LVM devices, etc. could all be =E2=80=9Ccompiled=E2=80=9D to.= I feel that we should stick to the abstractions of the Linux kernel, where device mapping is entirely different from file systems, and so on. However, we must definitely unify device naming (the /dev vs. UUID vs. label thing.) > There also a small issue where mapped devices need more data in special c= ases, > like LUKS keyfiles which returns a function to create the type. What? :-) Thanks for your insightful comments! Ludo=E2=80=99.