Unbootable images with GuixSD on... "GuixSD"

  • Done
  • quality assurance status badge
Details
3 participants
  • Danny Milosavljevic
  • Ludovic Courtès
  • Tobias Geerinckx-Rice
Owner
unassigned
Submitted by
Tobias Geerinckx-Rice
Severity
normal
T
T
Tobias Geerinckx-Rice wrote on 17 Jul 2017 16:40
(address . bug-guix@gnu.org)
327af9f3-fdfb-7916-f0ea-9aec0fae20f3@tobias.gr
Guix,

[I lost most hours of sleep to this. I might ramble more than usual.]

The default label for images was recently changed[1] to "GuixSD".
While I think it's a fine label, that's also a problem: I've been using
it for years for my root partitions. And when one broke last night, I
couldn't use the GuixSD installer to rescue it.

The installer's now expects exactly one "GuixSD" partition when booting
— at least on UEFI. If the GRUB finds two, the GRUB will randomly
choose. In my case, the GRUB chose a frozen system.

(With a black screen that made debugging hell, but that's probably an
unrelated effect of the roughness of our UEFI support.)

The real problem here is that we're using a label as a UUID.
From gnu/build/vm.scm:

;; Create a tiny configuration file telling the embedded grub
;; where to load the real thing.
(call-with-output-file grub-config
(lambda (port)
(format port
"insmod part_msdos~@
search --set=root --label GuixSD~@
configfile /boot/grub/grub.cfg~%")))

I'm not the first to think so, as noted in gnu/system/vm.scm:

(define root-label
;; Volume name of the root file system. Since we don't know which
device
;; will hold it, we use the volume name to find it (using the UUID would
;; be even better, but somewhat less convenient.)
(normalize-label "GuixSD"))

I like that understatement. I'm not sure how to go about creating a
reproducible almost-UUID based on the store hash and passing it to all
the right places in a reasonably non-horrible manner either, random
hacker. And it would mean even more work and testing after all the
heroic effort on the new installer image + UEFI support by Danny,
Marius, and others.

Until it does happen, I suggest we change the name to "GuixSD-image"[2].
Still fragile, but not the PR fail that ‘don't call your GuixSD file
system GuixSD or it will break GuixSD’ would be.

Zzz,

T G-R

[1]:
[2]: Or whatever. I remember someone (Danny?) calling "-image" an
implementation detail. I think it's a description of the end result.
Attachment: signature.asc
T
T
Tobias Geerinckx-Rice wrote on 17 Jul 2017 16:51
[PATCH 1/2] build, vm: Use a slightly less generic label.
(address . 27735@debbugs.gnu.org)
20170717145151.12222-1-me@tobias.gr
* gnu/build/vm.scm (initialize-hard-disk): Use "GuixSD-image" as label.
* gnu/system/install.scm (installation-os): Likewise.
* gnu/system/vm.scm (system-disk-image): Likewise.
---

Or GuixSD-bikeshed or whatever.

gnu/build/vm.scm | 7 +++++--
gnu/system/install.scm | 2 +-
gnu/system/vm.scm | 2 +-
3 files changed, 7 insertions(+), 4 deletions(-)

Toggle diff (57 lines)
diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm
index d8c53ef37..e71b1b92e 100644
--- a/gnu/build/vm.scm
+++ b/gnu/build/vm.scm
@@ -354,7 +354,7 @@ SYSTEM-DIRECTORY is the name of the directory of the 'system' derivation."
(error "failed to create GRUB EFI image"))))
(define* (make-iso9660-image grub config-file os-drv target
- #:key (volume-id "GuixSD") (volume-uuid #f))
+ #: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."
(let ((grub-mkrescue (string-append grub "/bin/grub-mkrescue")))
@@ -440,11 +440,14 @@ passing it a directory name where it is mounted."
;; Create a tiny configuration file telling the embedded grub
;; where to load the real thing.
+ ;; XXX This is quite fragile, and can leave the system in an unusable
+ ;; state when there's more than one volume with this label present.
+ ;; Reproducible (not-)UUIDs could reduce the risk but not eliminate it.
(call-with-output-file grub-config
(lambda (port)
(format port
"insmod part_msdos~@
- search --set=root --label GuixSD~@
+ search --set=root --label GuixSD-image~@
configfile /boot/grub/grub.cfg~%")))
(display "creating EFI firmware image...")
diff --git a/gnu/system/install.scm b/gnu/system/install.scm
index f9aa7f673..866440eb4 100644
--- a/gnu/system/install.scm
+++ b/gnu/system/install.scm
@@ -306,7 +306,7 @@ Use Alt-F2 for documentation.
;; the appropriate one.
(cons* (file-system
(mount-point "/")
- (device "GuixSD")
+ (device "GuixSD-image")
(title 'label)
(type "ext4"))
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index dd9be2c6f..6e06781d5 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -345,7 +345,7 @@ to USB sticks meant to be read-only."
;; Volume name of the root file system. Since we don't know which device
;; will hold it, we use the volume name to find it (using the UUID would
;; be even better, but somewhat less convenient.)
- (normalize-label "GuixSD"))
+ (normalize-label "GuixSD-image"))
(define file-systems-to-keep
(remove (lambda (fs)
--
2.13.1
D
D
Danny Milosavljevic wrote on 17 Jul 2017 19:17
Re: bug#27735: Unbootable images with GuixSD on... "GuixSD"
(name . Tobias Geerinckx-Rice)(address . me@tobias.gr)(address . 27735@debbugs.gnu.org)
20170717191731.2d3ad604@scratchpost.org
Hi T G-R,

On Mon, 17 Jul 2017 16:40:56 +0200
Tobias Geerinckx-Rice <me@tobias.gr> wrote:

Toggle quote (4 lines)
> The installer's now expects exactly one "GuixSD" partition when booting
> — at least on UEFI. If the GRUB finds two, the GRUB will randomly
> choose. In my case, the GRUB chose a frozen system.

Sorry!

Toggle quote (2 lines)
> The real problem here is that we're using a label as a UUID.

I agree. Unfortunately Guix UUIDs are difficult to use consistently or I would have changed it over to begin with.

Toggle quote (14 lines)
> (define root-label
> ;; Volume name of the root file system. Since we don't know which
> device
> ;; will hold it, we use the volume name to find it (using the UUID would
> ;; be even better, but somewhat less convenient.)
> (normalize-label "GuixSD"))
>
> I like that understatement. I'm not sure how to go about creating a
> reproducible almost-UUID based on the store hash and passing it to all
> the right places in a reasonably non-horrible manner either, random
> hacker. And it would mean even more work and testing after all the
> heroic effort on the new installer image + UEFI support by Danny,
> Marius, and others.

Yeah, having the UUID actually be derived from the store hash would be good.

I think for now having a random UUID be generated would be fine too.

Toggle quote (4 lines)
> Until it does happen, I suggest we change the name to "GuixSD-image"[2].
> Still fragile, but not the PR fail that ‘don't call your GuixSD file
> system GuixSD or it will break GuixSD’ would be.

I think for the time being that's a good workaround. But I think we should get the UUIDs for booting working.

Toggle quote (2 lines)
The actual reason I had to change it is because of the dashes (which are not valid in ECMA-6 IRV).

Toggle quote (2 lines)
> [2]: Or whatever.

"GuixSD_installer" ? Well anyway, just pick one, doesn't matter much which, except that the characters have to be out of [A-Za-z0-9_] (will be uppercased for ISO-9660) because of ECMA-119 Appendix A (ECMA-6 IRV).

Toggle quote (3 lines)
>I remember someone (Danny?) calling "-image" an
> implementation detail. I think it's a description of the end result.

Yeah, that was me. I don't understand how an actual operating system on a drive is an image. Maybe I'm old-fashioned, dunno, but I think an image is something that is made up by light rays on a screen, not the real object. In the case of computing an image is a backup file of a drive, not what is on the drive to begin with.

Also, even if it were an image, the image shouldn't say "<foo> image" in the image itself. A mirror which doesn't add anything to your image when you look into it, either :)
D
D
Danny Milosavljevic wrote on 17 Jul 2017 19:20
Re: bug#27735: [PATCH 1/2] build, vm: Use a slightly less generic label.
(name . Tobias Geerinckx-Rice)(address . me@tobias.gr)(address . 27735@debbugs.gnu.org)
20170717192038.5b19d711@scratchpost.org
Dash is invalid. Otherwise OK!
T
T
Tobias Geerinckx-Rice wrote on 17 Jul 2017 19:58
4ad6ce9e-d710-df7f-9097-a214fd0b05ed@tobias.gr
Danny,

On 17/07/17 19:20, Danny Milosavljevic wrote:
Toggle quote (2 lines)
> Dash is invalid. Otherwise OK!

Good to know (I consider you an expert on file system label esoterica,
mainly so I don't have to be). Thanks!

Kind regards,

T G-R
Attachment: signature.asc
T
T
Tobias Geerinckx-Rice wrote on 17 Jul 2017 20:12
Re: bug#27735: Unbootable images with GuixSD on... "GuixSD"
(address . dannym@scratchpost.org)(address . 27735@debbugs.gnu.org)
8a8ece74-7035-9893-f62b-875cae3cfd7a@tobias.gr
On 17/07/17 19:17, Danny Milosavljevic wrote:> Hi T G-R,
Toggle quote (10 lines)
> Yeah, that was me. I don't understand how an actual operating system
> on a drive is an image. Maybe I'm old-fashioned, dunno, but I think
> an image is something that is made up by light rays on a screen, not
> the real object. In the case of computing an image is a backup file
> of a drive, not what is on the drive to begin with.
>
> Also, even if it were an image, the image shouldn't say "<foo> image"
> in the image itself. A mirror which doesn't add anything to your
> image when you look into it, either :)

I agree completely. I've become so used to dd'ing ISOs to USB drives
that I've come to think *only* in terms of fake discs, but you're right.
I chose ‘image’ reluctantly, because my first ideas (‘installer’, ‘vm’)
were even less relevant: this label's used for all disc images. Oh well.

We could choose the worst and ugliest label possible: that'd compel
someone to fix this!

(No. "GuixSD_image" it is.)

Thanks,

T G-R
Attachment: signature.asc
T
T
Tobias Geerinckx-Rice wrote on 17 Jul 2017 20:37
(address . 27735-done@debbugs.gnu.org)
2b71a313-b00b-9df8-dc38-3e8332ac184f@tobias.gr
Done with commit 0862b95433cacf91e44248097caa09119fc532a6.

Kind regards,

T G-R
Attachment: signature.asc
Closed
L
L
Ludovic Courtès wrote on 18 Jul 2017 12:09
Re: bug#27735: [PATCH 1/2] build, vm: Use a slightly less generic label.
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
87lgnm12gx.fsf@gnu.org
Danny Milosavljevic <dannym@scratchpost.org> skribis:

Toggle quote (2 lines)
> Dash is invalid. Otherwise OK!

Can we do ‘string-map’ to replace dash with underscore, just like we did
‘normalize-label’?

Ludo’.
L
L
Ludovic Courtès wrote on 18 Jul 2017 13:49
Re: bug#27735: Unbootable images with GuixSD on... "GuixSD"
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
87bmoi0xua.fsf@gnu.org
Hello,

Danny Milosavljevic <dannym@scratchpost.org> skribis:

Toggle quote (4 lines)
>> The real problem here is that we're using a label as a UUID.
>
> I agree. Unfortunately Guix UUIDs are difficult to use consistently or I would have changed it over to begin with.

What about generating a UUID in a deterministic yet somewhat unique
fashion along these lines (untested):
Toggle diff (80 lines)
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index ec3fb031a..6b53eacbf 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -56,9 +56,12 @@
#:use-module (gnu system file-systems)
#:use-module (gnu system)
#:use-module (gnu services)
+ #:use-module ((gnu build file-systems)
+ #:select (string->iso9660-uuid))
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
+ #:use-module (rnrs bytevectors)
#:use-module (ice-9 match)
#:export (expression->derivation-in-linux-vm
@@ -344,12 +347,29 @@ to USB sticks meant to be read-only."
(if (string=? "iso9660" file-system-type)
string-upcase
identity))
+
(define root-label
- ;; Volume name of the root file system. Since we don't know which device
- ;; will hold it, we use the volume name to find it (using the UUID would
- ;; be even better, but somewhat less convenient.)
+ ;; Volume name of the root file system.
(normalize-label "GuixSD_image"))
+ (define root-uuid
+ ;; UUID of the root file system, computed in a deterministic fashion.
+ (if (string=? "iso9660" file-system-type)
+ (let ((pad (compose (cut string-pad <> 2 #\0)
+ number->string)))
+ (string->iso9660-uuid
+ (string-append "1970-01-01-"
+ (pad (hash name 24))
+ (pad (hash file-system-type 60))
+ (pad (hash (operating-system-host-name os) 60)))))
+ (uint-list->bytevector
+ (list (hash (string-append file-system-type name)
+ (expt 2 64))
+ (hash (operating-system-host-name os)
+ (expt 2 64)))
+ (endianness little)
+ 8)))
+
(define file-systems-to-keep
(remove (lambda (fs)
(string=? (file-system-mount-point fs) "/"))
@@ -367,8 +387,8 @@ to USB sticks meant to be read-only."
;; Force our own root file system.
(file-systems (cons (file-system
(mount-point "/")
- (device root-label)
- (title 'label)
+ (device root-uuid)
+ (title 'uuid)
(type file-system-type))
file-systems-to-keep)))))
@@ -376,8 +396,7 @@ to USB sticks meant to be read-only."
(bootcfg (operating-system-bootcfg os)))
(if (string=? "iso9660" file-system-type)
(iso9660-image #:name name
- #:file-system-label root-label
- #:file-system-uuid #f
+ #:file-system-uuid root-uuid
#:os-drv os-drv
#:bootcfg-drv bootcfg
#:bootloader (bootloader-configuration-bootloader
@@ -395,7 +414,7 @@ to USB sticks meant to be read-only."
file-system-type)
"ext4"
file-system-type)
- #:file-system-label root-label
+ #:file-system-label root-label ;FIXME: use ROOT-UUID
#:copy-inputs? #t
#:register-closures? #t
#:inputs `(("system" ,os-drv)
We cannot use the store file name’s hash, unfortunately, because the
UUID has to be given on the “host side.”

Thoughts?

Ludo’.
T
T
Tobias Geerinckx-Rice wrote on 18 Jul 2017 14:30
Re: bug#27735: [PATCH 1/2] build, vm: Use a slightly less generic label.
(address . 27735@debbugs.gnu.org)
d106fcb3-8ac0-214f-f1c7-4860c38014aa@tobias.gr
Ludo',

On 18/07/17 12:09, Ludovic Courtès wrote:
Toggle quote (3 lines)
> Can we do ‘string-map’ to replace dash with underscore, just like we did
> ‘normalize-label’?

That would have been a better approach. :-)

Kind regards,

T G-R
Attachment: signature.asc
D
D
Danny Milosavljevic wrote on 18 Jul 2017 15:48
(name . Tobias Geerinckx-Rice)(address . me@tobias.gr)
20170718154845.5cd79c48@scratchpost.org
Hi T G-R,
Hi Ludo,

On Tue, 18 Jul 2017 14:30:10 +0200
Tobias Geerinckx-Rice <me@tobias.gr> wrote:

Toggle quote (4 lines)
> On 18/07/17 12:09, Ludovic Courtès wrote:
> > Can we do ‘string-map’ to replace dash with underscore, just like we did
> > ‘normalize-label’?

Yes.

Toggle quote (2 lines)
> That would have been a better approach. :-)

I disagree that that would be better. Every map is a source of error and also makes it difficult to follow what is going on (i.e. difficult to maintain).

Best is only to use the common intersection of all the valid charsets and not map anything to anything else.

We can map it and it's OK but it's not good in the long run. I've learnt that the hard way over many years.

But since we do string-upcase already, it doesn't matter anymore. Better hope we don't break it by accident one day (or right away), though.
T
T
Tobias Geerinckx-Rice wrote on 18 Jul 2017 17:09
Re: bug#27735: Unbootable images with GuixSD on... "GuixSD"
(address . 27735@debbugs.gnu.org)
9b7cffa7-96a4-a799-c207-854bbcc7df04@tobias.gr
Ludo',

On 18/07/17 13:49, Ludovic Courtès wrote:
Toggle quote (3 lines)
> What about generating a UUID in a deterministic yet somewhat unique
> fashion along these lines (untested):

Not great, but I can't think of a better way. :-)

Toggle quote (19 lines)
> + (define root-uuid
> + ;; UUID of the root file system, computed in a deterministic fashion.
> + (if (string=? "iso9660" file-system-type)
> + (let ((pad (compose (cut string-pad <> 2 #\0)
> + number->string)))
> + (string->iso9660-uuid
> + (string-append "1970-01-01-"
> + (pad (hash name 24))
> + (pad (hash file-system-type 60))
> + (pad (hash (operating-system-host-name os) 60)))))
> + (uint-list->bytevector
> + (list (hash (string-append file-system-type name)
> + (expt 2 64))
> + (hash (operating-system-host-name os)
> + (expt 2 64)))
> + (endianness little)
> + 8)))
> +

Why not throw SIZE into this mix as well?

When building without ‘--image-size’ (the default nowadays), it's a
function of the exact size of the entire graph and reasonably sensitive
to most kinds of input changes.

Toggle quote (3 lines)
> We cannot use the store file name’s hash, unfortunately, because the
> UUID has to be given on the “host side.”

That is unfortunate, but a best-effort heuristic will do.

Kind regards,

T G-R
Attachment: signature.asc
L
L
Ludovic Courtès wrote on 18 Jul 2017 20:59
(name . Tobias Geerinckx-Rice)(address . me@tobias.gr)
87lgnlpo4q.fsf@gnu.org
Heya,

Tobias Geerinckx-Rice <me@tobias.gr> skribis:

Toggle quote (6 lines)
> On 18/07/17 13:49, Ludovic Courtès wrote:
>> What about generating a UUID in a deterministic yet somewhat unique
>> fashion along these lines (untested):
>
> Not great, but I can't think of a better way. :-)

Yup.

Toggle quote (21 lines)
>> + (define root-uuid
>> + ;; UUID of the root file system, computed in a deterministic fashion.
>> + (if (string=? "iso9660" file-system-type)
>> + (let ((pad (compose (cut string-pad <> 2 #\0)
>> + number->string)))
>> + (string->iso9660-uuid
>> + (string-append "1970-01-01-"
>> + (pad (hash name 24))
>> + (pad (hash file-system-type 60))
>> + (pad (hash (operating-system-host-name os) 60)))))
>> + (uint-list->bytevector
>> + (list (hash (string-append file-system-type name)
>> + (expt 2 64))
>> + (hash (operating-system-host-name os)
>> + (expt 2 64)))
>> + (endianness little)
>> + 8)))
>> +
>
> Why not throw SIZE into this mix as well?

Because it can be the symbol 'guess or a number, so that makes things
needlessly complicated IMO.

Toggle quote (4 lines)
> When building without ‘--image-size’ (the default nowadays), it's a
> function of the exact size of the entire graph and reasonably sensitive
> to most kinds of input changes.

The actual size is not known until the derivation is built; we don’t
have access to that information here.

Toggle quote (5 lines)
>> We cannot use the store file name’s hash, unfortunately, because the
>> UUID has to be given on the “host side.”
>
> That is unfortunate, but a best-effort heuristic will do.

Yeah, still better than a hard-coded label I guess.

Ludo’.
T
T
Tobias Geerinckx-Rice wrote on 18 Jul 2017 22:42
(address . ludo@gnu.org)(address . 27735@debbugs.gnu.org)
350d9a8b-9916-79f6-24f5-9cf223681729@tobias.gr
Ludo',

On 18/07/17 20:59, Ludovic Courtès wrote:
Toggle quote (5 lines)
>> Why not throw SIZE into this mix as well?
>
> Because it can be the symbol 'guess or a number, so that makes things
> needlessly complicated IMO.

Of course. Thanks for your patience. I got completely lost in the
gexp/ungexps of expression->derivation-in-linux-vm. Stupid.

Kind regards,

T G-R
Attachment: signature.asc
D
D
Danny Milosavljevic wrote on 19 Jul 2017 21:11
(name . Ludovic Courtès)(address . ludo@gnu.org)
20170719211107.51ebe24b@scratchpost.org
Hi Ludo,

I think it's a good interim solution.

On Tue, 18 Jul 2017 13:49:01 +0200
ludo@gnu.org (Ludovic Courtès) wrote:

Toggle quote (3 lines)
> + (define root-uuid
> + ;; UUID of the root file system, computed in a deterministic fashion.
> + (if (string=? "iso9660" file-system-type)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Toggle quote (6 lines)
> + (let ((pad (compose (cut string-pad <> 2 #\0)
> + number->string)))
> + (string->iso9660-uuid
> + (string-append "1970-01-01-"
> + (pad (hash name 24))
> + (pad (hash file-system-type 60))
^^^^^^^^^^^^^^^^^^^^^^^^^^ hmm... isn't that constant?
L
L
Ludovic Courtès wrote on 20 Jul 2017 00:32
Lookup by UUID
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
87tw28kqh6.fsf_-_@gnu.org
Hi!

Danny Milosavljevic <dannym@scratchpost.org> skribis:

Toggle quote (2 lines)
> I think it's a good interim solution.

Based on your feedback I’ve come up with the two attached patches. I’ve
checked at the REPL that ‘operating-system-uuid’ gives reasonable
results for different ‘operating-system’ configs, and deterministic
results for a given config (OSes that are not ‘eq?’ but that are equal.)

On ext4 “guix system disk-image” produces an image that works like a
charm.

With iso9660, it works… by chance, because GRUB’s “search --fs-uuid”
fails. Guess why? Because it compares UUIDs as strings, and we format
it as a DCE UUID instead of an ISO UUID. Sounds familiar no? :-)

So that’s where we are. Thoughts on how to address it?

Cheers,
Ludo’.
From 00d49f0199dc51b02f2113c3669ea07f4461b102 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@gnu.org>
Date: Thu, 20 Jul 2017 00:15:43 +0200
Subject: [PATCH] vm: Allow partitions to be initialized with a given UUID.

* gnu/build/vm.scm (<partition>)[uuid]: New field.
(create-ext-file-system): Add #:uuid and honor it.
(create-fat-file-system): Add #:uuid.
(format-partition): Add #:uuid and honor it.
(initialize-partition): Honor the 'uuid' field of PARTITION.
---
gnu/build/vm.scm | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)

Toggle diff (74 lines)
diff --git a/gnu/build/vm.scm b/gnu/build/vm.scm
index 727494ad9..8dfaf2789 100644
--- a/gnu/build/vm.scm
+++ b/gnu/build/vm.scm
@@ -163,6 +163,7 @@ the #:references-graphs parameter of 'derivation'."
(size partition-size)
(file-system partition-file-system (default "ext4"))
(label partition-label (default #f))
+ (uuid partition-uuid (default #f))
(flags partition-flags (default '()))
(initializer partition-initializer (default (const #t))))
@@ -236,22 +237,26 @@ actual /dev name based on DEVICE."
(define MS_BIND 4096) ; <sys/mounts.h> again!
(define* (create-ext-file-system partition type
- #:key label)
+ #:key label uuid)
"Create an ext-family filesystem of TYPE on PARTITION. If LABEL is true,
-use that as the volume name."
+use that as the volume name. If UUID is true, use it as the partition UUID."
(format #t "creating ~a partition...\n" type)
(unless (zero? (apply system* (string-append "mkfs." type)
"-F" partition
- (if label
- `("-L" ,label)
- '())))
+ `(,@(if label
+ `("-L" ,label)
+ '())
+ ,@(if uuid
+ `("-U" ,(uuid->string uuid))
+ '()))))
(error "failed to create partition")))
(define* (create-fat-file-system partition
- #:key label)
+ #:key label uuid)
"Create a FAT filesystem on PARTITION. The number of File Allocation Tables
will be determined based on filesystem size. If LABEL is true, use that as the
volume name."
+ ;; FIXME: UUID is ignored!
(format #t "creating FAT partition...\n")
(unless (zero? (apply system* "mkfs.fat" partition
(if label
@@ -260,13 +265,13 @@ volume name."
(error "failed to create FAT partition")))
(define* (format-partition partition type
- #:key label)
+ #:key label uuid)
"Create a file system TYPE on PARTITION. If LABEL is true, use that as the
volume name."
(cond ((string-prefix? "ext" type)
- (create-ext-file-system partition type #:label label))
+ (create-ext-file-system partition type #:label label #:uuid uuid))
((or (string-prefix? "fat" type) (string= "vfat" type))
- (create-fat-file-system partition #:label label))
+ (create-fat-file-system partition #:label label #:uuid uuid))
(else (error "Unsupported file system."))))
(define (initialize-partition partition)
@@ -275,7 +280,8 @@ it, run its initializer, and unmount it."
(let ((target "/fs"))
(format-partition (partition-device partition)
(partition-file-system partition)
- #:label (partition-label partition))
+ #:label (partition-label partition)
+ #:uuid (partition-uuid partition))
(mkdir-p target)
(mount (partition-device partition) target
(partition-file-system partition))
--
2.13.2
Attachment: file
D
D
Danny Milosavljevic wrote on 20 Jul 2017 19:38
(name . Ludovic Courtès)(address . ludo@gnu.org)
20170720193801.131a59c7@scratchpost.org
Hi Ludo,

Toggle quote (4 lines)
> With iso9660, it works… by chance, because GRUB’s “search --fs-uuid”
> fails. Guess why? Because it compares UUIDs as strings, and we format
> it as a DCE UUID instead of an ISO UUID. Sounds familiar no? :-)

Yeah :)

Toggle quote (2 lines)
> So that’s where we are. Thoughts on how to address it?

Toggle quote (4 lines)
>...grub-mkrescue
>This produces a file named grub.iso, which then can be burned into a CD (or a DVD), or written to a USB mass storage device.
>The root device will be set up appropriately on entering your grub.cfg configuration file, so you can refer to file names on the CD without needing to use an explicit device name. This makes it easier to produce rescue images that will work on both optical drives and USB mass storage devices.

So... just leave the entire "search" instruction off if it's created by grub-mkrescue ? That's how one could interpret thir "root device" sentence...
L
L
Ludovic Courtès wrote on 20 Jul 2017 22:32
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
87379qn92a.fsf@gnu.org
Heya,

Danny Milosavljevic <dannym@scratchpost.org> skribis:

Toggle quote (16 lines)
>> With iso9660, it works… by chance, because GRUB’s “search --fs-uuid”
>> fails. Guess why? Because it compares UUIDs as strings, and we format
>> it as a DCE UUID instead of an ISO UUID. Sounds familiar no? :-)
>
> Yeah :)
>
>> So that’s where we are. Thoughts on how to address it?
>
> https://www.gnu.org/software/grub/manual/grub.html#Making-a-GRUB-bootable-CD_002dROM says:
>
>>...grub-mkrescue
>>This produces a file named grub.iso, which then can be burned into a CD (or a DVD), or written to a USB mass storage device.
>>The root device will be set up appropriately on entering your grub.cfg configuration file, so you can refer to file names on the CD without needing to use an explicit device name. This makes it easier to produce rescue images that will work on both optical drives and USB mass storage devices.
>
> So... just leave the entire "search" instruction off if it's created by grub-mkrescue ? That's how one could interpret thir "root device" sentence...

Oooh, interesting, that comes in handy. :-)

Now, how can we pass the information to ‘grub-configuration-file’ so
that it doesn’t emit that “search” command?

It seems that the bootloader API doesn’t leave room to pass
bootloader-specific options.

Thoughts?

Ludo’.
D
D
Danny Milosavljevic wrote on 20 Jul 2017 23:51
(name . Ludovic Courtès)(address . ludo@gnu.org)
20170720235115.0958266c@scratchpost.org
Hi Ludo,

On Thu, 20 Jul 2017 22:32:29 +0200
ludo@gnu.org (Ludovic Courtès) wrote:

Toggle quote (10 lines)
> > So... just leave the entire "search" instruction off if it's created by grub-mkrescue ? That's how one could interpret thir "root device" sentence...
>
> Oooh, interesting, that comes in handy. :-)
>
> Now, how can we pass the information to ‘grub-configuration-file’ so
> that it doesn’t emit that “search” command?
>
> It seems that the bootloader API doesn’t leave room to pass
> bootloader-specific options.

I can't believe I'm suggesting this (we've come full circle now) but we could add a new bootloader in gnu/bootloader/grub.scm,

(define* grub-hybrid-bootloader ; or grub-mkrescue-bootloader, maybe less misleading.
(bootloader
(inherit grub-efi-bootloader)
(configuration-file-generator grub-configuration-file-without-search-emission) ; this here could parametrize grub-configuration-file somehow or maybe we could refactor grub-configuration-file instead.
; Note: name is still 'grub-efi, so the public boot parameters API doesn't change.
(package grub-hybrid))) ; probably; or grub-efi if you just want a quick test with EFI only.

... and use it in iso9660-image or gnu/system/install.scm .
D
D
Danny Milosavljevic wrote on 5 Aug 2017 19:50
(name . Ludovic Courtès)(address . ludo@gnu.org)
20170805195035.2e2a93ed@scratchpost.org
Hi Ludo,

Toggle quote (7 lines)
> > So... just leave the entire "search" instruction off if it's created by grub-mkrescue ? That's how one could interpret thir "root device" sentence...
>
> Oooh, interesting, that comes in handy. :-)
>
> Now, how can we pass the information to ‘grub-configuration-file’ so
> that it doesn’t emit that “search” command?

I've gone ahead and pushed bug# 27705 to master. That means that there's now a new bootloader "grub-mkrescue-bootloader" in gnu/bootloaders/grub.scm . So you can just override its "configuration-file-generator" by one that doesn't emit the "search" command (remainder should be fine as-is).

I wonder what would happen (to Grub) if someone did guix system reconfigure in a system booted from the ISO9660 image, though. I think it would be better to not install any bootloader in the case of mkrescue and guix system reconfigure. We might want to do a follow-up commit that adds a dummy installer to the "installer" field of grub-mkrescue-bootloader. WDYT?
?