[PATCH] build: Make ISO-9660 image bootable from USB flash drive.

  • Done
  • quality assurance status badge
Details
4 participants
  • Danny Milosavljevic
  • Ludovic Courtès
  • Marius Bakke
  • ng0
Owner
unassigned
Submitted by
Danny Milosavljevic
Severity
normal

Debbugs page

Danny Milosavljevic wrote 8 years ago
(address . guix-patches@gnu.org)(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
20170712070508.5908-1-dannym@scratchpost.org
* gnu/build/vm.scm (make-iso9660-image): Make image bootable from USB flash
drive.
---
gnu/build/vm.scm | 2 ++
1 file changed, 2 insertions(+)

Toggle diff (13 lines)
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"
Ludovic Courtès wrote 8 years ago
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)(address . 27661@debbugs.gnu.org)
87d195etic.fsf@gnu.org
Danny Milosavljevic <dannym@scratchpost.org> skribis:

Toggle quote (17 lines)
> * 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’.
Danny Milosavljevic wrote 8 years ago
[PATCH v2] build: Make ISO-9660 image bootable from USB flash drive.
(address . 27661@debbugs.gnu.org)(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
20170712134405.25274-1-dannym@scratchpost.org
* gnu/build/vm.scm (make-iso9660-image): Make image bootable from USB flash
drive.
---
gnu/build/vm.scm | 13 +++++++++++++
1 file changed, 13 insertions(+)

Toggle diff (24 lines)
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"
Ludovic Courtès wrote 8 years ago
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)(address . 27661@debbugs.gnu.org)
87inixd9z1.fsf@gnu.org
Danny Milosavljevic <dannym@scratchpost.org> skribis:

Toggle quote (28 lines)
> * 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’.
Danny Milosavljevic wrote 8 years ago
(no subject)
(address . control@debbugs.gnu.org)
20170712161515.31fa886c@scratchpost.org
close 27661
Danny Milosavljevic wrote 8 years ago
ISO-9660 image working and ready
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 27661-done@debbugs.gnu.org)
20170712192827.22b7c740@scratchpost.org
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)))
Closed
ng0 wrote 8 years ago
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)(address . 27661-done@debbugs.gnu.org)
20170712203752.4u27xie4mcc3zvmm@abyayala
Danny Milosavljevic transcribed 1.4K bytes:
Toggle quote (8 lines)
> 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.

Toggle quote (51 lines)
> (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
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEEqIyK3RKYKNfqwC5S4i+bv+40hYgFAllmiKAACgkQ4i+bv+40
hYiw4A/+NC0VypR++IoiUSZLnZftT2Zsh82ijh3alDpuvMRzedsCmjjaxGeVC4dj
pFRuHGl35ULkBhXu0TpHcMopWd2C6XqBDgw/bbhatlgsikT3u4qBOmmy2En8/xkj
KcLGIBKxOXy3rTWMW+vbMwjyralvaOcHK4WjBKuC/ejc8yFlnN2fmbBx3F6Knxcm
RFkVklO8LaDXSQ0ULc0FIi/iMxiErtMNx2QPS5m9EnTpHJ2W8eGeq4xOYZ27obCj
fwP6vH1x6V8QpjM6nc1yAmAtLDwS6nlKQpAEsodNraEvSVUTW5Ru+HjS80MtN8Ip
J2gTnq2rLXAj7b05PAIldevyc/Kc1q912931sNbWM97Uryb+FQaJdnhXHqexCgEe
Y6uzYZw1VAYHBIGhVpYh92SpfJfbDwtVv+BvcmmU97DTomgyXdI7S4uorZcTprew
xaAF5EFnqGxTFw77EppZSs05hJQ+UqkLzK9F/r3KHBqYJgjxdtNDoGaON+I3diiK
eLwwIJ0wmsPWODLcqQHZAQzzzsB4s/Isiw2wWwH0NDYh0FSEyqFEy/xSeGVLh/G5
bf75uP1OK5nKM9LKBuA14Fz/LHGiM4jw6r9e5qOBjMwujIvLrHExiG17KDwFO9pi
KxRXwjU57S9Mb6Mq7IBpWfWIEwuAsBRyUoKw2HjuYmkP52upNIs=
=gJQd
-----END PGP SIGNATURE-----


Closed
Marius Bakke wrote 8 years ago
(address . 27661-done@debbugs.gnu.org)
87eftkjhhd.fsf@fastmail.com
Danny Milosavljevic <dannym@scratchpost.org> writes:

Toggle quote (12 lines)
> 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™
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCgAdFiEEu7At3yzq9qgNHeZDoqBt8qM6VPoFAllnwb4ACgkQoqBt8qM6
VPrcmggArE4RpvaVysuhpoRGgPBLe6bJe4CTV44yNqYF4p8wZgt+ZWvUC0AEgITC
nxNyEebAtEaaNfxDK8yT8TZgPb07Bg4u4zsxK7LVWaKtdLXmNk7stW9qHewo07+n
tFZmgvewiOa5sODV4yNl3/oB7JWjB8UOPAJO02uqEkM06RZoCNitqA2p37K9snfQ
BZfvuV5ac0bGgi0BFz5Ge9odPuxNyde7mi4yRuHiQcXjhIpXfu/QZwHsvQ7qHM+3
T5QIy/iVakSOH0hZYgI9JTfev4padarCSIRTA30YZoUiHkOix/NSeOdRekcEwrHE
O5UsqIvlcxRdunHS97hv11Pb2N/W9Q==
=sL7n
-----END PGP SIGNATURE-----

Closed
Danny Milosavljevic wrote 8 years ago
(name . Marius Bakke)(address . mbakke@fastmail.com)
20170714093021.1b162844@scratchpost.org
Hi Marius,

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

Toggle quote (8 lines)
> 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.

Toggle quote (3 lines)
> Also, the derivation creates two files alongside the ISO, are those
> actually required

No.

Toggle quote (2 lines)
>or can we make it it return the ISO directly?

I don't know how...

Toggle quote (6 lines)
> 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)?
Closed
Danny Milosavljevic wrote 8 years ago
(name . Marius Bakke)(address . mbakke@fastmail.com)
20170714095521.10045e44@scratchpost.org
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.
Closed
Ludovic Courtès wrote 8 years ago
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
87bmojfp6i.fsf@gnu.org
Hello,

Danny Milosavljevic <dannym@scratchpost.org> skribis:

Toggle quote (9 lines)
>> 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’.
Closed
Ludovic Courtès wrote 8 years ago
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
8760erfp23.fsf@gnu.org
Danny Milosavljevic <dannym@scratchpost.org> skribis:

Toggle quote (32 lines)
> 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’.
Closed
Danny Milosavljevic wrote 8 years ago
(name . Ludovic Courtès)(address . ludo@gnu.org)
20170717110434.1576628d@scratchpost.org
Hi Ludo,

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

Toggle quote (4 lines)
> 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.

Toggle quote (5 lines)
> 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.
Closed
Danny Milosavljevic wrote 8 years ago
(name . Ludovic Courtès)(address . ludo@gnu.org)
20170717212837.10c1d0b3@scratchpost.org
Hi Ludo,

Toggle quote (3 lines)
> 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?
Closed
Danny Milosavljevic wrote 8 years ago
(name . Ludovic Courtès)(address . ludo@gnu.org)
20170717215819.684a1578@scratchpost.org
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...

Toggle diff (63 lines)
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)))))
Closed
Ludovic Courtès wrote 8 years ago
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
87o9shyjry.fsf@gnu.org
Hi Danny,

Danny Milosavljevic <dannym@scratchpost.org> skribis:

Toggle quote (7 lines)
>> 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. :-)

Toggle snippet (6 lines)
$ ./pre-inst-env guix system disk-image -t iso9660 gnu/system/install.scm
/gnu/store/5pk71pmjp2yshkh0xdfgsnmaxfvdsms1-image.iso
ludo@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)

WDYT?

Ludo’.
Attachment: file
Closed
Danny Milosavljevic wrote 8 years ago
(name . Ludovic Courtès)(address . ludo@gnu.org)
20170718163056.77452560@scratchpost.org
Hi Ludo,

On Tue, 18 Jul 2017 15:08:49 +0200 ludo@gnu.org (Ludovic Courtès) wrote:
Toggle quote (4 lines)
>--- 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.

Toggle quote (5 lines)
>+ (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?

Toggle quote (5 lines)
>+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?

Toggle quote (1 lines)
>+++ b/guix/scripts/system.scm
[...]
Toggle quote (5 lines)
>+ (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!
Closed
Ludovic Courtès wrote 8 years ago
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
87pocxo43s.fsf@gnu.org
Danny Milosavljevic <dannym@scratchpost.org> skribis:

Toggle quote (26 lines)
> On Tue, 18 Jul 2017 15:08:49 +0200 ludo@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.

Toggle quote (9 lines)
>>+++ 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’.
Closed
Danny Milosavljevic wrote 8 years ago
(address . adam@vany.ca)(address . 27661-done@debbugs.gnu.org)
20170720192244.002d6e6a@scratchpost.org
Hi,

Adam Van Ymeren wrote on Mon, 17 Jul 2017 22:34:34 -0400:
Toggle quote (4 lines)
>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) ?
Closed
?
Your comment

This issue is archived.

To comment on this conversation send an email to 27661@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 27661
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch
You may also tag this issue. See list of standard tags. For example, to set the confirmed and easy tags
mumi command -t +confirmed -t +easy
Or, remove the moreinfo tag and set the help tag
mumi command -t -moreinfo -t +help