GNU bug report logs - #27661
[PATCH] build: Make ISO-9660 image bootable from USB flash drive.

Previous Next

Package: guix-patches;

Reported by: Danny Milosavljevic <dannym <at> scratchpost.org>

Date: Wed, 12 Jul 2017 07:06:02 UTC

Severity: normal

Tags: patch

Done: Danny Milosavljevic <dannym <at> scratchpost.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 27661 in the body.
You can then email your comments to 27661 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#27661; Package guix-patches. (Wed, 12 Jul 2017 07:06:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Danny Milosavljevic <dannym <at> scratchpost.org>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Wed, 12 Jul 2017 07:06:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: guix-patches <at> gnu.org
Cc: Danny Milosavljevic <dannym <at> scratchpost.org>
Subject: [PATCH] build: Make ISO-9660 image bootable from USB flash drive.
Date: Wed, 12 Jul 2017 09:05:08 +0200
* gnu/build/vm.scm (make-iso9660-image): Make image bootable from USB flash
drive.
---
 gnu/build/vm.scm | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm
index 2d41c5756..b686ef298 100644
--- a/gnu/build/vm.scm
+++ b/gnu/build/vm.scm
@@ -367,6 +367,8 @@ Grub configuration and OS-DRV as the stuff in it."
                             "var=/tmp/root/var"
                             "run=/tmp/root/run"
                             "--"
+                            ;; Store two copies of the headers
+                            "-boot_image" "any" "partition_offset=16"
                             "-volid" ,(string-upcase volume-id)
                             ,@(if volume-uuid
                                   `("-volume_date" "uuid"




Information forwarded to guix-patches <at> gnu.org:
bug#27661; Package guix-patches. (Wed, 12 Jul 2017 12:21:02 GMT) Full text and rfc822 format available.

Message #8 received at 27661 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Danny Milosavljevic <dannym <at> scratchpost.org>
Cc: 27661 <at> debbugs.gnu.org
Subject: Re: [bug#27661] [PATCH] build: Make ISO-9660 image bootable from USB
 flash drive.
Date: Wed, 12 Jul 2017 14:20:43 +0200
Danny Milosavljevic <dannym <at> scratchpost.org> skribis:

> * gnu/build/vm.scm (make-iso9660-image): Make image bootable from USB flash
> drive.
> ---
>  gnu/build/vm.scm | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm
> index 2d41c5756..b686ef298 100644
> --- a/gnu/build/vm.scm
> +++ b/gnu/build/vm.scm
> @@ -367,6 +367,8 @@ Grub configuration and OS-DRV as the stuff in it."
>                              "var=/tmp/root/var"
>                              "run=/tmp/root/run"
>                              "--"
> +                            ;; Store two copies of the headers
> +                            "-boot_image" "any" "partition_offset=16"

I think you’ll have to expound in the comment because it doesn’t sound
trivial.  :-)

Thanks,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#27661; Package guix-patches. (Wed, 12 Jul 2017 13:45:02 GMT) Full text and rfc822 format available.

Message #11 received at 27661 <at> debbugs.gnu.org (full text, mbox):

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: 27661 <at> debbugs.gnu.org
Cc: Danny Milosavljevic <dannym <at> scratchpost.org>
Subject: [PATCH v2] build: Make ISO-9660 image bootable from USB flash drive.
Date: Wed, 12 Jul 2017 15:44:05 +0200
* gnu/build/vm.scm (make-iso9660-image): Make image bootable from USB flash
drive.
---
 gnu/build/vm.scm | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm
index 2d41c5756..d8c53ef37 100644
--- a/gnu/build/vm.scm
+++ b/gnu/build/vm.scm
@@ -367,6 +367,19 @@ Grub configuration and OS-DRV as the stuff in it."
                             "var=/tmp/root/var"
                             "run=/tmp/root/run"
                             "--"
+                            ;; Store two copies of the headers.
+                            ;; The resulting ISO-9660 image has a DOS MBR and
+                            ;; one protective partition (with type 0xCD).
+                            ;; Because GuixSD only uses actual partitions
+                            ;; rather than what /proc/partitions returns, work
+                            ;; around it by storing the primary volume
+                            ;; descriptor twice, once where it should be and
+                            ;; once in the partition.
+                            ;; Allegedly, otherwise, many other GNU tools
+                            ;; (automounters etc) would also be confused by
+                            ;; the extra partition so it makes sense to
+                            ;; store two copies in any case.
+                            "-boot_image" "any" "partition_offset=16"
                             "-volid" ,(string-upcase volume-id)
                             ,@(if volume-uuid
                                   `("-volume_date" "uuid"




Information forwarded to guix-patches <at> gnu.org:
bug#27661; Package guix-patches. (Wed, 12 Jul 2017 14:09:02 GMT) Full text and rfc822 format available.

Message #14 received at 27661 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Danny Milosavljevic <dannym <at> scratchpost.org>
Cc: 27661 <at> debbugs.gnu.org
Subject: Re: [bug#27661] [PATCH v2] build: Make ISO-9660 image bootable from
 USB flash drive.
Date: Wed, 12 Jul 2017 16:08:02 +0200
Danny Milosavljevic <dannym <at> scratchpost.org> skribis:

> * gnu/build/vm.scm (make-iso9660-image): Make image bootable from USB flash
> drive.
> ---
>  gnu/build/vm.scm | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
>
> diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm
> index 2d41c5756..d8c53ef37 100644
> --- a/gnu/build/vm.scm
> +++ b/gnu/build/vm.scm
> @@ -367,6 +367,19 @@ Grub configuration and OS-DRV as the stuff in it."
>                              "var=/tmp/root/var"
>                              "run=/tmp/root/run"
>                              "--"
> +                            ;; Store two copies of the headers.
> +                            ;; The resulting ISO-9660 image has a DOS MBR and
> +                            ;; one protective partition (with type 0xCD).
> +                            ;; Because GuixSD only uses actual partitions
> +                            ;; rather than what /proc/partitions returns, work
> +                            ;; around it by storing the primary volume
> +                            ;; descriptor twice, once where it should be and
> +                            ;; once in the partition.
> +                            ;; Allegedly, otherwise, many other GNU tools
> +                            ;; (automounters etc) would also be confused by
> +                            ;; the extra partition so it makes sense to
> +                            ;; store two copies in any case.
> +                            "-boot_image" "any" "partition_offset=16"

Now I understand.  :-)

Perfect, thank you!

Ludo’.




bug closed, send any further explanations to 27661 <at> debbugs.gnu.org and Danny Milosavljevic <dannym <at> scratchpost.org> Request was from Danny Milosavljevic <dannym <at> scratchpost.org> to control <at> debbugs.gnu.org. (Wed, 12 Jul 2017 14:16:01 GMT) Full text and rfc822 format available.

Information forwarded to guix-patches <at> gnu.org:
bug#27661; Package guix-patches. (Wed, 12 Jul 2017 17:30:02 GMT) Full text and rfc822 format available.

Message #19 received at 27661-done <at> debbugs.gnu.org (full text, mbox):

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: ludo <at> gnu.org (Ludovic Courtès)
Cc: 27661-done <at> debbugs.gnu.org
Subject: ISO-9660 image working and ready
Date: Wed, 12 Jul 2017 19:28:27 +0200
Thanks!

Pushed.

If we want we can (in the future) provide only the iso9660 image on the homepage (for x86_64).

It will work from CD and USB flash drive - that should cover all the options.

(Usually, ARM systems have a more involved boot process and will not work, neither from SD card nor from CD-ROM - and booting from USB flash drive is out of the question).

Of course it would be nice if people could test the iso9660 image a bit (especially on UEFI systems of which I have none).

To generate one, for example do this:

guix system disk-image -t iso9660 foo.scm # will print the name of the directory that contains "guixsd.iso" in the end.

where foo.scm contains:

(use-modules (gnu))
(use-package-modules linux bootloaders)
(use-service-modules base networking ssh)

(operating-system
  (host-name "beagle-bone-black")
  (timezone "Europe/Zurich")
  (locale "en_US.UTF-8")

  (bootloader (grub-configuration (device "/dev/vda")))
  (kernel linux-libre)

  (file-systems
   (cons
    (file-system
      (mount-point "/")
      (type "iso9660")
      (title 'label)
      (device "gnu-disk-image"))
    %base-file-systems))

  (users
   (cons*
    (user-account
     (name "test")
     (group "users")
     (supplementary-groups '("wheel" "video"))
     (home-directory "/home/test")
     (password "sa5JEXtYx/rm6")) ; Password is pass.
    %base-user-accounts))

  (services
   (cons*
    (dropbear-service)
    (dhcp-client-service)
    %base-services)))




Information forwarded to guix-patches <at> gnu.org:
bug#27661; Package guix-patches. (Wed, 12 Jul 2017 20:39:01 GMT) Full text and rfc822 format available.

Message #22 received at 27661-done <at> debbugs.gnu.org (full text, mbox):

From: ng0 <ng0 <at> infotropique.org>
To: Danny Milosavljevic <dannym <at> scratchpost.org>
Cc: 27661-done <at> debbugs.gnu.org
Subject: Re: [bug#27661] ISO-9660 image working and ready
Date: Wed, 12 Jul 2017 20:37:52 +0000
[Message part 1 (text/plain, inline)]
Danny Milosavljevic transcribed 1.4K bytes:
> Thanks!
> 
> Pushed.
> 
> If we want we can (in the future) provide only the iso9660 image on the homepage (for x86_64).
> 
> It will work from CD and USB flash drive - that should cover all the options.

Woo! Thanks for your work on this :)

I'll test this tomorrow evening.
Exciting news.

> (Usually, ARM systems have a more involved boot process and will not work, neither from SD card nor from CD-ROM - and booting from USB flash drive is out of the question).
> 
> Of course it would be nice if people could test the iso9660 image a bit (especially on UEFI systems of which I have none).
> 
> To generate one, for example do this:
> 
> guix system disk-image -t iso9660 foo.scm # will print the name of the directory that contains "guixsd.iso" in the end.
> 
> where foo.scm contains:
> 
> (use-modules (gnu))
> (use-package-modules linux bootloaders)
> (use-service-modules base networking ssh)
> 
> (operating-system
>   (host-name "beagle-bone-black")
>   (timezone "Europe/Zurich")
>   (locale "en_US.UTF-8")
> 
>   (bootloader (grub-configuration (device "/dev/vda")))
>   (kernel linux-libre)
> 
>   (file-systems
>    (cons
>     (file-system
>       (mount-point "/")
>       (type "iso9660")
>       (title 'label)
>       (device "gnu-disk-image"))
>     %base-file-systems))
> 
>   (users
>    (cons*
>     (user-account
>      (name "test")
>      (group "users")
>      (supplementary-groups '("wheel" "video"))
>      (home-directory "/home/test")
>      (password "sa5JEXtYx/rm6")) ; Password is pass.
>     %base-user-accounts))
> 
>   (services
>    (cons*
>     (dropbear-service)
>     (dhcp-client-service)
>     %base-services)))
> 
> 
> 
> 

-- 
ng0
GnuPG: A88C8ADD129828D7EAC02E52E22F9BBFEE348588
GnuPG: https://n0is.noblogs.org/my-keys
https://www.infotropique.org https://krosos.org
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#27661; Package guix-patches. (Thu, 13 Jul 2017 18:54:02 GMT) Full text and rfc822 format available.

Message #25 received at 27661-done <at> debbugs.gnu.org (full text, mbox):

From: Marius Bakke <mbakke <at> fastmail.com>
To: Danny Milosavljevic <dannym <at> scratchpost.org>, Ludovic Courtès <ludo <at> gnu.org>
Cc: 27661-done <at> debbugs.gnu.org
Subject: Re: [bug#27661] ISO-9660 image working and ready
Date: Thu, 13 Jul 2017 20:53:50 +0200
[Message part 1 (text/plain, inline)]
Danny Milosavljevic <dannym <at> scratchpost.org> writes:

> Thanks!
>
> Pushed.
>
> If we want we can (in the future) provide only the iso9660 image on the homepage (for x86_64).
>
> It will work from CD and USB flash drive - that should cover all the options.
>
> (Usually, ARM systems have a more involved boot process and will not work, neither from SD card nor from CD-ROM - and booting from USB flash drive is out of the question).
>
> Of course it would be nice if people could test the iso9660 image a bit (especially on UEFI systems of which I have none).

It does not work on UEFI. I tested in qemu like this:

qemu-system-x86_64 -bios $(guix build ovmf)/share/firmware/ovmf_x64.bin \
  -m 256M -enable-kvm -boot c -cdrom /gnu/store/...-disk-image/guixsd.iso

There doesn't seem to be an EFI system partition? How did you dodge my
nasty partition hack :)

Also, the derivation creates two files alongside the ISO, are those
actually required or can we make it it return the ISO directly?

Impressive work nonetheless! Many users have asked for ISO support for
use with e.g. hosting providers. And it's really cool to be able to
create a CDROM/USB, BIOS/UEFI* multi-hybrid at a whim!

* Soon™
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#27661; Package guix-patches. (Fri, 14 Jul 2017 07:31:02 GMT) Full text and rfc822 format available.

Message #28 received at 27661-done <at> debbugs.gnu.org (full text, mbox):

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: Marius Bakke <mbakke <at> fastmail.com>
Cc: Ludovic Courtès <ludo <at> gnu.org>,
 27661-done <at> debbugs.gnu.org
Subject: Re: [bug#27661] ISO-9660 image working and ready
Date: Fri, 14 Jul 2017 09:30:21 +0200
Hi Marius,

On Thu, 13 Jul 2017 20:53:50 +0200
Marius Bakke <mbakke <at> fastmail.com> wrote:

> It does not work on UEFI. I tested in qemu like this:
> 
> qemu-system-x86_64 -bios $(guix build ovmf)/share/firmware/ovmf_x64.bin \
>   -m 256M -enable-kvm -boot c -cdrom /gnu/store/...-disk-image/guixsd.iso
> 
> There doesn't seem to be an EFI system partition? How did you dodge my
> nasty partition hack :)

It's not using initialize-harddisk but rather grub-mkrescue and xorriso in order to create the filesystem.

That's because ISO-9660 filesystems are read-only and have to be created *including* the entire content in one go.

> Also, the derivation creates two files alongside the ISO, are those
> actually required 

No.

>or can we make it it return the ISO directly?

I don't know how...

> Impressive work nonetheless! Many users have asked for ISO support for
> use with e.g. hosting providers. And it's really cool to be able to
> create a CDROM/USB, BIOS/UEFI* multi-hybrid at a whim!
> 
> * Soon™

Bug #27689 fixes it a bit if the bootloader used is grub-efi.

However, that image then doesn't work with normal (non-EFI) BIOS and neither does it work with "qemu -hda".

Unfortunately I can't debug the "qemu -hda" problem properly because it seems that when UEFI is in use, "grub linux16" doesn't work any more which means I can't increase the number of lines on screen anymore (also, there's a huge penguin in the way) which means I can't see the entire error message that the guest prints.

How can I see the entire Linux kernel crash message in qemu (UEFI)?




Information forwarded to guix-patches <at> gnu.org:
bug#27661; Package guix-patches. (Fri, 14 Jul 2017 07:56:02 GMT) Full text and rfc822 format available.

Message #31 received at 27661-done <at> debbugs.gnu.org (full text, mbox):

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: Marius Bakke <mbakke <at> fastmail.com>
Cc: Ludovic Courtès <ludo <at> gnu.org>,
 27661-done <at> debbugs.gnu.org
Subject: Re: [bug#27661] ISO-9660 image working and ready
Date: Fri, 14 Jul 2017 09:55:21 +0200
Debugging:

$ qemu-system-x86_64 -bios $(guix build ovmf)/share/firmware/ovmf_x64.bin -m 1G -enable-kvm -hda Zuefi -serial stdio

Then add "console=ttyS0" to Linux cmdline in grub menu edit.

I get:

[    0.923605] scsi 0:0:0:0: Direct-Access     ATA      QEMU HARDDISK    2.5+ PQ: 0 ANSI: 5
[    0.926558] sd 0:0:0:0: [sda] 2215580 512-byte logical blocks: (1.13 GB/1.06 GiB)
[    0.928683] sd 0:0:0:0: [sda] Write Protect is off
[    0.930155] sd 0:0:0:0: Attached scsi generic sg0 type 0
[    0.931705] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[    0.934772] scsi 1:0:0:0: CD-ROM            QEMU     QEMU DVD-ROM     2.5+ PQ: 0 ANSI: 5
[    0.949039] sr 1:0:0:0: [sr0] scsi3-mmc drive: 4x/4x cd/rw xa/form2 tray
[    0.952674] cdrom: Uniform CD-ROM driver Revision: 3.20
[    0.955449]  sda: sda1 sda2 sda3 sda4
[    0.956995] sd 0:0:0:0: [sda] Attached SCSI disk
[    0.959031] sr 1:0:0:0: Attached scsi generic sg1 type 5
GC Warning: Couldn't read /proc/stat
Welcome, this is GNU's early boot Guile.
Use '--repl' for an initrd REPL.
loading '/gnu/store/48d1w55iy2vpcm5ass5lsp8almghszv8-system/boot'...
[    1.235733] attempt to access beyond end of device
[    1.237066] sda1: rw=0, want=949216, limit=76376
[    1.238565] attempt to access beyond end of device
[    1.240115] sda1: rw=0, want=949216, limit=76376
[    1.242095] attempt to access beyond end of device
[    1.243545] sda1: rw=0, want=949216, limit=76376
ERROR: In procedure primitive-load:
ERROR: In procedure fport_fill_input: Input/output error

Partitions are:

Disk Zuefi: 1.1 GiB, 1134376960 bytes, 2215580 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: DB26D0AA-65F4-4CE1-87F8-85CAD51B5C94

Device       Start     End Sectors  Size Type
Zuefi1          64   76439   76376 37.3M Microsoft basic data <----- here is a suspect
Zuefi2       76440   82199    5760  2.8M EFI System
Zuefi3       82200 2214931 2132732    1G Apple HFS/HFS+
Zuefi4     2214932 2215531     600  300K Microsoft basic data

Backtrace:

Impossible.  It did not actually enter the prompt.




Information forwarded to guix-patches <at> gnu.org:
bug#27661; Package guix-patches. (Mon, 17 Jul 2017 08:23:02 GMT) Full text and rfc822 format available.

Message #34 received at 27661-done <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Danny Milosavljevic <dannym <at> scratchpost.org>
Cc: Marius Bakke <mbakke <at> fastmail.com>, 27661-done <at> debbugs.gnu.org
Subject: Re: [bug#27661] ISO-9660 image working and ready
Date: Mon, 17 Jul 2017 10:22:29 +0200
Hello,

Danny Milosavljevic <dannym <at> scratchpost.org> skribis:

>> Also, the derivation creates two files alongside the ISO, are those
>> actually required 
>
> No.
>
>>or can we make it it return the ISO directly?
>
> I don't know how...

I also vote for returning the ISO directly, for consistency with what
‘guix system disk-image’ does for the other formats.  WDYT, Danny?  :-)

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#27661; Package guix-patches. (Mon, 17 Jul 2017 08:26:01 GMT) Full text and rfc822 format available.

Message #37 received at 27661-done <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Danny Milosavljevic <dannym <at> scratchpost.org>
Cc: Marius Bakke <mbakke <at> fastmail.com>, 27661-done <at> debbugs.gnu.org
Subject: Re: [bug#27661] ISO-9660 image working and ready
Date: Mon, 17 Jul 2017 10:25:08 +0200
Danny Milosavljevic <dannym <at> scratchpost.org> skribis:

> Debugging:
>
> $ qemu-system-x86_64 -bios $(guix build ovmf)/share/firmware/ovmf_x64.bin -m 1G -enable-kvm -hda Zuefi -serial stdio
>
> Then add "console=ttyS0" to Linux cmdline in grub menu edit.
>
> I get:
>
> [    0.923605] scsi 0:0:0:0: Direct-Access     ATA      QEMU HARDDISK    2.5+ PQ: 0 ANSI: 5
> [    0.926558] sd 0:0:0:0: [sda] 2215580 512-byte logical blocks: (1.13 GB/1.06 GiB)
> [    0.928683] sd 0:0:0:0: [sda] Write Protect is off
> [    0.930155] sd 0:0:0:0: Attached scsi generic sg0 type 0
> [    0.931705] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
> [    0.934772] scsi 1:0:0:0: CD-ROM            QEMU     QEMU DVD-ROM     2.5+ PQ: 0 ANSI: 5
> [    0.949039] sr 1:0:0:0: [sr0] scsi3-mmc drive: 4x/4x cd/rw xa/form2 tray
> [    0.952674] cdrom: Uniform CD-ROM driver Revision: 3.20
> [    0.955449]  sda: sda1 sda2 sda3 sda4
> [    0.956995] sd 0:0:0:0: [sda] Attached SCSI disk
> [    0.959031] sr 1:0:0:0: Attached scsi generic sg1 type 5
> GC Warning: Couldn't read /proc/stat
> Welcome, this is GNU's early boot Guile.
> Use '--repl' for an initrd REPL.
> loading '/gnu/store/48d1w55iy2vpcm5ass5lsp8almghszv8-system/boot'...
> [    1.235733] attempt to access beyond end of device
> [    1.237066] sda1: rw=0, want=949216, limit=76376
> [    1.238565] attempt to access beyond end of device
> [    1.240115] sda1: rw=0, want=949216, limit=76376
> [    1.242095] attempt to access beyond end of device
> [    1.243545] sda1: rw=0, want=949216, limit=76376
> ERROR: In procedure primitive-load:
> ERROR: In procedure fport_fill_input: Input/output error

It looks like the partition detection code in (gnu build file-systems)
tries to read beyond the end of disk or something.  Could you try adding
a few ‘pk’ or ‘format’ calls in there so see what’s going on?

Alternately, you could run the same QEMU command line that the
derivation spawns, so you would get a REPL (and backtrace).  For that
you can “ps aux | grep qemu” while the derivation is building, and
copy/paste the QEMU command from there.

HTH,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#27661; Package guix-patches. (Mon, 17 Jul 2017 09:05:02 GMT) Full text and rfc822 format available.

Message #40 received at 27661-done <at> debbugs.gnu.org (full text, mbox):

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: ludo <at> gnu.org (Ludovic Courtès)
Cc: Marius Bakke <mbakke <at> fastmail.com>, 27661-done <at> debbugs.gnu.org
Subject: Re: [bug#27661] ISO-9660 image working and ready
Date: Mon, 17 Jul 2017 11:04:34 +0200
Hi Ludo,

On Mon, 17 Jul 2017 10:25:08 +0200
ludo <at> gnu.org (Ludovic Courtès) wrote:

> It looks like the partition detection code in (gnu build file-systems)
> tries to read beyond the end of disk or something.  Could you try adding
> a few ‘pk’ or ‘format’ calls in there so see what’s going on?

Yeah, it tries to read beyond the end of the partition.  That's because grub-mkrescue creates a tiny fake partition which happens to start where the ISO-9660 filesystem starts and GuixSD mounts it and tries to boot from it (because it has a valid volume id).  As it is going on booting, the system boot wanders off the end of the partition and Linux tells it that it can't do that.

I've posted bug# 27705 which is the minimal set of patches to get it to work.  I just read the root filesystem directly from the whole disk there.

By now, I've also tested the resulting image on the bare metal on a real DVD on a non-EFI, non-Libreboot system.  Works fine :)

Marius, could you also test it on EFI ?

As for fixing the original partitioning problem, I didn't manage to find the place yet.  As far as I can see, grub-mkrescue uses xorriso which uses mkisofs to actually generate the ISO image.  There's a "protective" DOS MBR generated somewhere, but where.  It seems that Xorriso_coordinate_system_area and make_isohybrid_mbr are at least related somehow.  Also, it's questionable whether it's possible to fix it without creating overlapped partitions, see below.

The resulting partition table is:

Disk J: 1.1 GiB, 1137074176 bytes, 2220848 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: F86B53DD-3E7B-4B5E-A4C9-3A1A0AA56D22

Device   Start     End Sectors  Size Type
J1          64   76871   76808 37.5M Microsoft basic data <--- GuixSD tried to use this one as root
J2       76872   82631    5760  2.8M EFI System <-- mounts and reads fine as FAT FS
J3       82632 2220199 2137568    1G Apple HFS/HFS+ <--- can't find valid HFS on there
J4     2220200 2220799     600  300K Microsoft basic data <-- can't mount it

P.S. grub-mkrescue (with EFI) has a surprising number of supported architectures.  It might be that a grub-mkrescue-generated image could also boot on MIPS, Sparc, PowerPC, ARM64.

> Alternately, you could run the same QEMU command line that the
> derivation spawns, so you would get a REPL (and backtrace).  For that
> you can “ps aux | grep qemu” while the derivation is building, and
> copy/paste the QEMU command from there.

Thanks!  Very useful.




Information forwarded to guix-patches <at> gnu.org:
bug#27661; Package guix-patches. (Mon, 17 Jul 2017 19:29:02 GMT) Full text and rfc822 format available.

Message #43 received at 27661-done <at> debbugs.gnu.org (full text, mbox):

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: ludo <at> gnu.org (Ludovic Courtès)
Cc: Marius Bakke <mbakke <at> fastmail.com>, 27661-done <at> debbugs.gnu.org
Subject: Re: [bug#27661] ISO-9660 image working and ready
Date: Mon, 17 Jul 2017 21:28:37 +0200
Hi Ludo,

> I also vote for returning the ISO directly, for consistency with what
> ‘guix system disk-image’ does for the other formats.  WDYT, Danny?  :-)

Sure, I just don't know how to do that.  The other two files are "system" and "bootcfg" and contain some kind of list of gnu store paths and single-digit numbers.  Anyone can go ahead and remove those - and make it somehow pick the guixsd.iso ... *shrugs*

iso9660-image uses expression->derivation-in-linux-vm to run make-iso9660-image to create /xchg/guixsd.iso - not sure how the other two files came into being.

I could make iso9660-image delete the two other files after the fact, I guess.  But that wouldn't make system-disk-image use just one regular file as the output - without the directory.

load-in-linux-vm has a flag "make-disk-image?".  When not set (and in this case, it's really not set), it does

    (mkdir output)
    (copy-recursively "xchg" output)

.

On the other hand, when set, it creates a huge qemu disk image we don't need.

We could special-case "if there's a guixsd.iso in there, take it instead" there, but doesn't seem so nice, does it?




Information forwarded to guix-patches <at> gnu.org:
bug#27661; Package guix-patches. (Mon, 17 Jul 2017 19:59:01 GMT) Full text and rfc822 format available.

Message #46 received at 27661-done <at> debbugs.gnu.org (full text, mbox):

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: ludo <at> gnu.org (Ludovic Courtès)
Cc: Marius Bakke <mbakke <at> fastmail.com>, 27661-done <at> debbugs.gnu.org
Subject: Re: [bug#27661] ISO-9660 image working and ready
Date: Mon, 17 Jul 2017 21:58:19 +0200
I tried something like the following.  But now it throws away the output entirely.  That's not an improvement :)

But I think this is overcomplicating things - and the easiest way with only aesthetic downsides would be to punt and do nothing...

Or we could replace make-disk-image? and make-output-directory? by two parameters "initializer" and "serializer" which would be procedures that could do whatever they wanted.  I think that would be overly generic, though :)

Also, what amount of rebuilding would any change cause?  The procedures modified are already used quite often...

diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm
index d8c53ef37..2be060902 100644
--- a/gnu/build/vm.scm
+++ b/gnu/build/vm.scm
@@ -76,6 +76,7 @@
                            (qemu (qemu-command)) (memory-size 512)
                            linux initrd
                            make-disk-image?
+                           (make-output-directory? #f)
                            (disk-image-size (* 100 (expt 2 20)))
                            (disk-image-format "qcow2")
                            (references-graphs '()))
@@ -87,7 +88,9 @@ 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'."
+the #:references-graphs parameter of 'derivation'.
+
+If CREATE_OUTPUT-DIRECTORY?, creates a directory OUTPUT."
   (when make-disk-image?
     (format #t "creating ~a image of ~,2f MiB...~%"
             disk-image-format (/ disk-image-size (expt 2 20)))
@@ -137,8 +140,10 @@ the #:references-graphs parameter of 'derivation'."
 
   ;; When MAKE-DISK-IMAGE? is true, the image is in OUTPUT already.
   (unless make-disk-image?
-    (mkdir output)
-    (copy-recursively "xchg" output)))
+    (if make-output-directory?
+        (begin
+          (mkdir output)
+          (copy-recursively "xchg" output)))))
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index 66a2448ce..69ebf2377 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -106,6 +106,7 @@
                                               (%guile-for-build))
 
                                              (make-disk-image? #f)
+                                             (make-output-directory? #f)
                                              (references-graphs #f)
                                              (memory-size 256)
                                              (disk-image-format "qcow2")
@@ -121,6 +122,9 @@ DISK-IMAGE-FORMAT (e.g., 'qcow2' or 'raw'), of DISK-IMAGE-SIZE bytes and
 return it.  When DISK-IMAGE-SIZE is 'guess, estimate the image size based
 based on the size of the closure of REFERENCES-GRAPHS.
 
+When MAKE-OUTPUT-DIRECTORY? is true, then create a directory OUTPUT
+and copy the contents of /xchg there.
+
 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
 made available under the /xchg CIFS share."
@@ -164,6 +168,7 @@ made available under the /xchg CIFS share."
                                 #:linux linux #:initrd initrd
                                 #:memory-size #$memory-size
                                 #:make-disk-image? #$make-disk-image?
+                                #:make-output-directory? #$make-output-directory?
                                 #:disk-image-format #$disk-image-format
                                 #:disk-image-size size
                                 #:references-graphs graphs)))))




Information forwarded to guix-patches <at> gnu.org:
bug#27661; Package guix-patches. (Tue, 18 Jul 2017 13:10:02 GMT) Full text and rfc822 format available.

Message #49 received at 27661-done <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Danny Milosavljevic <dannym <at> scratchpost.org>
Cc: Marius Bakke <mbakke <at> fastmail.com>, 27661-done <at> debbugs.gnu.org
Subject: Re: [bug#27661] ISO-9660 image working and ready
Date: Tue, 18 Jul 2017 15:08:49 +0200
[Message part 1 (text/plain, inline)]
Hi Danny,

Danny Milosavljevic <dannym <at> scratchpost.org> skribis:

>> I also vote for returning the ISO directly, for consistency with what
>> ‘guix system disk-image’ does for the other formats.  WDYT, Danny?  :-)
>
> Sure, I just don't know how to do that.  The other two files are
> "system" and "bootcfg" and contain some kind of list of gnu store
> paths and single-digit numbers.

They are “references graphs” files, describing the closure of the given
store items.

I gave it a stab and ended up with the attached patch, which Works For
Me™ and is not unreasonably ugly to my eye.  :-)

--8<---------------cut here---------------start------------->8---
$ ./pre-inst-env guix system disk-image -t iso9660 gnu/system/install.scm 
/gnu/store/5pk71pmjp2yshkh0xdfgsnmaxfvdsms1-image.iso
ludo <at> ribbon ~/src/guix/+master$ file /gnu/store/5pk71pmjp2yshkh0xdfgsnmaxfvdsms1-image.iso
/gnu/store/5pk71pmjp2yshkh0xdfgsnmaxfvdsms1-image.iso: DOS/MBR boot sector; GRand Unified Bootloader, stage1 version 0x79, boot drive 0xbb, stage2 address 0x8e70, 1st sector stage2 0xb8db31c3, stage2 segment 0x201 ISO 9660 CD-ROM filesystem data (DOS/MBR boot sector) 'GUIXSD_IMAGE' (bootable)
--8<---------------cut here---------------end--------------->8---

WDYT?

Ludo’.

[Message part 2 (text/x-patch, inline)]
diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm
index 086f38ade..305df5933 100644
--- a/gnu/build/vm.scm
+++ b/gnu/build/vm.scm
@@ -76,11 +76,13 @@
                            (qemu (qemu-command)) (memory-size 512)
                            linux initrd
                            make-disk-image?
+                           single-file-output?
                            (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.
+the result to OUTPUT.  Unless SINGLE-FILE-OUTPUT? is true, the result is
+copied recursively to OUTPUT.
 
 When MAKE-DISK-IMAGE? is true, OUTPUT will contain a VM image of
 DISK-IMAGE-SIZE bytes resulting from the execution of BUILDER, which may
@@ -137,8 +139,14 @@ the #:references-graphs parameter of 'derivation'."
 
   ;; When MAKE-DISK-IMAGE? is true, the image is in OUTPUT already.
   (unless make-disk-image?
-    (mkdir output)
-    (copy-recursively "xchg" output)))
+    (if single-file-output?
+        (let ((graph? (lambda (name stat)
+                        (member (basename name) references-graphs))))
+          (copy-file (first (find-files "xchg" (negate graph?)))
+                     output))
+        (begin
+          (mkdir output)
+          (copy-recursively "xchg" output)))))
 
 
 ;;;
@@ -356,7 +364,7 @@ SYSTEM-DIRECTORY is the name of the directory of the 'system' derivation."
 (define* (make-iso9660-image grub config-file os-drv target
                              #:key (volume-id "GuixSD_image") (volume-uuid #f))
   "Given a GRUB package, creates an iso image as TARGET, using CONFIG-FILE as
-Grub configuration and OS-DRV as the stuff in it."
+GRUB configuration and OS-DRV as the stuff in it."
   (let ((grub-mkrescue (string-append grub "/bin/grub-mkrescue")))
     (mkdir-p "/tmp/root/var/run")
     (mkdir-p "/tmp/root/run")
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index ec3fb031a..45006b2ba 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -108,16 +108,18 @@
                                              (guile-for-build
                                               (%guile-for-build))
 
+                                             (single-file-output? #f)
                                              (make-disk-image? #f)
                                              (references-graphs #f)
                                              (memory-size 256)
                                              (disk-image-format "qcow2")
                                              (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
-copied to the derivation's output when the VM terminates.  The virtual machine
-runs with MEMORY-SIZE MiB of memory.
+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
+copied to the derivation's output when the VM terminates, recursively, unless
+SINGLE-FILE-OUTPUT? is true.  The virtual machine 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
@@ -167,6 +169,7 @@ made available under the /xchg CIFS share."
                                 #:linux linux #:initrd initrd
                                 #:memory-size #$memory-size
                                 #:make-disk-image? #$make-disk-image?
+                                #:single-file-output? #$single-file-output?
                                 #:disk-image-format #$disk-image-format
                                 #:disk-image-size size
                                 #:references-graphs graphs)))))
@@ -222,6 +225,7 @@ INPUTS is a list of inputs (as for packages)."
            (reboot))))
    #:system system
    #:make-disk-image? #f
+   #:single-file-output? #t
    #:references-graphs inputs))
 
 (define* (qemu-image #:key
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 65dd92e8b..0fcb6a9b0 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -579,8 +579,12 @@ PATTERN, a string.  When PATTERN is #f, display all the system generations."
                                                 (* 70 (expt 2 20)))
                                             #:mappings mappings))
     ((disk-image)
-     (system-disk-image os #:disk-image-size image-size
-                           #:file-system-type file-system-type))))
+     (system-disk-image os
+                        #:name (match file-system-type
+                                 ("iso9660" "image.iso")
+                                 (_         "disk-image"))
+                        #:disk-image-size image-size
+                        #:file-system-type file-system-type))))
 
 (define (maybe-suggest-running-guix-pull)
   "Suggest running 'guix pull' if this has never been done before."

Information forwarded to guix-patches <at> gnu.org:
bug#27661; Package guix-patches. (Tue, 18 Jul 2017 14:32:02 GMT) Full text and rfc822 format available.

Message #52 received at 27661-done <at> debbugs.gnu.org (full text, mbox):

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: ludo <at> gnu.org (Ludovic Courtès)
Cc: Marius Bakke <mbakke <at> fastmail.com>, 27661-done <at> debbugs.gnu.org
Subject: Re: [bug#27661] ISO-9660 image working and ready
Date: Tue, 18 Jul 2017 16:30:56 +0200
Hi Ludo,

On Tue, 18 Jul 2017 15:08:49 +0200 ludo <at> gnu.org (Ludovic Courtès) wrote:
>--- a/gnu/build/vm.scm
>+the result to OUTPUT.  Unless SINGLE-FILE-OUTPUT? is true, the result is
>+copied recursively to OUTPUT.

What happens when SINGLE-FILE-OUTPUT? is true? :)

I'd say something like,

If SINGLE-FILE-OUTPUT? is true, copy a single file from /xchg to OUTPUT.
Otherwise, copy the contents of /xchg to a new directory OUTPUT.

>+    (if single-file-output?
>+        (let ((graph? (lambda (name stat)
>+                        (member (basename name) references-graphs))))
>+          (copy-file (first (find-files "xchg" (negate graph?)))

Maybe raise error when there's more than one possibility?

>+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
>+copied to the derivation's output when the VM terminates, recursively, unless
>+SINGLE-FILE-OUTPUT? is true. 

What if it's true?

>+++ b/guix/scripts/system.scm
[...]
>+     (system-disk-image os
>+                        #:name (match file-system-type
>+                                 ("iso9660" "image.iso")
>+                                 (_         "disk-image"))

If we called it "disk-image" in the iso9660 case as well we'd not have this special case.  Do we want to?

Overall LGTM!




Information forwarded to guix-patches <at> gnu.org:
bug#27661; Package guix-patches. (Tue, 18 Jul 2017 20:58:02 GMT) Full text and rfc822 format available.

Message #55 received at 27661-done <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Danny Milosavljevic <dannym <at> scratchpost.org>
Cc: Marius Bakke <mbakke <at> fastmail.com>, 27661-done <at> debbugs.gnu.org
Subject: Re: [bug#27661] ISO-9660 image working and ready
Date: Tue, 18 Jul 2017 22:57:27 +0200
Danny Milosavljevic <dannym <at> scratchpost.org> skribis:

> On Tue, 18 Jul 2017 15:08:49 +0200 ludo <at> gnu.org (Ludovic Courtès) wrote:
>>--- a/gnu/build/vm.scm
>>+the result to OUTPUT.  Unless SINGLE-FILE-OUTPUT? is true, the result is
>>+copied recursively to OUTPUT.
>
> What happens when SINGLE-FILE-OUTPUT? is true? :)
>
> I'd say something like,
>
> If SINGLE-FILE-OUTPUT? is true, copy a single file from /xchg to OUTPUT.
> Otherwise, copy the contents of /xchg to a new directory OUTPUT.
>
>>+    (if single-file-output?
>>+        (let ((graph? (lambda (name stat)
>>+                        (member (basename name) references-graphs))))
>>+          (copy-file (first (find-files "xchg" (negate graph?)))
>
> Maybe raise error when there's more than one possibility?
>
>>+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
>>+copied to the derivation's output when the VM terminates, recursively, unless
>>+SINGLE-FILE-OUTPUT? is true. 
>
> What if it's true?

All good points, indeed.  Pushed with these changes as
8d033e3e1607d5722ef7288208551d0331c8a853.

>>+++ b/guix/scripts/system.scm
> [...]
>>+     (system-disk-image os
>>+                        #:name (match file-system-type
>>+                                 ("iso9660" "image.iso")
>>+                                 (_         "disk-image"))
>
> If we called it "disk-image" in the iso9660 case as well we'd not have this special case.  Do we want to?

I find it marginally nicer to have an explicit “.iso” suffix.  I pushed
this part as 5058bf56843baf3c0d82fbf0addbb30f00572428.

Thank you!

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#27661; Package guix-patches. (Thu, 20 Jul 2017 17:23:02 GMT) Full text and rfc822 format available.

Message #58 received at 27661-done <at> debbugs.gnu.org (full text, mbox):

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: adam <at> vany.ca
Cc: 27661-done <at> debbugs.gnu.org
Subject: Re: [bug#27661] ISO-9660 image working and ready
Date: Thu, 20 Jul 2017 19:22:44 +0200
Hi,

Adam Van Ymeren wrote on Mon, 17 Jul 2017 22:34:34 -0400:
>No luck booting the prodced guixsd.iso burned to a DVD on my UEFI system.  It does boot fine if I disable UEFI boot.

>That being said, it's possible that my system just doesn't supporting booting from DVDs in UEFI mode.  I'm going to try to rule that out by finding some other iso reported to work on UEFI systems.

Hmm, was that with patches from bug# 27695 (grub-hybrid-bootloader) or with patches from bug# 27705 (grub-efi patched to include some grub-pc files) ?




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 18 Aug 2017 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 6 years and 275 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.