From 6efb98ed3cc0ff4b2a35f4a08651d5ad15d1a9cd Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 29 Jun 2017 23:11:23 +0200 Subject: vm: Fix 'load-in-linux-vm' docstring. * gnu/build/vm.scm (load-in-linux-vm): Change default value of #:disk-image-size. Update docstring to note that DISK-IMAGE-SIZE is in bytes. --- gnu/build/vm.scm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'gnu') diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm index 57619764ce..56ebeaea63 100644 --- a/gnu/build/vm.scm +++ b/gnu/build/vm.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2013, 2014, 2015, 2016 Ludovic Courtès +;;; Copyright © 2013, 2014, 2015, 2016, 2017 Ludovic Courtès ;;; Copyright © 2016 Christopher Allan Webber ;;; Copyright © 2016 Leo Famulari ;;; Copyright © 2017 Mathieu Othacehe @@ -71,15 +71,16 @@ output (qemu (qemu-command)) (memory-size 512) linux initrd - make-disk-image? (disk-image-size 100) + make-disk-image? + (disk-image-size (* 100 (expt 2 20))) (disk-image-format "qcow2") (references-graphs '())) "Run BUILDER, a Scheme file, into a VM running LINUX with INITRD, and copy the result to OUTPUT. When MAKE-DISK-IMAGE? is true, OUTPUT will contain a VM image of -DISK-IMAGE-SIZE MiB resulting from the execution of BUILDER, which may access -it via /dev/hda. +DISK-IMAGE-SIZE bytes resulting from the execution of BUILDER, which may +access it via /dev/hda. REFERENCES-GRAPHS can specify a list of reference-graph files as produced by the #:references-graphs parameter of 'derivation'." -- cgit 1.4.1 From a2cf57e79e0c1ca59ff854c12ece178a73fe224d Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 29 Jun 2017 23:26:35 +0200 Subject: vm: Display the disk and partition sizes. * gnu/build/vm.scm (load-in-linux-vm): Add 'format' call when MAKE-DISK-IMAGE? is true. (initialize-partition-table): Show the size of the partitions being created. --- gnu/build/vm.scm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'gnu') diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm index 56ebeaea63..7d5e613956 100644 --- a/gnu/build/vm.scm +++ b/gnu/build/vm.scm @@ -85,6 +85,9 @@ access it via /dev/hda. REFERENCES-GRAPHS can specify a list of reference-graph files as produced by the #:references-graphs parameter of 'derivation'." (when make-disk-image? + (format #t "creating ~a image of ~,2f MiB...~%" + disk-image-format (/ disk-image-size (expt 2 20))) + (force-output) (unless (zero? (system* "qemu-img" "create" "-f" disk-image-format output (number->string disk-image-size))) @@ -193,8 +196,15 @@ actual /dev name based on DEVICE." (cons (partition-options head offset index) result)))))) - (format #t "creating partition table with ~a partitions...\n" - (length partitions)) + (format #t "creating partition table with ~a partitions (~a)...\n" + (length partitions) + (string-join (map (compose (cut string-append <> " MiB") + number->string + (lambda (size) + (round (/ size (expt 2. 20)))) + partition-size) + partitions) + ", ")) (unless (zero? (apply system* "parted" "--script" device "mklabel" label-type (options partitions offset))) -- cgit 1.4.1 From a8ac4f081a9a679498ea42ccfe001f218bba3043 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 30 Jun 2017 00:04:38 +0200 Subject: vm: Estimate the disk size by default. * gnu/build/vm.scm (estimated-partition-size): New procedure. * gnu/system/vm.scm (expression->derivation-in-linux-vm): Change #:disk-image-size default to 'guess. [builder]: When DISK-IMAGE-SIZE is 'guess, use 'estimated-partition-size' and compute and estimate of the image size. (qemu-image): Likewise. * guix/build/store-copy.scm (file-size, closure-size): New procedures. * guix/scripts/system.scm (%default-options): Change 'image-size' to 'guess. * doc/guix.texi (Building the Installation Image): Remove '--image-size' flag from example. (Invoking guix system): Document the image size estimate. --- doc/guix.texi | 12 ++++++++---- gnu/build/vm.scm | 7 +++++++ gnu/system/vm.scm | 44 +++++++++++++++++++++++++++----------------- guix/build/store-copy.scm | 35 ++++++++++++++++++++++++++++++++++- guix/scripts/system.scm | 2 +- 5 files changed, 77 insertions(+), 23 deletions(-) (limited to 'gnu') diff --git a/doc/guix.texi b/doc/guix.texi index 729ec081be..d61a5b7514 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -7877,9 +7877,8 @@ that. The installation image described above was built using the @command{guix system} command, specifically: -@c FIXME: 1G is too much; see . @example -guix system disk-image --image-size=1G gnu/system/install.scm +guix system disk-image gnu/system/install.scm @end example Have a look at @file{gnu/system/install.scm} in the source tree, @@ -16187,8 +16186,9 @@ size of the image. @item vm-image @itemx disk-image Return a virtual machine or disk image of the operating system declared -in @var{file} that stands alone. Use the @option{--image-size} option -to specify the size of the image. +in @var{file} that stands alone. By default, @command{guix system} +estimates the size of the image needed to store the system, but you can +use the @option{--image-size} option to specify a value. When using @code{vm-image}, the returned image is in qcow2 format, which the QEMU emulator can efficiently use. @xref{Running GuixSD in a VM}, @@ -16251,6 +16251,10 @@ of the given @var{size}. @var{size} may be a number of bytes, or it may include a unit as a suffix (@pxref{Block size, size specifications,, coreutils, GNU Coreutils}). +When this option is omitted, @command{guix system} computes an estimate +of the image size as a function of the size of the system declared in +@var{file}. + @item --root=@var{file} @itemx -r @var{file} Make @var{file} a symlink to the result, and register it as a garbage diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm index 7d5e613956..d0bc8c3033 100644 --- a/gnu/build/vm.scm +++ b/gnu/build/vm.scm @@ -46,6 +46,7 @@ partition-flags partition-initializer + estimated-partition-size root-partition-initializer initialize-partition-table initialize-hard-disk)) @@ -150,6 +151,12 @@ the #:references-graphs parameter of 'derivation'." (flags partition-flags (default '())) (initializer partition-initializer (default (const #t)))) +(define (estimated-partition-size graphs) + "Return the estimated size of a partition that can store the store items +given by GRAPHS, a list of file names produced by #:references-graphs." + ;; Simply add a 20% overhead. + (round (* 1.2 (closure-size graphs)))) + (define (fold2 proc seed1 seed2 lst) ;TODO: factorize "Like `fold', but with a single list and two seeds." (let loop ((result1 seed1) diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm index 392737d078..7ac8696158 100644 --- a/gnu/system/vm.scm +++ b/gnu/system/vm.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2013, 2014, 2015, 2016 Ludovic Courtès +;;; Copyright © 2013, 2014, 2015, 2016, 2017 Ludovic Courtès ;;; Copyright © 2016 Christopher Allan Webber ;;; Copyright © 2016 Leo Famulari ;;; Copyright © 2017 Mathieu Othacehe @@ -108,8 +108,7 @@ (references-graphs #f) (memory-size 256) (disk-image-format "qcow2") - (disk-image-size - (* 100 (expt 2 20)))) + (disk-image-size 'guess)) "Evaluate EXP in a QEMU virtual machine running LINUX with INITRD (a derivation). In the virtual machine, EXP has access to all its inputs from the store; it should put its output files in the `/xchg' directory, which is @@ -118,7 +117,8 @@ runs with MEMORY-SIZE MiB of memory. When MAKE-DISK-IMAGE? is true, then create a QEMU disk image of type DISK-IMAGE-FORMAT (e.g., 'qcow2' or 'raw'), of DISK-IMAGE-SIZE bytes and -return it. +return it. When DISK-IMAGE-SIZE is 'guess, estimate the image size based +based on the size of the closure of REFERENCES-GRAPHS. When REFERENCES-GRAPHS is true, it must be a list of file name/store path pairs, as for `derivation'. The files containing the reference graphs are @@ -143,14 +143,18 @@ made available under the /xchg CIFS share." (use-modules (guix build utils) (gnu build vm)) - (let ((inputs '#$(list qemu coreutils)) - (linux (string-append #$linux "/" - #$(system-linux-image-file-name))) - (initrd (string-append #$initrd "/initrd")) - (loader #$loader) - (graphs '#$(match references-graphs - (((graph-files . _) ...) graph-files) - (_ #f)))) + (let* ((inputs '#$(list qemu coreutils)) + (linux (string-append #$linux "/" + #$(system-linux-image-file-name))) + (initrd (string-append #$initrd "/initrd")) + (loader #$loader) + (graphs '#$(match references-graphs + (((graph-files . _) ...) graph-files) + (_ #f))) + (size #$(if (eq? 'guess disk-image-size) + #~(+ (* 70 (expt 2 20)) ;ESP + (estimated-partition-size graphs)) + disk-image-size))) (set-path-environment-variable "PATH" '("bin") inputs) @@ -160,7 +164,7 @@ made available under the /xchg CIFS share." #:memory-size #$memory-size #:make-disk-image? #$make-disk-image? #:disk-image-format #$disk-image-format - #:disk-image-size #$disk-image-size + #:disk-image-size size #:references-graphs graphs))))) (gexp->derivation name builder @@ -174,7 +178,7 @@ made available under the /xchg CIFS share." (name "qemu-image") (system (%current-system)) (qemu qemu-minimal) - (disk-image-size (* 100 (expt 2 20))) + (disk-image-size 'guess) (disk-image-format "qcow2") (file-system-type "ext4") file-system-label @@ -201,7 +205,8 @@ the image." (guix build utils))) #~(begin (use-modules (gnu build vm) - (guix build utils)) + (guix build utils) + (srfi srfi-26)) (let ((inputs '#$(append (list qemu parted e2fsprogs dosfstools) @@ -227,9 +232,14 @@ the image." #:copy-closures? #$copy-inputs? #:register-closures? #$register-closures? #:system-directory #$os-drv)) + (root-size #$(if (eq? 'guess disk-image-size) + #~(estimated-partition-size + (map (cut string-append "/xchg/" <>) + graphs)) + (- disk-image-size + (* 50 (expt 2 20))))) (partitions (list (partition - (size #$(- disk-image-size - (* 50 (expt 2 20)))) + (size root-size) (label #$file-system-label) (file-system #$file-system-type) (flags '(boot)) diff --git a/guix/build/store-copy.scm b/guix/build/store-copy.scm index a296bdf78f..fe2eb6f69a 100644 --- a/guix/build/store-copy.scm +++ b/guix/build/store-copy.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2013, 2014 Ludovic Courtès +;;; Copyright © 2013, 2014, 2017 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -20,7 +20,9 @@ #:use-module (guix build utils) #:use-module (srfi srfi-1) #:use-module (ice-9 rdelim) + #:use-module (ice-9 ftw) #:export (read-reference-graph + closure-size populate-store)) ;;; Commentary: @@ -46,6 +48,37 @@ The data at PORT is the format produced by #:references-graphs." (loop (read-line port) result))))) +(define (file-size file) + "Return the size of bytes of FILE, entering it if FILE is a directory." + (file-system-fold (const #t) + (lambda (file stat result) ;leaf + (+ (stat:size stat) result)) + (lambda (directory stat result) ;down + (+ (stat:size stat) result)) + (lambda (directory stat result) ;up + result) + (lambda (file stat result) ;skip + result) + (lambda (file stat errno result) + (format (current-error-port) + "file-size: ~a: ~a~%" file + (strerror errno)) + result) + 0 + file + lstat)) + +(define (closure-size reference-graphs) + "Return an estimate of the size of the closure described by +REFERENCE-GRAPHS, a list of reference-graph files." + (define (graph-from-file file) + (call-with-input-file file read-reference-graph)) + + (define items + (delete-duplicates (append-map graph-from-file reference-graphs))) + + (reduce + 0 (map file-size items))) + (define* (populate-store reference-graphs target) "Populate the store under directory TARGET with the items specified in REFERENCE-GRAPHS, a list of reference-graph files." diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index 35675cc018..7e20b10dad 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -854,7 +854,7 @@ Some ACTIONS support additional ARGS.\n")) (build-hook? . #t) (max-silent-time . 3600) (verbosity . 0) - (image-size . ,(* 900 (expt 2 20))) + (image-size . guess) (install-bootloader? . #t))) -- cgit 1.4.1 From a2278922fe5158d3caac9d2c3ff5008e084a45d3 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 30 Jun 2017 00:13:54 +0200 Subject: vm: Use 'fold2' from (guix combinators). * gnu/build/vm.scm: Use (guix combinators). (fold2): Remove. --- gnu/build/vm.scm | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'gnu') diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm index d0bc8c3033..8f7fc3c9c4 100644 --- a/gnu/build/vm.scm +++ b/gnu/build/vm.scm @@ -27,6 +27,7 @@ #:use-module (gnu build linux-boot) #:use-module (gnu build install) #:use-module (guix records) + #:use-module ((guix combinators) #:select (fold2)) #:use-module (ice-9 format) #:use-module (ice-9 match) #:use-module (ice-9 regex) @@ -157,18 +158,6 @@ given by GRAPHS, a list of file names produced by #:references-graphs." ;; Simply add a 20% overhead. (round (* 1.2 (closure-size graphs)))) -(define (fold2 proc seed1 seed2 lst) ;TODO: factorize - "Like `fold', but with a single list and two seeds." - (let loop ((result1 seed1) - (result2 seed2) - (lst lst)) - (if (null? lst) - (values result1 result2) - (call-with-values - (lambda () (proc (car lst) result1 result2)) - (lambda (result1 result2) - (loop result1 result2 (cdr lst))))))) - (define* (initialize-partition-table device partitions #:key (label-type "msdos") -- cgit 1.4.1 From 5a1b5dccf0588faff7ab4a71bb45b0b633fcc700 Mon Sep 17 00:00:00 2001 From: Mark H Weaver Date: Fri, 30 Jun 2017 00:11:10 -0400 Subject: gnu: linux-libre@4.1: Update to 4.1.42 [mitigates CVE-2017-1000364]. * gnu/packages/linux.scm (linux-libre-4.1): Update to 4.1.42. --- gnu/packages/linux.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gnu') diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm index 641c307a0b..324ade3037 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm @@ -385,8 +385,8 @@ It has been modified to remove all non-free binary blobs.") #:configuration-file kernel-config)) (define-public linux-libre-4.1 - (make-linux-libre "4.1.41" - "02mqfl899jxvrmxlh8lvcgvm3klwd8wbsdz4rr2gpchbggj4vgb2" + (make-linux-libre "4.1.42" + "1g5jhn7cm6ixn7w8ciqm6qgxv7k1jg50v6k05hsvzvrqfpaxqlbz" %intel-compatible-systems #:configuration-file kernel-config)) -- cgit 1.4.1 From 5d7f9c156e61e3789e7b8f051589a84f66909d52 Mon Sep 17 00:00:00 2001 From: Mark H Weaver Date: Fri, 30 Jun 2017 00:12:16 -0400 Subject: gnu: linux-libre@4.4: Update to 4.4.75. * gnu/packages/linux.scm (linux-libre-4.4): Update to 4.4.75. --- gnu/packages/linux.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gnu') diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm index 324ade3037..83465ed609 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm @@ -379,8 +379,8 @@ It has been modified to remove all non-free binary blobs.") #:configuration-file kernel-config)) (define-public linux-libre-4.4 - (make-linux-libre "4.4.74" - "04x2ki3s2jsjkkk6bld0rd9rsk8qqvrfsxawxzfa26mkq6pv87r2" + (make-linux-libre "4.4.75" + "1h687flrdzlcd1ms5n2khm0mxybr8bj2jfnnm7qvy6ha2vsngb5b" %intel-compatible-systems #:configuration-file kernel-config)) -- cgit 1.4.1 From 426187d27838f4d38ccd25bf9da955bdaab55a1c Mon Sep 17 00:00:00 2001 From: Mark H Weaver Date: Fri, 30 Jun 2017 00:12:55 -0400 Subject: gnu: linux-libre@4.9: Update to 4.9.35. * gnu/packages/linux.scm (linux-libre-4.9): Update to 4.9.35. --- gnu/packages/linux.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gnu') diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm index 83465ed609..3aa0159053 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm @@ -373,8 +373,8 @@ It has been modified to remove all non-free binary blobs.") #:configuration-file kernel-config)) (define-public linux-libre-4.9 - (make-linux-libre "4.9.34" - "00jm3338kvhfj850lg3mvk680fmfw34mvwaq41lvxgb1z2xqqlz1" + (make-linux-libre "4.9.35" + "0fs90jgb01jybkclngg5asvbs1y70f2abs395qcb3lxpx7zxhy1h" %intel-compatible-systems #:configuration-file kernel-config)) -- cgit 1.4.1 From 588b22575d1ad7eb41dec17e01e03aa1c56f56db Mon Sep 17 00:00:00 2001 From: Mark H Weaver Date: Fri, 30 Jun 2017 00:13:36 -0400 Subject: gnu: linux-libre: Update to 4.11.8. * gnu/packages/linux.scm (%linux-libre-version): Update to 4.11.8. (%linux-libre-hash): Update hash. --- gnu/packages/linux.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gnu') diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm index 3aa0159053..f18a23b2cf 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm @@ -363,8 +363,8 @@ It has been modified to remove all non-free binary blobs.") (define %intel-compatible-systems '("x86_64-linux" "i686-linux")) -(define %linux-libre-version "4.11.7") -(define %linux-libre-hash "0kliwdz4qqjz13pywhavxg19cy1mf6d1f52f6kgapc331309vad9") +(define %linux-libre-version "4.11.8") +(define %linux-libre-hash "1z35h6xr8gdzq31xv3dpdz6ddz4q3183fwvkmx8qd7h9bhy13aw6") (define-public linux-libre (make-linux-libre %linux-libre-version -- cgit 1.4.1 From 87941d1df473511f0f75737e81a51a106132c9de Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 30 Jun 2017 11:13:53 +0200 Subject: system: Use "@" to refer to the 'shadow' package. Reported by Mark H Weaver at . * gnu/system.scm (%base-packages): Use '@' for shadow. This fixes an error on Guile 2.0 where 'shadow' alone resolves to the (gnu system shadow) module. --- gnu/system.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gnu') diff --git a/gnu/system.scm b/gnu/system.scm index 0aec872e6c..ee1e10f82d 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -490,7 +490,7 @@ explicitly appear in OS." lsof ;for Guix's 'list-runtime-roots' pciutils usbutils util-linux inetutils isc-dhcp - shadow ;for 'passwd' + (@ (gnu packages admin) shadow) ;for 'passwd' ;; wireless-tools is deprecated in favor of iw, but it's still what ;; many people are familiar with, so keep it around. -- cgit 1.4.1