[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: using isohybrid for usb bootable isos



Joey Hess wrote:
> So ideally, debian-cd would add a small second partition to the iso file's
> partition table, and tack on a FAT filesystem. This could probably be done
> by running fdisk on the iso file after isohybrid.

I've attached a patch with a script, which I am checking into d-i for now,
that does that. 

This would add 6 to 7 mb to iso images it's used on, I don't know how Steve
feels about that. :)

-- 
see shy jo
#!/bin/sh
# Given an iso image, runs isohybrid on it to allow it to be booted from
# USB stick as well as CD. Then it adds a small second FAT partition, which
# the user can use to provide firmware files to the installer on the same
# USB stick.

# This needs to be big enough to hold the uncompressed firmware.tar.gz
# file. Currently that is 4.4M; add a few more to grow.
firmware_volume_size_M=6
# max size 11 chars:  ----------- 
firmware_volume_name="Firmware"

iso="$1"

if [ -z "$iso" ]; then
	echo "usage: $0 iso" >&2
	exit 1
fi

set -e

isohybrid "$iso"

# Make the firmware volume.
tmpdir="$(mktemp -d)"
firmware_volume_file="$tmpdir/fat"
mkfs.msdos -n "$firmware_volume_name" -C "$firmware_volume_file" \
	$(expr $firmware_volume_size_M \* 1024)

# Combine images. 
# XXX This wastes some space because isohybrid pads the iso to one
# megabyte. Could reuse that padding for the start of the firmware volume.
cat "$firmware_volume_file" >> "$iso"
rm -r "$tmpdir"

# Now adjust the partition table of the hybrid iso.
# It has a first partition which is the iso; add a second partition for the
# firmware volume.
(

# Go into extended menu and set cylinders to 32. 
# This is the same number of cylinders (currently) used by isohybrid.
echo x
echo c
echo 32
echo r

# Make new partition #2
echo n
echo p
echo 2
echo 
echo +"$firmware_volume_size_M"M

# Pedantically, set partition type to 1: FAT 16
echo t
echo 2
echo 1

# Done!
echo w
) | fdisk "$iso"
From 9e4ab44eb5d43353769350872803cae71553eae5 Mon Sep 17 00:00:00 2001
From: Joey Hess <joey@kitenet.net>
Date: Mon, 13 Sep 2010 22:07:36 -0400
Subject: [PATCH 1/2] create geniso_hybrid_plus_firware_partition script

This script makes a hybrid iso image with a second partition for firmware.
---
 installer/build/config/x86.cfg                     |    2 +-
 .../util/geniso_hybrid_plus_firware_partition      |   62 ++++++++++++++++++++
 2 files changed, 63 insertions(+), 1 deletions(-)
 create mode 100755 installer/build/util/geniso_hybrid_plus_firware_partition

diff --git a/installer/build/config/x86.cfg b/installer/build/config/x86.cfg
index 4a0a005..e9ef577 100644
--- a/installer/build/config/x86.cfg
+++ b/installer/build/config/x86.cfg
@@ -279,7 +279,7 @@ arch_miniiso: x86_syslinux
 		-no-emul-boot -boot-load-size 4 -boot-info-table \
 		-o $(TEMP_MINIISO) $(TEMP_CD_TREE)
 	
-	isohybrid $(TEMP_MINIISO)
+	geniso_hybrid_plus_firware_partition $(TEMP_MINIISO)
 
 # Netboot files
 .PHONY: arch_netboot_dir
diff --git a/installer/build/util/geniso_hybrid_plus_firware_partition b/installer/build/util/geniso_hybrid_plus_firware_partition
new file mode 100755
index 0000000..52cccf1
--- /dev/null
+++ b/installer/build/util/geniso_hybrid_plus_firware_partition
@@ -0,0 +1,62 @@
+#!/bin/sh
+# Given an iso image, runs isohybrid on it to allow it to be booted from
+# USB stick as well as CD. Then it adds a small second FAT partition, which
+# the user can use to provide firmware files to the installer on the same
+# USB stick.
+
+# This needs to be big enough to hold the uncompressed firmware.tar.gz
+# file. Currently that is 4.4M; add a few more to grow.
+firmware_volume_size_M=6
+# max size 11 chars:  ----------- 
+firmware_volume_name="Firmware"
+
+iso="$1"
+
+if [ -z "$iso" ]; then
+	echo "usage: $0 iso" >&2
+	exit 1
+fi
+
+set -e
+
+isohybrid "$iso"
+
+# Make the firmware volume.
+tmpdir="$(mktemp -d)"
+firmware_volume_file="$tmpdir/fat"
+mkfs.msdos -n "$firmware_volume_name" -C "$firmware_volume_file" \
+	$(expr $firmware_volume_size_M \* 1024)
+
+# Combine images. 
+# XXX This wastes some space because isohybrid pads the iso to one
+# megabyte. Could reuse that padding for the start of the firmware volume.
+cat "$firmware_volume_file" >> "$iso"
+rm -r "$tmpdir"
+
+# Now adjust the partition table of the hybrid iso.
+# It has a first partition which is the iso; add a second partition for the
+# firmware volume.
+(
+
+# Go into extended menu and set cylinders to 32. 
+# This is the same number of cylinders (currently) used by isohybrid.
+echo x
+echo c
+echo 32
+echo r
+
+# Make new partition #2
+echo n
+echo p
+echo 2
+echo 
+echo +"$firmware_volume_size_M"M
+
+# Pedantically, set partition type to 1: FAT 16
+echo t
+echo 2
+echo 1
+
+# Done!
+echo w
+) | fdisk "$iso"
-- 
1.7.1

From cff9c48f8e041e317186e91cce17d86181fd80a6 Mon Sep 17 00:00:00 2001
From: Joey Hess <joey@kitenet.net>
Date: Mon, 13 Sep 2010 22:32:40 -0400
Subject: [PATCH 2/2] add documentation for piggybacking formware onto hybrid mini.iso usb stick

---
 manual/en/install-methods/boot-usb-files.xml |   17 +++++++++++++++--
 manual/en/using-d-i/loading-firmware.xml     |    6 +++---
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/manual/en/install-methods/boot-usb-files.xml b/manual/en/install-methods/boot-usb-files.xml
index e2fc9af..87687ff 100644
--- a/manual/en/install-methods/boot-usb-files.xml
+++ b/manual/en/install-methods/boot-usb-files.xml
@@ -19,6 +19,8 @@ to install entirely from the network, you'll need to download the
 <filename>mini.iso</filename> image from the <filename>netboot</filename>
 directory (at the location mentioned in <xref linkend="where-files"/>), and
 write this file directly to the USB stick, overwriting its current contents.
+This method will work with very small USB sticks, only a few megabytes in
+size.
 
 </para><para arch="x86">
 
@@ -27,10 +29,21 @@ For example, when using an existing GNU/Linux system, the
 
 <informalexample><screen>
 # cat mini.iso &gt; /dev/<replaceable>sdX</replaceable>
+# sync
 </screen></informalexample>
 
-This method will work with very small USB sticks, only a few megabytes in
-size.
+To add firmware to a USB stick prepared in this way, obtain the necessary firmware
+files. See <xref linkend="loading-firmware"/> for more information.
+Now unplug and replug the USB stick, and two partitions should now be visible on it.
+You should mount the second of the two partitions, and unpack the firmware onto it.
+
+<informalexample><screen>
+# mount /dev/<replaceable>sdX2</replaceable> /mnt
+# cd /mnt
+# tar zxvf <replacable>/path/to/</replacable>firmware.tar.gz
+# cd /
+# umount
+</screen></informalexample>
 
 </para><para>
 
diff --git a/manual/en/using-d-i/loading-firmware.xml b/manual/en/using-d-i/loading-firmware.xml
index 3a720db..09946eb 100644
--- a/manual/en/using-d-i/loading-firmware.xml
+++ b/manual/en/using-d-i/loading-firmware.xml
@@ -62,7 +62,7 @@ certain to be supported during the early stages of the installation.
 
 </para><para>
 
-Tarballs containing current packages for the most common firmware are
+Tarballs and zip files containing current packages for the most common firmware are
 available from:
 
 <itemizedlist>
@@ -71,8 +71,8 @@ available from:
 </para></listitem>
 </itemizedlist>
 
-Just download the tarball for the correct release and unpack it to the file
-system on the medium.
+Just download the tarball or zip file for the correct release and unpack it to
+the file system on the medium.
 
 </para><para>
 
-- 
1.7.1

Attachment: signature.asc
Description: Digital signature


Reply to: