Skip to contentSkip to conversation

mkefidisk: Various fixes for 1.4 M6

PATCH In review Darren Hart 2 participants 9 messages Mar 19, 2013 – Mar 20, 2013

lore
Share & tools
lore
#2 lore raw

PATCH 2/6 mkefidisk: Always specify a root= kernel parameter

In reply to Darren Hart

The current script only replaces an existing root= kernel parameter which can result images created without a root= paremeter, even though the script expects a target rootfs parameter.

Rather than replacing the root= parameter, delete the root= parameter if it exists, then append an appropriate root= parameter.

Fixes [YOCTO 4035] mkefidisk.sh forgets to add root= parameter

---
 scripts/contrib/mkefidisk.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
scripts/contrib/mkefidisk.sh +4 -2
index 701a4d0..c68c224 100755
@@ -250,8 +250,10 @@ sed -i "/menuentry 'install'/,/^}/d" $GRUBCFG
 sed -i "/initrd /d" $GRUBCFG
 # Delete any LABEL= strings
 sed -i "s/ LABEL=[^ ]*/ /" $GRUBCFG
-# Replace the ramdisk root with the install device and include other options
-sed -i "s@ root=[^ ]*@ root=$TARGET_ROOTFS rw $ROOTWAIT quiet@" $GRUBCFG
+# Replace the ramdisk root (if any) with the install device and include other
+# kernel parameters
+sed -i "s@ root=[^ ]*@ @" $GRUBCFG
+sed -i "s@vmlinuz @vmlinuz root=$TARGET_ROOTFS rw $ROOTWAIT quiet @" $GRUBCFG
 
 # Provide a startup.nsh script for older firmware with non-standard boot
 # directories and paths.
Signature · 1 line
1.8.1.2
#5 lore raw

PATCH 5/6 mkefidisk: Remove startup.nsh

In reply to Darren Hart

Most firmware implementations use the EFI specified EFI/BOOT/bootia32.efi (and similar) boot paths. Only broken firmware uses different paths for removable media. In those cases, the user can add their own startup.nsh.

For the compliant case, selecting "Shell" from the EFI boot menu should go to the shell.

---
 scripts/contrib/mkefidisk.sh | 4 ----
 1 file changed, 4 deletions(-)
scripts/contrib/mkefidisk.sh +0 -4
index f8c08dd..6ff12af 100755
@@ -255,10 +255,6 @@ sed -i "s/ LABEL=[^ ]*/ /" $GRUBCFG
 sed -i "s@ root=[^ ]*@ @" $GRUBCFG
 sed -i "s@vmlinuz @vmlinuz root=$TARGET_ROOTFS ro rootwait quiet @" $GRUBCFG
 
-# Provide a startup.nsh script for older firmware with non-standard boot
-# directories and paths.
-echo "bootia32.efi" > $BOOTFS_MNT/startup.nsh
-
 umount $BOOTFS_MNT
 umount $HDDIMG_MNT
 rm -rf $TMPDIR
Signature · 1 line
1.8.1.2
#0 lore raw

cover mkefidisk: Various fixes for 1.4 M6

Fix bugs 4035 and 4036 as well as several other issues with mkefidisk.sh without bugs reported.

The following changes since commit ee416ad6f4b0209f7ad7d54467e0d7d5e097dd2a:

bitbake: utils.py: fix BB_ENV_WHITELIST (2013-03-19 13:56:03 +0000)

are available in the git repository at:

git://git.yoctoproject.org/poky-contrib dvhart/mkefidisk
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=dvhart/mkefidisk

Darren Hart (6):
mkefidisk: Cleanup comment length
mkefidisk: Always specify a root= kernel parameter
mkefidisk: Boot with ro kernel parameter instead of rw
mkefidisk: Always use rootwait and document kernel parameters used
mkefidisk: Remove startup.nsh
mkefidisk: Use msdos partition tables

 scripts/contrib/mkefidisk.sh | 36 ++++++++++++++++--------------------
 1 file changed, 16 insertions(+), 20 deletions(-)
Signature · 1 line
1.8.1.2
#1 lore raw

PATCH 1/6 mkefidisk: Cleanup comment length

Keep comments under 80 characters in length.

---
 scripts/contrib/mkefidisk.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/contrib/mkefidisk.sh +2 -2
index b7db0a9..701a4d0 100755
@@ -166,8 +166,8 @@ parted $DEVICE mklabel gpt
 echo "Creating boot partition on $BOOTFS"
 parted $DEVICE mkpart primary 0% $BOOT_SIZE
 
-# GPT doesn't have a real boot flag, parted will change the GUID to EFI System Partition, 
-# which is what we want
+# GPT doesn't have a real boot flag, parted will change the GUID to EFI System
+# Partition, which is what we want
 echo "Enabling boot flag on $BOOTFS"
 parted $DEVICE set 1 boot on
 
Signature · 1 line
1.8.1.2
#6 lore raw

PATCH 6/6 mkefidisk: Use msdos partition tables

In reply to Darren Hart

While GPT works fine when writing to actual media, it cannot be reliably used for distributing disk images as it requires the backup table to be on the last block on the device, which of course varies from device to device. Use MSDOS tables instead.

Use mkfs to label the filesystems as msdos tables do not support partition labeling.

---
 scripts/contrib/mkefidisk.sh | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)
scripts/contrib/mkefidisk.sh +7 -9
index 6ff12af..acadd49 100755
@@ -156,20 +156,18 @@ echo "*****************"
 echo "Deleting partition table on $DEVICE ..."
 dd if=/dev/zero of=$DEVICE bs=512 count=2
 
-echo "Creating new partition table (GPT) on $DEVICE ..."
-parted $DEVICE mklabel gpt
+# Use MSDOS by default as GPT cannot be reliably distributed in disk image form
+# as it requires the backup table to be on the last block of the device, which
+# of course varies from device to device.
+echo "Creating new partition table (MSDOS) on $DEVICE ..."
+parted $DEVICE mklabel msdos
 
 echo "Creating boot partition on $BOOTFS"
 parted $DEVICE mkpart primary 0% $BOOT_SIZE
 
-# GPT doesn't have a real boot flag, parted will change the GUID to EFI System
-# Partition, which is what we want
 echo "Enabling boot flag on $BOOTFS"
 parted $DEVICE set 1 boot on
 
-echo "Labeling $BOOTFS as EFI System Partition"
-parted $DEVICE name 1 "EFI System Partition"
-
 echo "Creating ROOTFS partition on $ROOTFS"
 parted $DEVICE mkpart primary $ROOTFS_START $ROOTFS_END
 
@@ -184,10 +182,10 @@ parted $DEVICE print
 #
 echo ""
 echo "Formatting $BOOTFS as vfat..."
-mkfs.vfat $BOOTFS
+mkfs.vfat $BOOTFS -n "efi"
 
 echo "Formatting $ROOTFS as ext3..."
-mkfs.ext3 $ROOTFS
+mkfs.ext3 $ROOTFS -L "root"
 
 echo "Formatting swap partition...($SWAP)"
 mkswap $SWAP
Signature · 1 line
1.8.1.2
#4 lore raw

PATCH 4/6 mkefidisk: Always use rootwait and document kernel parameters used

In reply to Darren Hart

Without a reliable way of knowing if the target device with be an asyncronous block device on the target (MMC or USB), err on the side of caution of always specifcy "rootwait", ensuring the kernel will wait for the device to appear and not abort if it hasn't appeared in time for mount.

Document the remaining kernel parameters added by this script on the same line as rootwait.

---
 scripts/contrib/mkefidisk.sh | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
scripts/contrib/mkefidisk.sh +8 -8
index 9275ecf..f8c08dd 100755
@@ -132,9 +132,7 @@ ROOTFS_START=$((BOOT_SIZE))
 ROOTFS_END=$((ROOTFS_START+ROOTFS_SIZE))
 SWAP_START=$((ROOTFS_END))
 
-# MMC devices are special in a couple of ways
-# 1) they use a partition prefix character 'p'
-# 2) they are detected asynchronously (need ROOTWAIT)
+# MMC devices use a partition prefix character 'p'
 PART_PREFIX=""
 if [ ! "${DEVICE#/dev/mmcblk}" = "${DEVICE}" ]; then
 	PART_PREFIX="p"
@@ -143,11 +141,9 @@ BOOTFS=$DEVICE${PART_PREFIX}1
 ROOTFS=$DEVICE${PART_PREFIX}2
 SWAP=$DEVICE${PART_PREFIX}3
 
-ROOTWAIT=""
 TARGET_PART_PREFIX=""
 if [ ! "${TARGET_DEVICE#/dev/mmcblk}" = "${TARGET_DEVICE}" ]; then
 	TARGET_PART_PREFIX="p"
-	ROOTWAIT="rootwait"
 fi
 TARGET_ROOTFS=$TARGET_DEVICE${TARGET_PART_PREFIX}2
 TARGET_SWAP=$TARGET_DEVICE${TARGET_PART_PREFIX}3
@@ -250,10 +246,14 @@ sed -i "/menuentry 'install'/,/^}/d" $GRUBCFG
 sed -i "/initrd /d" $GRUBCFG
 # Delete any LABEL= strings
 sed -i "s/ LABEL=[^ ]*/ /" $GRUBCFG
-# Replace the ramdisk root (if any) with the install device and include other
-# kernel parameters
+# Remove any existing root= kernel parameters and:
+# o Add a root= parameter with the target rootfs
+# o Specify ro so fsck can be run during boot
+# o Specify rootwait in case the target media is an asyncronous block device
+#   such as MMC or USB disks
+# o Specify "quiet" to minimize boot time when using slow serial consoles
 sed -i "s@ root=[^ ]*@ @" $GRUBCFG
-sed -i "s@vmlinuz @vmlinuz root=$TARGET_ROOTFS ro $ROOTWAIT quiet @" $GRUBCFG
+sed -i "s@vmlinuz @vmlinuz root=$TARGET_ROOTFS ro rootwait quiet @" $GRUBCFG
 
 # Provide a startup.nsh script for older firmware with non-standard boot
 # directories and paths.
Signature · 1 line
1.8.1.2
#3 lore raw

PATCH 3/6 mkefidisk: Boot with ro kernel parameter instead of rw

In reply to Darren Hart

There is no need to boot with "rw". Booting with "ro" will allow for fsck to be run during boot, and a proper /etc/fstab will still ensure the rootfs is "rw" by the time the user can interact with the system.

Change the "rw" to "ro" in the kernel parameters specified in the generated grub.cfg file.

Fixes [YOCTO 4036] mkefidisk.sh hardcodes 'rw' as root mount option

---
 scripts/contrib/mkefidisk.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/contrib/mkefidisk.sh +1 -1
index c68c224..9275ecf 100755
@@ -253,7 +253,7 @@ sed -i "s/ LABEL=[^ ]*/ /" $GRUBCFG
 # Replace the ramdisk root (if any) with the install device and include other
 # kernel parameters
 sed -i "s@ root=[^ ]*@ @" $GRUBCFG
-sed -i "s@vmlinuz @vmlinuz root=$TARGET_ROOTFS rw $ROOTWAIT quiet @" $GRUBCFG
+sed -i "s@vmlinuz @vmlinuz root=$TARGET_ROOTFS ro $ROOTWAIT quiet @" $GRUBCFG
 
 # Provide a startup.nsh script for older firmware with non-standard boot
 # directories and paths.
Signature · 1 line
1.8.1.2
#7 lore raw

Re: [PATCH 6/6] mkefidisk: Use msdos partition tables

In reply to Darren Hart

Op 19 mrt. 2013, om 23:15 heeft Darren Hart <[email protected]> het volgende geschreven:

Quoted 7 lines

While GPT works fine when writing to actual media, it cannot be reliably used for distributing disk images as it requires the backup table to be on the last block on the device, which of course varies from device to device. Use MSDOS tables instead.

Use mkfs to label the filesystems as msdos tables do not support partition labeling.

I was wondering if it's possible to run parted in fixup mode manually. I did that on the target itself to fix the off-by-one error, so running it on the host should work as well.

regards,

Koen

Quoted 57 lines

---
scripts/contrib/mkefidisk.sh | 16 +++++++---------

1 file changed, 7 insertions(+), 9 deletions(-)
scripts/contrib/mkefidisk.sh +0 -0
index 6ff12af..acadd49 100755
@@ -156,20 +156,18 @@ echo "*****************"

echo "Deleting partition table on $DEVICE ..."
dd if=/dev/zero of=$DEVICE bs=512 count=2

scripts/contrib/mkefidisk.sh +5 -2
-echo "Creating new partition table (GPT) on $DEVICE ..."
-parted $DEVICE mklabel gpt
+# Use MSDOS by default as GPT cannot be reliably distributed in disk image form
+# as it requires the backup table to be on the last block of the device, which
+# of course varies from device to device.
+echo "Creating new partition table (MSDOS) on $DEVICE ..."
+parted $DEVICE mklabel msdos

echo "Creating boot partition on $BOOTFS"
parted $DEVICE mkpart primary 0% $BOOT_SIZE

scripts/contrib/mkefidisk.sh +0 -2
-# GPT doesn't have a real boot flag, parted will change the GUID to EFI System
-# Partition, which is what we want

echo "Enabling boot flag on $BOOTFS"
parted $DEVICE set 1 boot on

scripts/contrib/mkefidisk.sh +0 -3
-echo "Labeling $BOOTFS as EFI System Partition"
-parted $DEVICE name 1 "EFI System Partition"
-

echo "Creating ROOTFS partition on $ROOTFS" parted $DEVICE mkpart primary $ROOTFS_START $ROOTFS_END

scripts/contrib/mkefidisk.sh +0 -0
@@ -184,10 +182,10 @@ parted $DEVICE print
 #

echo ""
echo "Formatting $BOOTFS as vfat..."

scripts/contrib/mkefidisk.sh +1 -1
-mkfs.vfat $BOOTFS
+mkfs.vfat $BOOTFS -n "efi"

echo "Formatting $ROOTFS as ext3..."

scripts/contrib/mkefidisk.sh +1 -1
-mkfs.ext3 $ROOTFS
+mkfs.ext3 $ROOTFS -L "root"

echo "Formatting swap partition...($SWAP)"
mkswap $SWAP

Signature · 7 lines
1.8.1.2


_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
#8 lore raw

Re: [PATCH 6/6] mkefidisk: Use msdos partition tables

Quoted 8 lines · Koen Kooi

Op 19 mrt. 2013, om 23:15 heeft Darren Hart <[email protected]> het volgende geschreven:

Quoted 5 lines

While GPT works fine when writing to actual media, it cannot be reliably used for distributing disk images as it requires the backup table to be on the last block on the device, which of course varies from device to device. Use MSDOS tables instead.

Quoted 6 lines
Quoted 2 lines

Use mkfs to label the filesystems as msdos tables do not support partition labeling.

I was wondering if it's possible to run parted in fixup mode manually. I did that on the target itself to fix the off-by-one error, so running it on the host should work as well.

I thought of that as well, but that doesn't help with the disk image problem. I don't like the idea of shipping images that have to be fixed on first boot without any clear motivation. For the purposes of these images, I don't see any clear advantage of GPT.

--
Darren

Quoted 64 lines

regards,

Koen

Quoted 57 lines

---
scripts/contrib/mkefidisk.sh | 16 +++++++---------

1 file changed, 7 insertions(+), 9 deletions(-)
scripts/contrib/mkefidisk.sh +0 -0
index 6ff12af..acadd49 100755
@@ -156,20 +156,18 @@ echo "*****************"

echo "Deleting partition table on $DEVICE ..."
dd if=/dev/zero of=$DEVICE bs=512 count=2

scripts/contrib/mkefidisk.sh +5 -2
-echo "Creating new partition table (GPT) on $DEVICE ..."
-parted $DEVICE mklabel gpt
+# Use MSDOS by default as GPT cannot be reliably distributed in disk image form
+# as it requires the backup table to be on the last block of the device, which
+# of course varies from device to device.
+echo "Creating new partition table (MSDOS) on $DEVICE ..."
+parted $DEVICE mklabel msdos

echo "Creating boot partition on $BOOTFS"
parted $DEVICE mkpart primary 0% $BOOT_SIZE

scripts/contrib/mkefidisk.sh +0 -2
-# GPT doesn't have a real boot flag, parted will change the GUID to EFI System
-# Partition, which is what we want

echo "Enabling boot flag on $BOOTFS"
parted $DEVICE set 1 boot on

scripts/contrib/mkefidisk.sh +0 -3
-echo "Labeling $BOOTFS as EFI System Partition"
-parted $DEVICE name 1 "EFI System Partition"
-

echo "Creating ROOTFS partition on $ROOTFS" parted $DEVICE mkpart primary $ROOTFS_START $ROOTFS_END

scripts/contrib/mkefidisk.sh +0 -0
@@ -184,10 +182,10 @@ parted $DEVICE print
 #

echo ""
echo "Formatting $BOOTFS as vfat..."

scripts/contrib/mkefidisk.sh +1 -1
-mkfs.vfat $BOOTFS
+mkfs.vfat $BOOTFS -n "efi"

echo "Formatting $ROOTFS as ext3..."

scripts/contrib/mkefidisk.sh +1 -1
-mkfs.ext3 $ROOTFS
+mkfs.ext3 $ROOTFS -L "root"

echo "Formatting swap partition...($SWAP)"
mkswap $SWAP

Signature · 7 lines
1.8.1.2


_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
Signature · 3 lines
Darren Hart
Intel Open Source Technology Center
Yocto Project - Technical Lead - Linux Kernel