From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id aK3qGDWbcWVeUwEAG6o9tA:P1 (envelope-from ) for ; Thu, 07 Dec 2023 11:15:17 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id aK3qGDWbcWVeUwEAG6o9tA (envelope-from ) for ; Thu, 07 Dec 2023 11:15:17 +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 3019224C5B for ; Thu, 7 Dec 2023 11:15:17 +0100 (CET) Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b="SUdoI7/T"; spf=pass (aspmx1.migadu.com: domain of "help-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="help-guix-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=1701944117; 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:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=6Q72emmkk/QTgUteZS3euLJ75HGuzzfIS/6vGK/s1Pc=; b=n2vxf0E44Um+dbxruTQNv1AMcYIVCk6hOrmZ0IawnuXBqxlgY/vmTV8Oc2Tqd9Qt79RYH3 7rYjitqYuetyi55jQmQztlNeqAfAAQSNLsofxcqxsmRvNma8GBQxushKVSa1SJQHXjkeHJ QebEhq1ctNra7HWH2LDi4lmnLKiaFmw99IkwZJnTGWaz9gWUbbGTFJkvnipobT6FqX77A0 VhEKivMI6iZGZrctKYxVbwxz1ci2AJJkKRmTcwkJ4F4UbH6gsY5sAMwt+++OKTxJgFjLPK YVqsd7avALAACPUgOy5pXtOrBJWigcAq8oSqcB/3/xYrcoaWOz5XbkgHVTWtRg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b="SUdoI7/T"; spf=pass (aspmx1.migadu.com: domain of "help-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="help-guix-bounces+larch=yhetil.org@gnu.org"; dmarc=none ARC-Seal: i=1; s=key1; d=yhetil.org; t=1701944117; a=rsa-sha256; cv=none; b=mBTqi5LOJwv4hydhToOqjVyIAoUlnPIZrgeOOz+RW8RZAO8OIc4prrS57BK7ln/9O+33GA Q+M7wmcIsx1tCNPQCtJjyBjPyEFpC5D446ZpvhlNVOfnkSrXwLA7f47JnIK4YhW1bx+ctT uuljNxU73+11f0IgO7DyORwOH35+1OjTdcPHLCwFtzeMsiTXEW6S5Qqa1zOjySPm+Wd2YE 2sVa1XHPFmHgAybtUk0meZRicRRfXWHBZum7cU9ar3Ac/9oZIkOsxTgWIvwiskLoJ/8PZW at7kZ3qwYYn2HN58Xh4xsIax/hdct1npl2levgL0oUdU/DTpEd0njGaaHnH5Hg== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rBBOy-0001xj-As; Thu, 07 Dec 2023 05:14:40 -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 1rBBOv-0001xP-Bx for help-guix@gnu.org; Thu, 07 Dec 2023 05:14:37 -0500 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rBBOt-0006cE-34 for help-guix@gnu.org; Thu, 07 Dec 2023 05:14:37 -0500 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-40c2bb872e2so2646145e9.3 for ; Thu, 07 Dec 2023 02:14:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701944074; x=1702548874; darn=gnu.org; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:sender:from:to :cc:subject:date:message-id:reply-to; bh=6Q72emmkk/QTgUteZS3euLJ75HGuzzfIS/6vGK/s1Pc=; b=SUdoI7/TVAUsQIGWYGvHGpQutlZcPU5ewwXrdRENluUWpIFOhFZeEkTk2t5sPalECD OafzHd78ZN+HgLm6vckAici5d9QIwIsQGfSSllq7AghG229hdZ1t/HJIndK2yQ1Y+eV5 3ZkGKeco+shvRxNbmbweLFnUQ5uq9vZsrhXBkLflRdN44UlTwaJgx09rrU/qFTWSALdN RhZvjP2VTVytqmSEwuISDEvJokL4RMn6J9vhwvKx+Jibhc34w1bgJQtVeQKwBfQVaroh zuwylVnl0FY90IWqro8YjR/RX0IK6peDTjCGCXx1wp/JqCmgovW8OCQcTvC3eQE7sSWj oohA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701944074; x=1702548874; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:sender :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6Q72emmkk/QTgUteZS3euLJ75HGuzzfIS/6vGK/s1Pc=; b=UgSfPlZplgDRXOcvKnR9YsQx+Gk0aIecsT9HNaTf5Hzy7UhoFw7VujH16CsJbsr4fc AziHYIMb/LxEl0OBLbySYpBBnlKGDxGS9Q+4WuzuEGLbo2m4+QjtoM2MEJ/knlhEQ1Jj nXk1LDZa4Dbr6JhPpAPWP2716aPlzfb5QIiORJKDkp7ImVnTRFJi5a41LZ7lSBLbs1YV FeDgGS2VTFthjq4mCoMd9IDsqu2EzSJ8xts13LNFPoaMUZ5c5UNXjjZu6G69SwlO9Xe1 uMCMBRF+MLD+ylc+8rlHOQBGtV2T4kE5OzEaviSaViYmSm09205PGJoLuImbXgqSyAyk un9g== X-Gm-Message-State: AOJu0YzyhNw5TLHeFPowQQKY3ffNiG9xLK8C4VmmygeEDk15NzqTBmym UQC1RaXswpy7u8T7O3g2wP2R6G/AHoTV3Q== X-Google-Smtp-Source: AGHT+IHPAUmomO2LCnYLN/anTabbiSNmIN+RyrIXadIsDLbHNV2hOjX7VswKL433Cub1JN6/UgPMUA== X-Received: by 2002:a05:600c:19cc:b0:40c:eb7:d62d with SMTP id u12-20020a05600c19cc00b0040c0eb7d62dmr676559wmq.64.1701944073390; Thu, 07 Dec 2023 02:14:33 -0800 (PST) Received: from localhost ([188.120.129.233]) by smtp.gmail.com with ESMTPSA id fm14-20020a05600c0c0e00b0040c11fbe581sm1400545wmb.27.2023.12.07.02.14.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 02:14:32 -0800 (PST) Date: Thu, 7 Dec 2023 12:14:31 +0200 From: Efraim Flashner To: "Wicki Gabriel (wicg)" Cc: "help-guix@gnu.org" Subject: Re: Resize Filesystem Service Message-ID: Mail-Followup-To: "Wicki Gabriel (wicg)" , "help-guix@gnu.org" References: <87a5qpn2lo.fsf@lease-up.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="FPq7fVEiHSWcH2GS" Content-Disposition: inline In-Reply-To: X-PGP-Key-ID: 0x41AAE7DCCA3D8351 X-PGP-Key: https://flashner.co.il/~efraim/efraim_flashner.asc X-PGP-Fingerprint: A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=efraim.flashner@gmail.com; helo=mail-wm1-x330.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: help-guix@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-guix-bounces+larch=yhetil.org@gnu.org Sender: help-guix-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -3.75 X-Spam-Score: -3.75 X-Migadu-Queue-Id: 3019224C5B X-Migadu-Scanner: mx12.migadu.com X-TUID: QNtiWTdUjAFW --FPq7fVEiHSWcH2GS Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Dec 07, 2023 at 09:25:43AM +0000, Wicki Gabriel (wicg) wrote: > Hi >=20 > Thanks for the input, Felix. I finally managed to get it to work (with a= dditional input from ludo). I attach the service to this mail. If people = think this might be a nice-to-have in upstream guix i'll happily craft a pa= tch. >=20 > g > ________________________________ > From: Felix Lechner > Sent: Monday, December 4, 2023 9:18 PM > To: Wicki Gabriel (wicg) ; help-guix@gnu.org > Subject: Re: Resize Filesystem Service >=20 > Hi Gabriel, >=20 > On Mon, Dec 04 2023, Wicki Gabriel wrote: >=20 > > I crafted the service in the file attached but this doesn't work and i > > neither know where to look nor how to debug the issue. >=20 > Writing services is probably more complex than it should be, but it can > be done. >=20 > Please have a look at the cachefilesd-service [1] which I wrote together > with Bruno Victal (mirai) and which was accepted, or the Heimdal > Kerberos services that are still waiting for review. [2] >=20 > My most immediate suggestion is that I would use define-configuration > even when no serialization (which helps write configuration files) is > needed. Also, you have to think carefully about where to place the > G-Expressions, which can be tough to wrap your mind arround. Finally, I > would use "file-append" instead of string-append for some of the > configurable executable paths. >=20 > Kind regards > Felix >=20 > [1] https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/services/linux.sc= m#n492 > [2] https://issues.guix.gnu.org/67555 > (define-module (services resize-fs) > #:use-module (guix gexp) > #:use-module (guix records) > #:use-module (gnu packages bash) > #:use-module (gnu packages disk) ; parted > #:use-module (gnu packages linux); e2fsprogs > #:use-module (guix build utils) > #:use-module (guix packages) > #:use-module (gnu services) > #:use-module (gnu services configuration) > #:use-module (gnu services shepherd) > #:export (resize-fs-configuration > resize-fs-configuration? > resize-fs-configuration-parted > resize-fs-configuration-e2fsprogs > resize-fs-configuration-device > resize-fs-configuration-partition > resize-fs-configuration-end > resize-fs-service-type)) >=20 > (define-configuration/no-serialization resize-fs-configuration > (parted > (file-like parted) > "The parted package to use.") > (e2fsprogs > (file-like e2fsprogs) > "The e2fsprogs package providing the resize2fs utility.") > (device > (string "/dev/mmcblk0") ;; #f may be preferrable here to prevent accid= ental resizing of wrong file-system > "The device containing the partition to be resized.") > (partition > (number 2) > "The partition number that is to be resized.") > (end > (string "100%") > "The end position of the resized partition as understood by the parted= \ > utility (e.g. \"100%\", \"500M\" or \"16GiB\").")) >=20 > (define (resize-fs-script config) > (match-record > config (parted e2fsprogs device partition= end) > (let ((parted-bin (file-append parted "/sbin/parted")) > (resize2fs (file-append e2fsprogs "/sbin/resize2fs")) > (device+partition (string-append device "p" (number->string par= tition)))) > (mixed-text-file "resize-fs.sh" > "#!/bin/sh > echoerr() { printf \"$*\\n\" >&2 ; } >=20 > cmd() { > " parted-bin " " device " ---pretend-input-tty < resizepart > " (number->string partition) " > Yes > " end " > EOF > } >=20 > set -o errexit > set -o pipefail >=20 > echoerr hello from resize-fs script >=20 > if cmd; then > echoerr \"Resizing successful\" > else > echoerr \"resize-script returned $?\" > fi > ")))) >=20 > (define (resize-fs-shepherd-service config) > "Return a list of for resize-fs-service for CONFIG" > (let ((resize-script (resize-fs-script config))) > (shepherd-service > (documentation "Resize a file-system. Intended for Guix Systems tha= t are booted from an image") > (provision '(resize-fs)) > (requirement '(user-processes)) > (one-shot? #t) > (respawn? #f) > (start #~(make-forkexec-constructor > (list #$(file-append bash "/bin/sh") #$resize-script)))))) >=20 > (define resize-fs-service-type > (service-type > (name 'resize-fs) > (description "Resize a partition.") > (extensions > (list > (service-extension shepherd-root-service-type > (compose list resize-fs-shepherd-service)))) > (default-value (resize-fs-configuration)))) I think it would be helpful to have upstream. I'm guessing it would be useful not just on single board computers but also on VPSs and probably other use cases. Not directly related to upstreaming this service, this seems like a useful service to offer for an 'on first boot' service, or as some sort of special service to be loaded with 'sudo herd load root'. --=20 Efraim Flashner =D7=A8=D7=A0=D7=A9=D7=9C=D7=A4 = =D7=9D=D7=99=D7=A8=D7=A4=D7=90 GPG key =3D A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351 Confidentiality cannot be guaranteed on emails sent or received unencrypted --FPq7fVEiHSWcH2GS Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEoov0DD5VE3JmLRT3Qarn3Mo9g1EFAmVxmwcACgkQQarn3Mo9 g1F+bg/+IbTKLJWyxFsA6pz6Erip5tqjGl9b7OP5qKpM7ZqQq/e+4g8CZ/56CdNo pSC0Mq6XbXFTx5/NMhA/YVv7KacvEB8+xbP2xKpcqZB0nYB0uE1XXkzQODSLTPF+ JdFxOhIha3l6MzfhAC5VC9r361VCxg2VNi6DgEtHsU8TosAxKyT3btiQhldjxSF7 w7ovxufjT6KypZshG7R8BAIMm++eG+fwbhPkRzu1U34ev6qGS8mJBNHMECq+MHD1 Q0xWPZb3K1knnyvCPpNz/huqG8T+dNShedN6Hr9vRfMulHU5UC1dnQXKczyQwka6 8aY3RPEjPgyW+xZ+Ae2oqf0wBaOOmICNhbUTFM/JJx3efk7Z1Fge8h/veDAt14d6 WORoibGFN7lCENL93LM3NFIUuBYQTOuCdNGq6jK+5X7l3vx12xIOCO3AW1Iq4AoM ffmGaW534YhMflScjg0OpqvK4Ie5fGMREGDht7qEQt0FnHBYKwtg08CH11SXuZaK v1LWHuo/e1aoCLXDtslrUjGFymn75cSi8MGeaYROlTQi+0/CYcZGbkOihnQ4T1XR W0km8mB+PDUjDu8kqwq37mK/T7l2D9aoC7LcqTgv679RkZvkJkn5aCvGLGwW3nQw /bVZSpCWJF3QjMkjYofeu92WhXnFeaX72mnQE6eeWyt6csAP+KU= =Sjr+ -----END PGP SIGNATURE----- --FPq7fVEiHSWcH2GS--