From: "Wicki Gabriel (wicg)" <wicg@zhaw.ch>
To: "help-guix@gnu.org" <help-guix@gnu.org>
Subject: Resize Filesystem Service
Date: Mon, 4 Dec 2023 15:33:39 +0000 [thread overview]
Message-ID: <ZR0P278MB0268910B4FE39A48112CE740C186A@ZR0P278MB0268.CHEP278.PROD.OUTLOOK.COM> (raw)
[-- Attachment #1: Type: text/plain, Size: 794 bytes --]
Hi
For a small embedded software project I need a resize-fs-service: a one-shot service started during boot that ensures that the rootfs (created from a guix system image foo.scm command) uses all of the medium's space -- creating an image of the correct size is completely infeasible as you may imagine.
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.
Any ideas are deeply appreciated!
Thanks for your time and effort!
Gabriel aka gabber
--
Gabriel Wicki
Research Assistant
ZHAW, Zurich University of Applied Sciences
InES, Institute of Embedded Systems
High Integrity Systems Group
Technikumstrasse 22, Postfach
CH-8401 Winterthur
--
E-Mail: wicg@zhaw.ch
Web: http://ines.zhaw.ch
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: resize-fs.scm --]
[-- Type: text/x-scheme; name="resize-fs.scm", Size: 2320 bytes --]
(define-module (resize-fs)
#:use-module (gnu packages disk)
#:use-module (gnu packages linux)
#:use-module (guix build utils)
#:use-module (guix packages)
#:use-module (gnu services)
#:use-module (guix gexp)
#:use-module (guix records)
#:use-module (gnu services shepherd))
(define (resize-fs-service config)
(use-modules (guix gexp))
(define parted #$(string-append (or (resize-fs-configuration-parted config)
parted)
"/sbin/parted"))
(define resize2fs #$(string-append (or (resize-fs-configuration-e2fsprogs config)
e2fsprogs)
"/sbin/resize2fs"))
(define size #$(resize-fs-configuration-size config))
(define device #$(resize-fs-configuration-device config))
(define partition #$(resize-fs-configuration-partition config))
(define device+partition (string-append device "p" partition))
(shepherd-service
(documentation "Resize a file-system. Intended for Guix Systems that are booted from an image")
(provision '(resize-fs))
(one-shot? #t)
(requirement '())
(start #~(invoke (plain-file "resize_partition.bash"
(string-append
"#!/bin/sh
parted " #$device " ---pretend-input-tty <<EOF
resizepart
" #$partition "
Yes
" #$size"
EOF
" $#resize2fs " " device+partition))))))
(define-record-type* <resize-fs-configuration>
resize-fs-configuration make-resize-fs-configuration
resize-fs-configuration?
;; the utilities doing the job
(parted resize-fs-configuraiton-parted
(default parted))
(e2fsprogs resize-fs-configuration-e2fsprogs
(default e2fsprogs))
;; path of a device
(device resize-fs-configuration-device
(default "/dev/mmcblk0")) ; #f may be preferrable here
;; integer
(partition resize-fs-configuration-partition
(default 2))
;; size - as understood by parted
(size resize-fs-configuration-size
(default "100%")))
(define-public resize-fs-service-type
(service-type
(name 'resize-fs)
(extensions
(list (service-extension shepherd-root-service-type resize-fs-service)))
(description "Resize a partition.")
(default-value (resize-fs-configuration))))
next reply other threads:[~2023-12-04 15:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-04 15:33 Wicki Gabriel (wicg) [this message]
2023-12-04 20:18 ` Resize Filesystem Service Felix Lechner via
2023-12-07 9:25 ` Wicki Gabriel (wicg)
2023-12-07 10:14 ` Efraim Flashner
2023-12-10 17:03 ` Csepp
2023-12-12 9:46 ` Wicki Gabriel (wicg)
2023-12-12 9:46 ` Wicki Gabriel (wicg)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZR0P278MB0268910B4FE39A48112CE740C186A@ZR0P278MB0268.CHEP278.PROD.OUTLOOK.COM \
--to=wicg@zhaw.ch \
--cc=help-guix@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.