From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?utf-8?B?VG9tw6HFoSDEjGVjaA==?= Subject: Re: LVM support Date: Fri, 1 May 2015 13:32:30 +0200 Message-ID: <20150501113230.GA1818@venom> References: <20150415050756.GC6648@venom> <878udt1sj5.fsf@gnu.org> <20150416062401.GD6648@venom> <87twwgxmrr.fsf@gnu.org> <20150417010911.GA610@venom> <87h9s9h41q.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="T4sUOijqQbZv57TR" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51672) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yo9BO-000878-RP for guix-devel@gnu.org; Fri, 01 May 2015 07:32:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yo9BL-0002gh-Ji for guix-devel@gnu.org; Fri, 01 May 2015 07:32:38 -0400 Received: from cantor2.suse.de ([195.135.220.15]:38908 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yo9BL-0002g1-A5 for guix-devel@gnu.org; Fri, 01 May 2015 07:32:35 -0400 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 07B64AD08 for ; Fri, 1 May 2015 11:32:33 +0000 (UTC) Content-Disposition: inline In-Reply-To: <87h9s9h41q.fsf@gnu.org> 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: guix-devel@gnu.org --T4sUOijqQbZv57TR Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Apr 21, 2015 at 05:52:33PM +0200, Ludovic Court=C3=A8s wrote: >Tom=C3=A1=C5=A1 =C4=8Cech skribis: > >> On Thu, Apr 16, 2015 at 02:47:52PM +0200, Ludovic Court=C3=A8s wrote: >>>Tom=C3=A1=C5=A1 =C4=8Cech skribis: >>> >>>> On Wed, Apr 15, 2015 at 02:32:14PM +0200, Ludovic Court=C3=A8s wrote: >>> >>>[...] >>> >>>>>Sorry I=E2=80=99m not really familiar with LVM. >>>> >>>> It's implemented using device mapper but instead of mapping one block >>>> device to another you map one block device to whole group (like >>>> playground where you can do anything). >>> >>>What do you mean by =E2=80=9Cwhole group=E2=80=9D? A tree under /dev/ma= pper? >> >> From device node POV it generates >> /dev// and it also creates >> /dev/mapper/- and >> /dev/dm-. > >OK. > >> From block device perspective it adds another level of "partitioning" >> to "physical volume" partitions. You gather block devices (can be >> partitions, disks, anything), create volume group to join the space >> into one entity and then create logical volumes without caring where >> it really is. Logical volumes are useful for resizing, adding and >> removing filesystems - it has always the same device node. > >Yes, that part I knew. ;-) > > >[...] > >> --- a/gnu/system.scm >> +++ b/gnu/system.scm >> @@ -41,6 +41,7 @@ >> #:use-module (gnu packages compression) >> #:use-module (gnu packages firmware) >> #:autoload (gnu packages cryptsetup) (cryptsetup) >> + #:autoload (gnu packages linux) (lvm2/static) >> #:use-module (gnu services) >> #:use-module (gnu services dmd) >> #:use-module (gnu services base) >> @@ -86,7 +87,9 @@ >> %base-packages >> %base-firmware >> >> - luks-device-mapping)) >> + luks-device-mapping >> + lvm-mapping >> + lvm-mapping-used?)) >> >> ;;; Commentary: >> ;;; >> @@ -208,6 +211,27 @@ file." >> (open open-luks-device) >> (close close-luks-device))) >> >> +(define (logical-volume-group-activate source target) >> + #~(zero? (system* (string-append #$lvm2/static "/sbin/lvm.static") >> + "vgchange" "--activate" "y" #$target))) >> + >> +(define (logical-volume-group-deactivate source target) >> + #~(zero? (system* (string-append #$lvm2/static "/sbin/lvm.static") >> + "vgchange" "--activate" "n" #$target))) >> + >> +(define (lvm-mapping-used? devices) >> + (not >> + (null? (filter >> + (lambda (md) >> + (eq? (mapped-device-type md) >> + lvm-mapping)) >> + devices)))) >> + >> +(define lvm-mapping >> + (mapped-device-kind >> + (open logical-volume-group-activate) >> + (close logical-volume-group-deactivate))) > >This looks good to me! > >So I would declare > > (mapped-device > (source "/dev/sda") > (target "volume_group_name-logical_volume_name") > (kind lvm-device-mapping)) > >and that would give me >/dev/mapper/volume_group_name-logical_volume_name, right? Volume group can be on multiple block devices. For now I rely on autodetect abilities of LVM. So you would declare: (mapped-device (source "") ; irrelevant for LVM (target "volume_group_name") (type lvm-mapping)) and that would give you /dev/mapper/volume_group_name-some_volume /dev/mapper/volume_group_name-other_volume =2E.. and more conveniently /dev/volume_group_name/some_volume /dev/volume_group_name/other_volume =2E.. > >> (define (other-file-system-services os) >> "Return file system services for the file systems of OS that are not = marked >> as 'needed-for-boot'." >> @@ -267,7 +291,10 @@ from the initrd." >> (file-systems (operating-system-file-systems os))) >> (filter (lambda (md) >> (let ((user (mapped-device-user md file-systems))) >> - (and user (file-system-needed-for-boot? user)))) >> + (or >> + (and user (file-system-needed-for-boot? user)) >> + (and (eq? (mapped-device-type md) >> + lvm-mapping))))) >> devices))) > >I don=E2=80=99t think it=E2=80=99s necessary: if a =E2=80=98file-system=E2= =80=99 object has >"/dev/mapper/volume_group_name-logical_volume_name" has its =E2=80=98devic= e=E2=80=99 >field, then this device mapping will automatically be recognized as >needed-for-boot, won=E2=80=99t it? Yes, you're right, this chunk shouldn't be needed at all. Good catch! >> --- a/gnu/system/linux-initrd.scm >> +++ b/gnu/system/linux-initrd.scm >> @@ -25,6 +25,7 @@ >> #:select (%store-prefix)) >> #:use-module ((guix derivations) >> #:select (derivation->output-path)) >> + #:use-module (gnu system) >> #:use-module (gnu packages cpio) >> #:use-module (gnu packages compression) >> #:use-module (gnu packages linux) >> @@ -212,6 +213,9 @@ loaded at boot time in the order in which they appea= r." >> file-systems) >> (list e2fsck/static) >> '()) >> + ,@(if (lvm-mapping-used? mapped-devices) >> + (list lvm2/static) >> + '()) >> ,@(if volatile-root? >> (list unionfs-fuse/static) >> '()))) >> @@ -241,7 +245,19 @@ loaded at boot time in the order in which they appe= ar." >> >> (boot-system #:mounts '#$(map file-system->spec file-systems) >> #:pre-mount (lambda () >> - (and #$@device-mapping-commands)) >> + (and #$@device-mapping-commands >> + ;; If we activated any volume = group, we >> + ;; need to ensure that device = nodes are >> + ;; created. Add code here to = call it >> + ;; once for all activations. >> + #$(when (lvm-mapping-used? map= ped-devices) >> + #~(zero? >> + (system* (string-append >> + #$lvm2/static >> + "/sbin/lvm.st= atic") >> + "vgscan" >> + "--mknodes")))= )) > >So =E2=80=98lvm vgchange --activate y=E2=80=99 does not create /dev nodes? Right. >Would it be possible to change the command returned by >=E2=80=98logical-volume-group-activate=E2=80=99 to somehow create the node= s? That would >be ideal. There are two actions needed to be taken: 1] volume group activation 2] creation of nodes This design choice does as many 1] as needed and 2] once in the end. I could do always 1] and 2] for every volume group, but I didn't find it ni= ce, since previous 2] calls are useless only slowing down the process. Do you really think I should change it? Thanks for your review. S_W --T4sUOijqQbZv57TR Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iEYEARECAAYFAlVDZEwACgkQ37XrCapiVCOzxwCgx6KWe7AWVuz6NDIuzl9H7XFy j98AnizuNgWtYZMWhOnh+mO7nr3h5/Eq =qxh0 -----END PGP SIGNATURE----- --T4sUOijqQbZv57TR--