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: [email protected]
Web: http://ines.zhaw.ch
(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))))