mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2025-01-11 21:59:08 -05:00
build: Use overlayfs instead of unionfs.
Overlayfs is part of the kernel, while unionfs needs FUSE. This also reduces the size of the initrd by ca. 4.3% (487K). * gnu/build/linux-boot.scm (mount-root-file-system): Remove optional parameter "unionfs"; mount using overlayfs instead of unionfs; new directory layout requied by overlayfs; update documentation. [mark-as-not-killable]: Remove now unused function * gnu/system/linux-initrd.scm (file-system-packages): Remove now unused packages "unionfs-fuse/static" and thus unused related 'if'. (linux-modules): Replace "fuse" by "overlay".
This commit is contained in:
parent
34260a10d7
commit
c828969036
2 changed files with 13 additions and 33 deletions
|
@ -241,20 +241,10 @@ (define (pidof program)
|
||||||
(filter-map string->number (scandir "/proc")))))
|
(filter-map string->number (scandir "/proc")))))
|
||||||
|
|
||||||
(define* (mount-root-file-system root type
|
(define* (mount-root-file-system root type
|
||||||
#:key volatile-root? (unionfs "unionfs"))
|
#:key volatile-root?)
|
||||||
"Mount the root file system of type TYPE at device ROOT. If VOLATILE-ROOT?
|
"Mount the root file system of type TYPE at device ROOT. If VOLATILE-ROOT?
|
||||||
is true, mount ROOT read-only and make it a union with a writable tmpfs using
|
is true, mount ROOT read-only and make it a overlay with a writable tmpfs
|
||||||
UNIONFS."
|
using the kernel build-in overlayfs."
|
||||||
(define (mark-as-not-killable pid)
|
|
||||||
;; Tell the 'user-processes' shepherd service that PID must be kept alive
|
|
||||||
;; when shutting down.
|
|
||||||
(mkdir-p "/root/etc/shepherd")
|
|
||||||
(let ((port (open-file "/root/etc/shepherd/do-not-kill" "a")))
|
|
||||||
(chmod port #o600)
|
|
||||||
(write pid port)
|
|
||||||
(newline port)
|
|
||||||
(close-port port)))
|
|
||||||
|
|
||||||
(if volatile-root?
|
(if volatile-root?
|
||||||
(begin
|
(begin
|
||||||
(mkdir-p "/real-root")
|
(mkdir-p "/real-root")
|
||||||
|
@ -262,24 +252,17 @@ (define (mark-as-not-killable pid)
|
||||||
(mkdir-p "/rw-root")
|
(mkdir-p "/rw-root")
|
||||||
(mount "none" "/rw-root" "tmpfs")
|
(mount "none" "/rw-root" "tmpfs")
|
||||||
|
|
||||||
|
;; Create the upperdir and the workdir of the overlayfs
|
||||||
|
(mkdir-p "/rw-root/upper")
|
||||||
|
(mkdir-p "/rw-root/work")
|
||||||
|
|
||||||
;; We want read-write /dev nodes.
|
;; We want read-write /dev nodes.
|
||||||
(mkdir-p "/rw-root/dev")
|
(mkdir-p "/rw-root/upper/dev")
|
||||||
(mount "none" "/rw-root/dev" "devtmpfs")
|
(mount "none" "/rw-root/upper/dev" "devtmpfs")
|
||||||
|
|
||||||
;; Make /root a union of the tmpfs and the actual root. Use
|
;; Make /root an overlay of the tmpfs and the actual root.
|
||||||
;; 'max_files' to set a high RLIMIT_NOFILE for the unionfs process
|
(mount "none" "/root" "overlay" 0
|
||||||
;; itself. Failing to do that, we quickly run out of file
|
"lowerdir=/real-root,upperdir=/rw-root/upper,workdir=/rw-root/work"))
|
||||||
;; descriptors; see <http://bugs.gnu.org/17827>.
|
|
||||||
(unless (zero? (system* unionfs "-o"
|
|
||||||
"cow,allow_other,use_ino,suid,dev,max_files=65536"
|
|
||||||
"/rw-root=RW:/real-root=RO"
|
|
||||||
"/root"))
|
|
||||||
(error "unionfs failed"))
|
|
||||||
|
|
||||||
;; Make sure unionfs remains alive till the end. Because
|
|
||||||
;; 'fuse_daemonize' doesn't tell the PID of the forked daemon, we
|
|
||||||
;; have to resort to 'pidof' here.
|
|
||||||
(mark-as-not-killable (pidof unionfs)))
|
|
||||||
(begin
|
(begin
|
||||||
(check-file-system root type)
|
(check-file-system root type)
|
||||||
(mount root "/root" type)))
|
(mount root "/root" type)))
|
||||||
|
|
|
@ -234,9 +234,6 @@ (define* (file-system-packages file-systems #:key (volatile-root? #f))
|
||||||
'())
|
'())
|
||||||
,@(if (find (file-system-type-predicate "btrfs") file-systems)
|
,@(if (find (file-system-type-predicate "btrfs") file-systems)
|
||||||
(list btrfs-progs/static)
|
(list btrfs-progs/static)
|
||||||
'())
|
|
||||||
,@(if volatile-root?
|
|
||||||
(list unionfs-fuse/static)
|
|
||||||
'())))
|
'())))
|
||||||
|
|
||||||
(define* (base-initrd file-systems
|
(define* (base-initrd file-systems
|
||||||
|
@ -308,7 +305,7 @@ (define linux-modules
|
||||||
'("isofs")
|
'("isofs")
|
||||||
'())
|
'())
|
||||||
,@(if volatile-root?
|
,@(if volatile-root?
|
||||||
'("fuse")
|
'("overlay")
|
||||||
'())
|
'())
|
||||||
,@extra-modules))
|
,@extra-modules))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue