From 9bd218f4d91f79b26ad32cc6c4c1f479febd28de Mon Sep 17 00:00:00 2001 From: "Jan (janneke) Nieuwenhuizen" Date: Tue, 19 May 2020 16:01:42 +0200 Subject: [PATCH] WIP: disk-image qemu-system-i386 -enable-kvm -bios $(guix build ovmf)/share/firmware/ovmf_ia32.bin -hda /tmp/qemu-image -m 1024 janneke: With this patch on top of your branch: https://paste.debian.net/1147629/, I'm able to generate an EFI disk-image. [15:54] That I start with this command: qemu-system-i386 -enable-kvm -bios $(guix build ovmf)/share/firmware/ovmf_ia32.bin -hda /tmp/qemu-image -m 1024 janneke: Sadly, just after Grub, the virtual machine restarts, nothing is printed. [15:55] --- gnu/build/bootloader.scm | 2 +- gnu/build/image.scm | 18 ++++++++++-------- gnu/system/examples/bare-hurd.tmpl | 2 +- gnu/system/image.scm | 10 ++++++---- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/gnu/build/bootloader.scm b/gnu/build/bootloader.scm index 498022f6db..68b68c4b47 100644 --- a/gnu/build/bootloader.scm +++ b/gnu/build/bootloader.scm @@ -56,7 +56,7 @@ (efi-directory (string-append esp "/EFI/BOOT")) ;; Map grub target names to boot file names. (efi-targets (cond ((string-prefix? "x86_64" system) - '("x86_64-efi" . "BOOTX64.EFI")) + '("i386-efi" . "BOOTIA32.EFI")) ((string-prefix? "i686" system) '("i386-efi" . "BOOTIA32.EFI")) ((string-prefix? "armhf" system) diff --git a/gnu/build/image.scm b/gnu/build/image.scm index fe8e11aa1b..23fc56571f 100644 --- a/gnu/build/image.scm +++ b/gnu/build/image.scm @@ -63,16 +63,18 @@ take the partition metadata size into account, take a 25% margin." (* 1.25 (file-size root))) -(define* (make-ext4-image partition target root - #:key - (owner-uid 0) - (owner-gid 0)) - "Handle the creation of EXT4 partition images. See 'make-partition-image'." +(define* (make-ext-image partition target root + #:key + (owner-uid 0) + (owner-gid 0)) + "Handle the creation of EXT2/3/4 partition images. See +'make-partition-image'." (let ((size (partition-size partition)) + (fs (partition-file-system partition)) (label (partition-label partition)) (uuid (partition-uuid partition)) (options "lazy_itable_init=1,lazy_journal_init=1")) - (invoke "mke2fs" "-t" "ext4" "-d" root + (invoke "mke2fs" "-t" fs "-d" root "-L" label "-U" (uuid->string uuid) "-E" (format #f "root_owner=~a:~a,~a" owner-uid owner-gid options) @@ -105,8 +107,8 @@ ROOT directory to populate the image." (let* ((partition (sexp->partition partition-sexp)) (type (partition-file-system partition))) (cond - ((string=? type "ext4") - (make-ext4-image partition target root)) + ((string-prefix? "ext" type) + (make-ext-image partition target root)) ((string=? type "vfat") (make-vfat-image partition target root)) (else diff --git a/gnu/system/examples/bare-hurd.tmpl b/gnu/system/examples/bare-hurd.tmpl index d4c40e6841..c3adf03a7f 100644 --- a/gnu/system/examples/bare-hurd.tmpl +++ b/gnu/system/examples/bare-hurd.tmpl @@ -11,7 +11,7 @@ (operating-system (inherit %hurd-default-operating-system) (bootloader (bootloader-configuration - (bootloader grub-minimal-bootloader) + (bootloader grub-efi-bootloader) (target "/dev/sdX"))) (file-systems (cons (file-system (device (file-system-label "my-root")) diff --git a/gnu/system/image.scm b/gnu/system/image.scm index 571b7af5f3..888099dae5 100644 --- a/gnu/system/image.scm +++ b/gnu/system/image.scm @@ -79,7 +79,7 @@ (partition (size 'guess) (label "Guix_image") - (file-system "ext4") + (file-system "ext2") (flags '(boot)) (initializer (gexp initialize-root-partition)))) @@ -222,7 +222,9 @@ used in the image." #:deduplicate? #f #:system-directory #$os #:bootloader-package - #$(bootloader-package bootloader) + #+(with-parameters + ((%current-system "i686-linux")) + (bootloader-package bootloader)) #:bootcfg #$bootcfg #:bootcfg-location #$(bootloader-configuration-file bootloader))))) @@ -232,7 +234,7 @@ used in the image." (type (partition-file-system partition)) (image-builder (with-imported-modules* - (let ((inputs '#$(list e2fsprogs dosfstools mtools))) + (let ((inputs '#+(list e2fsprogs dosfstools mtools))) (set-path-environment-variable "PATH" '("bin" "sbin") inputs) (make-partition-image #$(partition->gexp partition) #$output @@ -269,7 +271,7 @@ image ~a { (let* ((substitutable? (image-substitutable? image)) (builder (with-imported-modules* - (let ((inputs '#$(list genimage coreutils findutils))) + (let ((inputs '#+(list genimage coreutils findutils))) (set-path-environment-variable "PATH" '("bin" "sbin") inputs) (genimage #$(image->genimage-cfg image) #$output)))) (image-dir (computed-file "image-dir" builder))) -- 2.26.2