From b8e7781122d0d61891b38acdf427d09fb894c307 Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Fri, 24 Nov 2017 17:35:12 +0100 Subject: vm: Use os-defined initrd intead of base-initrd. * gnu/system/vm.scm (system-disk-image, system-qemu-image, virtualized-operating-system): Replace base-initrd by (operating-system-initrd os). The system produced were always using base-initrd even if the user had defined a custom initrd based on raw-initrd in the os declaration. --- gnu/system/vm.scm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'gnu/system/vm.scm') diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm index 44246083b3..3ddb41d9a6 100644 --- a/gnu/system/vm.scm +++ b/gnu/system/vm.scm @@ -423,7 +423,8 @@ to USB sticks meant to be read-only." ;; install QEMU networking or anything like that. Assume USB ;; mass storage devices (usb-storage.ko) are available. (initrd (lambda (file-systems . rest) - (apply base-initrd file-systems + (apply (operating-system-initrd os) + file-systems #:volatile-root? #t rest))) @@ -488,7 +489,8 @@ of the GNU system as described by OS." (let ((os (operating-system (inherit os) ;; Use an initrd with the whole QEMU shebang. (initrd (lambda (file-systems . rest) - (apply base-initrd file-systems + (apply (operating-system-initrd os) + file-systems #:virtio? #t rest))) @@ -574,7 +576,8 @@ environment with the store shared with the host. MAPPINGS is a list of (target "/dev/vda"))) (initrd (lambda (file-systems . rest) - (apply base-initrd file-systems + (apply (operating-system-initrd os) + file-systems #:volatile-root? #t #:virtio? #t rest))) -- cgit 1.4.1 From f00515b4831cbeef7ef4ee9dcc0079ecdadb705b Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 30 Nov 2017 16:14:12 +0100 Subject: vm: Filter out file systems that refer to UUIDs or labels. * gnu/system/vm.scm (virtualized-operating-system)[user-file-systems]: Filter out things that refer to file system UUIDs or labels. --- gnu/system/vm.scm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'gnu/system/vm.scm') diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm index 3ddb41d9a6..a5fe48e8f1 100644 --- a/gnu/system/vm.scm +++ b/gnu/system/vm.scm @@ -554,7 +554,13 @@ environment with the store shared with the host. MAPPINGS is a list of (or (string=? target (%store-prefix)) (string=? target "/") (and (eq? 'device (file-system-title fs)) - (string-prefix? "/dev/" source))))) + (string-prefix? "/dev/" source)) + + ;; Labels and UUIDs are necessarily invalid in the VM. + (and (file-system-mount? fs) + (or (eq? 'label (file-system-title fs)) + (eq? 'uuid (file-system-title fs)) + (uuid? source)))))) (operating-system-file-systems os))) (define virtual-file-systems -- cgit 1.4.1 From 00e39b2ea466f5627b6eb85e70c98d44b73a0516 Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Wed, 29 Nov 2017 15:12:01 +0100 Subject: system: vm: Do not add EFI partition on ARM system. * gnu/system/vm.scm (qemu-img): Do not add EFI partition if we are targetting ARM. UEFI support on u-boot is still experimental, so do not add EFI partition on ARM for now. --- gnu/system/vm.scm | 50 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 20 deletions(-) (limited to 'gnu/system/vm.scm') diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm index a5fe48e8f1..8cd4c064f9 100644 --- a/gnu/system/vm.scm +++ b/gnu/system/vm.scm @@ -29,6 +29,7 @@ #:use-module (guix monads) #:use-module (guix records) #:use-module (guix modules) + #:use-module (guix utils) #:use-module ((gnu build vm) #:select (qemu-command)) @@ -312,26 +313,35 @@ the image." graphs))) (- disk-image-size (* 50 (expt 2 20))))) - (partitions (list (partition - (size root-size) - (label #$file-system-label) - (uuid #$(and=> file-system-uuid - uuid-bytevector)) - (file-system #$file-system-type) - (flags '(boot)) - (initializer initialize)) - ;; Append a small EFI System Partition for - ;; use with UEFI bootloaders. - (partition - ;; The standalone grub image is about 10MiB, but - ;; leave some room for custom or multiple images. - (size (* 40 (expt 2 20))) - (label "GNU-ESP") ;cosmetic only - ;; Use "vfat" here since this property is used - ;; when mounting. The actual FAT-ness is based - ;; on filesystem size (16 in this case). - (file-system "vfat") - (flags '(esp)))))) + (partitions + (append + (list (partition + (size root-size) + (label #$file-system-label) + (uuid #$(and=> file-system-uuid + uuid-bytevector)) + (file-system #$file-system-type) + (flags '(boot)) + (initializer initialize))) + ;; Append a small EFI System Partition for use with UEFI + ;; bootloaders if we are not targetting ARM because UEFI + ;; support in U-Boot is experimental. + ;; + ;; FIXME: ‘target-arm32?’ may be not operate on the right + ;; system/target values. Rewrite using ‘let-system’ when + ;; available. + (if #$(target-arm32?) + '() + (list (partition + ;; The standalone grub image is about 10MiB, but + ;; leave some room for custom or multiple images. + (size (* 40 (expt 2 20))) + (label "GNU-ESP") ;cosmetic only + ;; Use "vfat" here since this property is used + ;; when mounting. The actual FAT-ness is based + ;; on filesystem size (16 in this case). + (file-system "vfat") + (flags '(esp)))))))) (initialize-hard-disk "/dev/vda" #:partitions partitions #:grub-efi #$grub-efi -- cgit 1.4.1 From 04bbd07218b5e67068219b90ff99df9580c47c0e Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Sat, 2 Dec 2017 13:58:05 +0100 Subject: system: vm: Fix typo in comment. * gnu/system/vm.scm (qemu-image): Fix typo targetting -> targeting. --- gnu/system/vm.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gnu/system/vm.scm') diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm index 8cd4c064f9..b68cce3eb5 100644 --- a/gnu/system/vm.scm +++ b/gnu/system/vm.scm @@ -324,7 +324,7 @@ the image." (flags '(boot)) (initializer initialize))) ;; Append a small EFI System Partition for use with UEFI - ;; bootloaders if we are not targetting ARM because UEFI + ;; bootloaders if we are not targeting ARM because UEFI ;; support in U-Boot is experimental. ;; ;; FIXME: ‘target-arm32?’ may be not operate on the right -- cgit 1.4.1 From 4307397b5e060b54d69b7d2818654504ebde9c1d Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Fri, 1 Dec 2017 14:09:38 +0100 Subject: bootloader: extlinux: Stop using dd binary. * gnu/bootloader/extlinux.scm (dd): Remove it, (install-extlinux): replace dd call by Guile I/O procedures. * gnu/system/vm.scm (qemu-image): Add (ice-9 binary-ports) to used-modules list to provide "get-bytevector-n" and "put-bytevector". * guix/scripts/system.scm (bootloader-installer-derivation): Ditto. --- gnu/bootloader/extlinux.scm | 20 +++++++++----------- gnu/system/vm.scm | 3 ++- guix/scripts/system.scm | 3 ++- 3 files changed, 13 insertions(+), 13 deletions(-) (limited to 'gnu/system/vm.scm') diff --git a/gnu/bootloader/extlinux.scm b/gnu/bootloader/extlinux.scm index 0db5598fc9..9b6e2c7f2a 100644 --- a/gnu/bootloader/extlinux.scm +++ b/gnu/bootloader/extlinux.scm @@ -85,14 +85,6 @@ TIMEOUT ~a~%" ;;; Install procedures. ;;; -(define dd - #~(lambda (bs count if of) - (zero? (system* "dd" - (string-append "bs=" (number->string bs)) - (string-append "count=" (number->string count)) - (string-append "if=" if) - (string-append "of=" of))))) - (define (install-extlinux mbr) #~(lambda (bootloader device mount-point) (let ((extlinux (string-append bootloader "/sbin/extlinux")) @@ -101,9 +93,15 @@ TIMEOUT ~a~%" (for-each (lambda (file) (install-file file install-dir)) (find-files syslinux-dir "\\.c32$")) - - (unless (and (zero? (system* extlinux "--install" install-dir)) - (#$dd 440 1 (string-append syslinux-dir "/" #$mbr) device)) + (unless + (and (zero? (system* extlinux "--install" install-dir)) + (call-with-input-file (string-append syslinux-dir "/" #$mbr) + (lambda (input) + (let ((bv (get-bytevector-n input 440))) + (call-with-output-file device + (lambda (output) + (put-bytevector output bv)) + #:binary #t))))) (error "failed to install SYSLINUX"))))) (define install-extlinux-mbr diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm index b68cce3eb5..d754ac76f0 100644 --- a/gnu/system/vm.scm +++ b/gnu/system/vm.scm @@ -278,7 +278,8 @@ the image." #~(begin (use-modules (gnu build vm) (guix build utils) - (srfi srfi-26)) + (srfi srfi-26) + (ice-9 binary-ports)) (let ((inputs '#$(append (list qemu parted e2fsprogs dosfstools) diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index 91d151d22b..e2ff42693f 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -676,7 +676,8 @@ and TARGET arguments." (gexp->file "bootloader-installer" (with-imported-modules '((guix build utils)) #~(begin - (use-modules (guix build utils)) + (use-modules (guix build utils) + (ice-9 binary-ports)) (#$installer #$bootloader #$device #$target)))))) (define* (perform-action action os -- cgit 1.4.1