diff options
| author | Hartmut Goebel <h.goebel@crazy-compilers.com> | 2017-10-25 18:13:15 +0200 |
|---|---|---|
| committer | Hartmut Goebel <h.goebel@crazy-compilers.com> | 2017-11-08 18:23:05 +0100 |
| commit | c8289690365887ca1dd122645e479a89cf7cd969 (patch) | |
| tree | a02e832d8f823061a916db682f4b0359e3d1f23b /gnu/build/linux-boot.scm | |
| parent | 34260a10d70c4eae87fc48419b7134fbbb4bbd30 (diff) | |
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".
Diffstat (limited to 'gnu/build/linux-boot.scm')
| -rw-r--r-- | gnu/build/linux-boot.scm | 43 |
1 files changed, 13 insertions, 30 deletions
diff --git a/gnu/build/linux-boot.scm b/gnu/build/linux-boot.scm index 3712abe910a..a1ff4dd1eab 100644 --- a/gnu/build/linux-boot.scm +++ b/gnu/build/linux-boot.scm | |||
| @@ -241,20 +241,10 @@ the last argument of `mknod'." | |||
| 241 | (filter-map string->number (scandir "/proc"))))) | 241 | (filter-map string->number (scandir "/proc"))))) |
| 242 | 242 | ||
| 243 | (define* (mount-root-file-system root type | 243 | (define* (mount-root-file-system root type |
| 244 | #:key volatile-root? (unionfs "unionfs")) | 244 | #:key volatile-root?) |
| 245 | "Mount the root file system of type TYPE at device ROOT. If VOLATILE-ROOT? | 245 | "Mount the root file system of type TYPE at device ROOT. If VOLATILE-ROOT? |
| 246 | is true, mount ROOT read-only and make it a union with a writable tmpfs using | 246 | is true, mount ROOT read-only and make it a overlay with a writable tmpfs |
| 247 | UNIONFS." | 247 | using the kernel build-in overlayfs." |
| 248 | (define (mark-as-not-killable pid) | ||
| 249 | ;; Tell the 'user-processes' shepherd service that PID must be kept alive | ||
| 250 | ;; when shutting down. | ||
| 251 | (mkdir-p "/root/etc/shepherd") | ||
| 252 | (let ((port (open-file "/root/etc/shepherd/do-not-kill" "a"))) | ||
| 253 | (chmod port #o600) | ||
| 254 | (write pid port) | ||
| 255 | (newline port) | ||
| 256 | (close-port port))) | ||
| 257 | |||
| 258 | (if volatile-root? | 248 | (if volatile-root? |
| 259 | (begin | 249 | (begin |
| 260 | (mkdir-p "/real-root") | 250 | (mkdir-p "/real-root") |
| @@ -262,24 +252,17 @@ UNIONFS." | |||
| 262 | (mkdir-p "/rw-root") | 252 | (mkdir-p "/rw-root") |
| 263 | (mount "none" "/rw-root" "tmpfs") | 253 | (mount "none" "/rw-root" "tmpfs") |
| 264 | 254 | ||
| 255 | ;; Create the upperdir and the workdir of the overlayfs | ||
| 256 | (mkdir-p "/rw-root/upper") | ||
| 257 | (mkdir-p "/rw-root/work") | ||
| 258 | |||
| 265 | ;; We want read-write /dev nodes. | 259 | ;; We want read-write /dev nodes. |
| 266 | (mkdir-p "/rw-root/dev") | 260 | (mkdir-p "/rw-root/upper/dev") |
| 267 | (mount "none" "/rw-root/dev" "devtmpfs") | 261 | (mount "none" "/rw-root/upper/dev" "devtmpfs") |
| 268 | 262 | ||
| 269 | ;; Make /root a union of the tmpfs and the actual root. Use | 263 | ;; Make /root an overlay of the tmpfs and the actual root. |
| 270 | ;; 'max_files' to set a high RLIMIT_NOFILE for the unionfs process | 264 | (mount "none" "/root" "overlay" 0 |
| 271 | ;; itself. Failing to do that, we quickly run out of file | 265 | "lowerdir=/real-root,upperdir=/rw-root/upper,workdir=/rw-root/work")) |
| 272 | ;; descriptors; see <http://bugs.gnu.org/17827>. | ||
| 273 | (unless (zero? (system* unionfs "-o" | ||
| 274 | "cow,allow_other,use_ino,suid,dev,max_files=65536" | ||
| 275 | "/rw-root=RW:/real-root=RO" | ||
| 276 | "/root")) | ||
| 277 | (error "unionfs failed")) | ||
| 278 | |||
| 279 | ;; Make sure unionfs remains alive till the end. Because | ||
| 280 | ;; 'fuse_daemonize' doesn't tell the PID of the forked daemon, we | ||
| 281 | ;; have to resort to 'pidof' here. | ||
| 282 | (mark-as-not-killable (pidof unionfs))) | ||
| 283 | (begin | 266 | (begin |
| 284 | (check-file-system root type) | 267 | (check-file-system root type) |
| 285 | (mount root "/root" type))) | 268 | (mount root "/root" type))) |
