public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH installer v3 0/2] assistant: keep prepared iso bootable on uefi with flash drives
@ 2024-04-30 10:46 Aaron Lauterer
  2024-04-30 10:46 ` [pve-devel] [PATCH installer v3 1/2] " Aaron Lauterer
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Aaron Lauterer @ 2024-04-30 10:46 UTC (permalink / raw)
  To: pve-devel

booting a prepared iso in UEFI mode from a blockdev (e.g. usb flash
drive) did not work as grub could not find the partition.

we now read the uuid / volume_date from the source iso and always set it
explictly to the same value when injecting files.

more details in the actual commit message

the second patch is a style patch

this version should now include everything. sorry for the noise :)

changes since:
v2:
* add import of format_err that was missed in v2
v1:
* improve error handling in case xorriso does return empty output

Aaron Lauterer (2):
  assistant: keep prepared iso bootable on uefi with flash drives
  assistant: use single dash for xorriso parameter

 proxmox-auto-install-assistant/src/main.rs | 48 +++++++++++++++++++---
 1 file changed, 43 insertions(+), 5 deletions(-)

-- 
2.39.2



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [pve-devel] [PATCH installer v3 1/2] assistant: keep prepared iso bootable on uefi with flash drives
  2024-04-30 10:46 [pve-devel] [PATCH installer v3 0/2] assistant: keep prepared iso bootable on uefi with flash drives Aaron Lauterer
@ 2024-04-30 10:46 ` Aaron Lauterer
  2024-04-30 10:46 ` [pve-devel] [PATCH installer v3 2/2] assistant: use single dash for xorriso parameter Aaron Lauterer
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Aaron Lauterer @ 2024-04-30 10:46 UTC (permalink / raw)
  To: pve-devel

By mapping files into the ISO, the UUID for the partitions change as
they depend on the timestamp. The result is, that grub cannot find its
partition anymore and the user ends up on the grub shell.

This only happens when booting from a blockdev in UEFI mode. E.g. a USB
flash drive. Alternatively one can `dd` the ISO to a small (2GiB) VM
disk and mark it as the first boot device.

When booting in legacy mode or via CDROM (e.g. pass through via IPMI),
it worked.

Xorriso can report the commands needed to recreate the source ISO. The
'-volume_date uuid' is the one needed to override the same UUIDs. We
therefore read it first from the source iso and pass it as parameter
whenever we inject a file into the iso.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
Reviewed-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Tested-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---
changes since:
v2:
* add missing import of format_err to patch
v1:
* improve error handling should xorriso return empty output

 proxmox-auto-install-assistant/src/main.rs | 46 ++++++++++++++++++++--
 1 file changed, 42 insertions(+), 4 deletions(-)

diff --git a/proxmox-auto-install-assistant/src/main.rs b/proxmox-auto-install-assistant/src/main.rs
index 0debd29..f8e5ed0 100644
--- a/proxmox-auto-install-assistant/src/main.rs
+++ b/proxmox-auto-install-assistant/src/main.rs
@@ -1,4 +1,4 @@
-use anyhow::{bail, Result};
+use anyhow::{bail, format_err, Result};
 use clap::{Args, Parser, Subcommand, ValueEnum};
 use glob::Pattern;
 use regex::Regex;
@@ -276,6 +276,7 @@ fn show_system_info(_args: &CommandSystemInfo) -> Result<()> {
 
 fn prepare_iso(args: &CommandPrepareISO) -> Result<()> {
     check_prepare_requirements(args)?;
+    let uuid = get_iso_uuid(&args.input)?;
 
     if args.fetch_from == FetchAnswerFrom::Iso && args.answer_file.is_none() {
         bail!("Missing path to the answer file required for the fetch-from 'iso' mode.");
@@ -331,10 +332,15 @@ fn prepare_iso(args: &CommandPrepareISO) -> Result<()> {
     instmode_file_tmp.push("auto-installer-mode.toml");
     fs::write(&instmode_file_tmp, toml::to_string_pretty(&config)?)?;
 
-    inject_file_to_iso(&tmp_iso, &instmode_file_tmp, "/auto-installer-mode.toml")?;
+    inject_file_to_iso(
+        &tmp_iso,
+        &instmode_file_tmp,
+        "/auto-installer-mode.toml",
+        &uuid,
+    )?;
 
     if let Some(answer_file) = &args.answer_file {
-        inject_file_to_iso(&tmp_iso, answer_file, "/answer.toml")?;
+        inject_file_to_iso(&tmp_iso, answer_file, "/answer.toml", &uuid)?;
     }
 
     println!("Moving prepared ISO to target location...");
@@ -371,11 +377,14 @@ fn final_iso_location(args: &CommandPrepareISO) -> PathBuf {
     target.to_path_buf()
 }
 
-fn inject_file_to_iso(iso: &PathBuf, file: &PathBuf, location: &str) -> Result<()> {
+fn inject_file_to_iso(iso: &PathBuf, file: &PathBuf, location: &str, uuid: &String) -> Result<()> {
     let result = Command::new("xorriso")
         .arg("--boot_image")
         .arg("any")
         .arg("keep")
+        .arg("-volume_date")
+        .arg("uuid")
+        .arg(uuid)
         .arg("-dev")
         .arg(iso)
         .arg("-map")
@@ -391,6 +400,35 @@ fn inject_file_to_iso(iso: &PathBuf, file: &PathBuf, location: &str) -> Result<(
     Ok(())
 }
 
+fn get_iso_uuid(iso: &PathBuf) -> Result<String> {
+    let result = Command::new("xorriso")
+        .arg("-dev")
+        .arg(iso)
+        .arg("-report_system_area")
+        .arg("cmd")
+        .output()?;
+    if !result.status.success() {
+        bail!(
+            "Error determining the UUID of the source ISO: {}",
+            String::from_utf8_lossy(&result.stderr)
+        );
+    }
+    let mut uuid = String::new();
+    for line in String::from_utf8(result.stdout)?.lines() {
+        if line.starts_with("-volume_date uuid") {
+            uuid = line
+                .split(' ')
+                .last()
+                .ok_or_else(|| format_err!("xorriso did behave unexpextedly"))?
+                .replace('\'', "")
+                .trim()
+                .into();
+            break;
+        }
+    }
+    Ok(uuid)
+}
+
 fn get_disks() -> Result<BTreeMap<String, BTreeMap<String, String>>> {
     let unwantend_block_devs = vec![
         "ram[0-9]*",
-- 
2.39.2



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [pve-devel] [PATCH installer v3 2/2] assistant: use single dash for xorriso parameter
  2024-04-30 10:46 [pve-devel] [PATCH installer v3 0/2] assistant: keep prepared iso bootable on uefi with flash drives Aaron Lauterer
  2024-04-30 10:46 ` [pve-devel] [PATCH installer v3 1/2] " Aaron Lauterer
@ 2024-04-30 10:46 ` Aaron Lauterer
  2024-04-30 15:10 ` [pve-devel] [PATCH installer v3 0/2] assistant: keep prepared iso bootable on uefi with flash drives Stoiko Ivanov
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Aaron Lauterer @ 2024-04-30 10:46 UTC (permalink / raw)
  To: pve-devel

while it works with two, one is what is shown in the man page and what
we already use for the other paramters.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
---
 proxmox-auto-install-assistant/src/main.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/proxmox-auto-install-assistant/src/main.rs b/proxmox-auto-install-assistant/src/main.rs
index f8e5ed0..1447175 100644
--- a/proxmox-auto-install-assistant/src/main.rs
+++ b/proxmox-auto-install-assistant/src/main.rs
@@ -379,7 +379,7 @@ fn final_iso_location(args: &CommandPrepareISO) -> PathBuf {
 
 fn inject_file_to_iso(iso: &PathBuf, file: &PathBuf, location: &str, uuid: &String) -> Result<()> {
     let result = Command::new("xorriso")
-        .arg("--boot_image")
+        .arg("-boot_image")
         .arg("any")
         .arg("keep")
         .arg("-volume_date")
-- 
2.39.2



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [pve-devel] [PATCH installer v3 0/2] assistant: keep prepared iso bootable on uefi with flash drives
  2024-04-30 10:46 [pve-devel] [PATCH installer v3 0/2] assistant: keep prepared iso bootable on uefi with flash drives Aaron Lauterer
  2024-04-30 10:46 ` [pve-devel] [PATCH installer v3 1/2] " Aaron Lauterer
  2024-04-30 10:46 ` [pve-devel] [PATCH installer v3 2/2] assistant: use single dash for xorriso parameter Aaron Lauterer
@ 2024-04-30 15:10 ` Stoiko Ivanov
  2024-05-08  8:00 ` Aaron Lauterer
  2024-05-08 14:06 ` [pve-devel] applied-series: " Thomas Lamprecht
  4 siblings, 0 replies; 6+ messages in thread
From: Stoiko Ivanov @ 2024-04-30 15:10 UTC (permalink / raw)
  To: Aaron Lauterer; +Cc: Proxmox VE development discussion

for completeness sake - gave the v3 a quick spin as well - so also from my
side the:
Reviewed-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Tested-by: Stoiko Ivanov <s.ivanov@proxmox.com>

still applies :)


On Tue, 30 Apr 2024 12:46:07 +0200
Aaron Lauterer <a.lauterer@proxmox.com> wrote:

> booting a prepared iso in UEFI mode from a blockdev (e.g. usb flash
> drive) did not work as grub could not find the partition.
> 
> we now read the uuid / volume_date from the source iso and always set it
> explictly to the same value when injecting files.
> 
> more details in the actual commit message
> 
> the second patch is a style patch
> 
> this version should now include everything. sorry for the noise :)
> 
> changes since:
> v2:
> * add import of format_err that was missed in v2
> v1:
> * improve error handling in case xorriso does return empty output
> 
> Aaron Lauterer (2):
>   assistant: keep prepared iso bootable on uefi with flash drives
>   assistant: use single dash for xorriso parameter
> 
>  proxmox-auto-install-assistant/src/main.rs | 48 +++++++++++++++++++---
>  1 file changed, 43 insertions(+), 5 deletions(-)
> 



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [pve-devel] [PATCH installer v3 0/2] assistant: keep prepared iso bootable on uefi with flash drives
  2024-04-30 10:46 [pve-devel] [PATCH installer v3 0/2] assistant: keep prepared iso bootable on uefi with flash drives Aaron Lauterer
                   ` (2 preceding siblings ...)
  2024-04-30 15:10 ` [pve-devel] [PATCH installer v3 0/2] assistant: keep prepared iso bootable on uefi with flash drives Stoiko Ivanov
@ 2024-05-08  8:00 ` Aaron Lauterer
  2024-05-08 14:06 ` [pve-devel] applied-series: " Thomas Lamprecht
  4 siblings, 0 replies; 6+ messages in thread
From: Aaron Lauterer @ 2024-05-08  8:00 UTC (permalink / raw)
  To: pve-devel

ping? can be push out a new version of the assistant with this change? 
it is unfortunately a rather annoying bug for people who want to install 
in uefi mode from a usb flash drive

On  2024-04-30  12:46, Aaron Lauterer wrote:
> booting a prepared iso in UEFI mode from a blockdev (e.g. usb flash
> drive) did not work as grub could not find the partition.
> 
> we now read the uuid / volume_date from the source iso and always set it
> explictly to the same value when injecting files.
> 
> more details in the actual commit message
> 
> the second patch is a style patch
> 
> this version should now include everything. sorry for the noise :)
> 
> changes since:
> v2:
> * add import of format_err that was missed in v2
> v1:
> * improve error handling in case xorriso does return empty output
> 
> Aaron Lauterer (2):
>    assistant: keep prepared iso bootable on uefi with flash drives
>    assistant: use single dash for xorriso parameter
> 
>   proxmox-auto-install-assistant/src/main.rs | 48 +++++++++++++++++++---
>   1 file changed, 43 insertions(+), 5 deletions(-)
> 


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [pve-devel] applied-series: [PATCH installer v3 0/2] assistant: keep prepared iso bootable on uefi with flash drives
  2024-04-30 10:46 [pve-devel] [PATCH installer v3 0/2] assistant: keep prepared iso bootable on uefi with flash drives Aaron Lauterer
                   ` (3 preceding siblings ...)
  2024-05-08  8:00 ` Aaron Lauterer
@ 2024-05-08 14:06 ` Thomas Lamprecht
  4 siblings, 0 replies; 6+ messages in thread
From: Thomas Lamprecht @ 2024-05-08 14:06 UTC (permalink / raw)
  To: Proxmox VE development discussion, Aaron Lauterer

On 30/04/2024 12:46, Aaron Lauterer wrote:
> booting a prepared iso in UEFI mode from a blockdev (e.g. usb flash
> drive) did not work as grub could not find the partition.
> 
> we now read the uuid / volume_date from the source iso and always set it
> explictly to the same value when injecting files.
> 
> more details in the actual commit message
> 
> the second patch is a style patch
> 
> this version should now include everything. sorry for the noise :)
> 
> changes since:
> v2:
> * add import of format_err that was missed in v2
> v1:
> * improve error handling in case xorriso does return empty output
> 
> Aaron Lauterer (2):
>   assistant: keep prepared iso bootable on uefi with flash drives
>   assistant: use single dash for xorriso parameter
> 
>  proxmox-auto-install-assistant/src/main.rs | 48 +++++++++++++++++++---
>  1 file changed, 43 insertions(+), 5 deletions(-)
> 


applied series with Stoiko's R-b and T-b, thanks!


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-05-08 14:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-30 10:46 [pve-devel] [PATCH installer v3 0/2] assistant: keep prepared iso bootable on uefi with flash drives Aaron Lauterer
2024-04-30 10:46 ` [pve-devel] [PATCH installer v3 1/2] " Aaron Lauterer
2024-04-30 10:46 ` [pve-devel] [PATCH installer v3 2/2] assistant: use single dash for xorriso parameter Aaron Lauterer
2024-04-30 15:10 ` [pve-devel] [PATCH installer v3 0/2] assistant: keep prepared iso bootable on uefi with flash drives Stoiko Ivanov
2024-05-08  8:00 ` Aaron Lauterer
2024-05-08 14:06 ` [pve-devel] applied-series: " Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal