From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41328) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e9oZD-0003NW-BM for guix-patches@gnu.org; Wed, 01 Nov 2017 04:40:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e9oZ9-0002r1-BA for guix-patches@gnu.org; Wed, 01 Nov 2017 04:40:07 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:36296) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e9oZ9-0002qv-79 for guix-patches@gnu.org; Wed, 01 Nov 2017 04:40:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1e9oZ9-0002dj-0n for guix-patches@gnu.org; Wed, 01 Nov 2017 04:40:03 -0400 Subject: [bug#29100] [PATCH 1/3] build: Use overlayfs instead of unionfs. References: <20171101083307.5214-1-h.goebel@crazy-compilers.com> In-Reply-To: <20171101083307.5214-1-h.goebel@crazy-compilers.com> Resent-Message-ID: From: Hartmut Goebel Date: Wed, 1 Nov 2017 09:39:50 +0100 Message-Id: <20171101083952.5376-1-h.goebel@crazy-compilers.com> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 29100@debbugs.gnu.org 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-intrd.scm (file-system-packages): Remove now unused packages "unionfs-fuse/static". (linux-modules): Replace "fuse" by "overlay". --- gnu/build/linux-boot.scm | 43 +++++++++++++------------------------------ gnu/system/linux-initrd.scm | 4 ++-- 2 files changed, 15 insertions(+), 32 deletions(-) diff --git a/gnu/build/linux-boot.scm b/gnu/build/linux-boot.scm index 3712abe91..7f07e8038 100644 --- a/gnu/build/linux-boot.scm +++ b/gnu/build/linux-boot.scm @@ -241,20 +241,10 @@ the last argument of `mknod'." (filter-map string->number (scandir "/proc"))))) (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? -is true, mount ROOT read-only and make it a union with a writable tmpfs using -UNIONFS." - (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))) - +is true, mount ROOT read-only and make it a overlay with a writable tmpfs +using the kernel build-in overlayfs." (if volatile-root? (begin (mkdir-p "/real-root") @@ -262,24 +252,17 @@ UNIONFS." (mkdir-p "/rw-root") (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. - (mkdir-p "/rw-root/dev") - (mount "none" "/rw-root/dev" "devtmpfs") - - ;; Make /root a union of the tmpfs and the actual root. Use - ;; 'max_files' to set a high RLIMIT_NOFILE for the unionfs process - ;; itself. Failing to do that, we quickly run out of file - ;; descriptors; see . - (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))) + (mkdir-p "/rw-root/upper/dev") + (mount "none" "/rw-root/upper/dev" "devtmpfs") + + ;; Make /root a overlay of the tmpfs and the actual root. + (mount "none" "/root" "overlay" 0 + "lowerdir=/real-root,upperdir=/rw-root/upper,workdir=/rw-root/work")) (begin (check-file-system root type) (mount root "/root" type))) diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm index 948c543a1..4168582c4 100644 --- a/gnu/system/linux-initrd.scm +++ b/gnu/system/linux-initrd.scm @@ -236,7 +236,7 @@ FILE-SYSTEMS." (list btrfs-progs/static) '()) ,@(if volatile-root? - (list unionfs-fuse/static) + (list ) ;; nothing requierd in this case '()))) (define* (base-initrd file-systems @@ -308,7 +308,7 @@ loaded at boot time in the order in which they appear." '("isofs") '()) ,@(if volatile-root? - '("fuse") + '("overlay") '()) ,@extra-modules)) -- 2.13.5