all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Resize Filesystem Service
@ 2023-12-04 15:33 Wicki Gabriel (wicg)
  2023-12-04 20:18 ` Felix Lechner via
  0 siblings, 1 reply; 7+ messages in thread
From: Wicki Gabriel (wicg) @ 2023-12-04 15:33 UTC (permalink / raw)
  To: help-guix@gnu.org

[-- 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))))

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-12-13 17:11 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-04 15:33 Resize Filesystem Service Wicki Gabriel (wicg)
2023-12-04 20:18 ` 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)

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.