livecd-iso-to-disk
--format fails with SD/MMC partitions:
Comment 10:
Support prefixed partition numbers
Partition numbers and any prefix is now detected with simpler code.
Review and testing requested..
--Fred
----------------------------------------------------------------------
From 2535f8a1c7a931ddbf06bcf9e74e7e943e592b43 Mon Sep 17 00:00:00 2001
From: Frederick Grose <fgrose(a)gmail.com>
Date: Tue, 23 Nov 2010 19:43:05 -0500
Subject: [PATCH] Fix partition number selection for MMC bus devices
Enable detection of partition number prefixes.
---
tools/livecd-iso-to-disk.sh | 24 +++++++++++++++++-------
1 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/tools/livecd-iso-to-disk.sh b/tools/livecd-iso-to-disk.sh
index caa7bde..ca28709 100755
--- a/tools/livecd-iso-to-disk.sh
+++ b/tools/livecd-iso-to-disk.sh
@@ -68,6 +68,13 @@ getdisk() {
partnum=${p##$device}
}
+getpartition() {
+ DEV=$1
+ pa=$( < /proc/partitions )
+ pa=${pa##*$DEV}
+ partnum=${pa%% *}
+}
+
resetMBR() {
if isdevloop "$DEV"; then
return
@@ -166,11 +173,12 @@ createGPTLayout() {
partinfo=$(LC_ALL=C /sbin/parted --script -m $device "unit b print"
|grep ^$device:)
size=$(echo $partinfo |cut -d : -f 2 |sed -e 's/B$//')
/sbin/parted --script $device unit b mkpart '"EFI System
Partition"'
fat32 17408 $(($size - 17408)) set 1 boot on
- USBDEV=${device}1
# Sometimes automount can be _really_ annoying.
echo "Waiting for devices to settle..."
/sbin/udevadm settle
sleep 5
+ getpartition ${device#/dev/}
+ USBDEV=${device}${partnum}
umount $USBDEV &> /dev/null
/sbin/mkdosfs -n LIVE $USBDEV
USBLABEL="UUID=$(/sbin/blkid -s UUID -o value $USBDEV)"
@@ -188,15 +196,16 @@ createMSDOSLayout() {
partinfo=$(LC_ALL=C /sbin/parted --script -m $device "unit b print"
|grep ^$device:)
size=$(echo $partinfo |cut -d : -f 2 |sed -e 's/B$//')
/sbin/parted --script $device unit b mkpart primary fat32 17408
$(($size - 17408)) set 1 boot on
- if ! isdevloop "$DEV"; then
- USBDEV=${device}1
- else
- USBDEV=${device}
- fi
# Sometimes automount can be _really_ annoying.
echo "Waiting for devices to settle..."
/sbin/udevadm settle
sleep 5
+ if ! isdevloop "$DEV"; then
+ getpartition ${device#/dev/}
+ USBDEV=${device}${partnum}
+ else
+ USBDEV=${device}
+ fi
umount $USBDEV &> /dev/null
/sbin/mkdosfs -n LIVE $USBDEV
USBLABEL="UUID=$(/sbin/blkid -s UUID -o value $USBDEV)"
@@ -214,11 +223,12 @@ createEXTFSLayout() {
partinfo=$(LC_ALL=C /sbin/parted --script -m $device "unit b print"
|grep ^$device:)
size=$(echo $partinfo |cut -d : -f 2 |sed -e 's/B$//')
/sbin/parted --script $device unit b mkpart primary ext2 17408 $(($size
- 17408)) set 1 boot on
- USBDEV=${device}1
# Sometimes automount can be _really_ annoying.
echo "Waiting for devices to settle..."
/sbin/udevadm settle
sleep 5
+ getpartition ${device#/dev/}
+ USBDEV=${device}${partnum}
umount $USBDEV &> /dev/null
/sbin/mkfs.ext4 -L LIVE $USBDEV
USBLABEL="UUID=$(/sbin/blkid -s UUID -o value $USBDEV)"
--
1.7.3.2