<div class="gmail_quote">On Mon, May 10, 2010 at 6:27 PM, Alan Pevec <span dir="ltr">&lt;<a href="mailto:apevec@gmail.com" target="_blank">apevec@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div>On Mon, May 10, 2010 at 10:20 PM, David Huff &lt;<a href="mailto:dhuff@redhat.com" target="_blank">dhuff@redhat.com</a>&gt; wrote:<br>
&gt; Frederick&#39;s patch fixes issues with SD cards that do not have a standard<br>
&gt; partitioning layout and requires part0 ie: /dev/mmcblk0<br>
<br>
</div>issue is that partitions on mmc device use separator p i.e. 1st<br>
partition is mmcblk0p1<br>
<div><br>
&gt; However the proposed patch requires users specify a<br>
&gt; partition for the storage device or have --format option require a<br>
&gt; partition number.<br>
<br>
</div>--format will create one, first partition, so it doesn&#39;t make sense to<br>
specify the partition number<br></blockquote><div><br></div><div>Yes,  currently we don&#39;t support multiple partition devices.  That will be</div><div>another bug and patch upcoming.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div><br>
&gt; Any comments on this?<br>
&gt;<br>
&gt; Also Frederick can you please resend the patch to the list, that way I<br>
&gt; can apply it and retain all header info for the commit.<br>
<br>
</div>patch in BZ also merged checkLVMActive() which is now committed<br>
<br>
I don&#39;t like special case for mmc:<br>
[[ &quot;${path/*mmc*/yes}&quot; = yes ]] &amp;&amp; mmc=p<br>
<br>
instead, why not simply detect partition separator here:<br>
<br>
path=/dev/`basename $path`<br>
partnum0=${path##$device}<br>
partnum=${partnum0/#p/}<br>
if [ &quot;$partnum&quot; = &quot;$partnum0&quot; ]; then<br>
  separator=&quot;&quot;<br>
else<br>
  separator=&quot;p&quot;<br>
fi<br>
...<br>
USBDEV=${device}${separator}${partnum:-1}</blockquote><div><br></div><div>A problem arises because users are allowed to --reset-mbr --format a partition by simply supplying a device node such as /dev/sdb.  This means the code must determine an appropriate partition name when one is not supplied. So the suggested test fails for the case where &quot;... --format /dev/mmcblk0 ...&quot; is supplied to livecd-iso-to-disk.</div>


<div><br></div><div>The path test works, but assumes that the separator is used, and apparently some older systems did not use a &#39;p&#39; separator.  So, better to just read from /proc/partitions.</div><div><br>
</div><div>The following patch is proposed--but note: It has NOT been tested on EFI code paths.</div><div><br></div><div>      --Fred</div><div><br></div><div><br></div><div><div><div><div>diff --git a/tools/livecd-iso-to-disk.sh b/tools/livecd-iso-to-disk.sh</div>

<div>index f4d0855..f92fe2b 100755</div><div>--- a/tools/livecd-iso-to-disk.sh</div><div>+++ b/tools/livecd-iso-to-disk.sh</div><div>@@ -47,21 +47,24 @@ getdisk() {</div><div>        return</div><div>     fi</div><div> </div>

<div>-    p=$(udevadm info -q path -n $DEV)</div><div>-    if [ -e /sys/$p/device ]; then</div><div>-<span class="Apple-tab-span" style="white-space:pre">        </span>device=$(basename /sys/$p)</div><div>+    path=$(udevadm info -q path -n $DEV)</div>

<div>+    if [ -e /sys/$path/device ]; then</div><div>+<span class="Apple-tab-span" style="white-space:pre">        </span>    device=$(basename /sys/$path)</div><div>     else</div><div>-<span class="Apple-tab-span" style="white-space:pre">        </span>device=$(basename $(readlink -f /sys/$p/../))</div>

<div>+<span class="Apple-tab-span" style="white-space:pre">        </span>    device=$(basename $(readlink -f /sys/$path/../))</div><div>     fi</div><div>     if [ ! -e /sys/block/$device -o ! -e /dev/$device ]; then</div><div>

-<span class="Apple-tab-span" style="white-space:pre">        </span>echo &quot;Error finding block device of $DEV.  Aborting!&quot;</div><div>-<span class="Apple-tab-span" style="white-space:pre">        </span>exitclean</div><div>+<span class="Apple-tab-span" style="white-space:pre">        </span>    echo &quot;Error finding block device of $DEV.  Aborting!&quot;</div>

<div>+<span class="Apple-tab-span" style="white-space:pre">        </span>    exitclean</div><div>     fi</div><div>-</div><div>-    device=&quot;/dev/$device&quot;</div><div>+   </div><div>     # FIXME: weird dev names could mess this up I guess</div>

<div>-    p=/dev/`basename $p`</div><div>-    partnum=${p##$device}</div><div>+    set $( awk &#39;$4 ~ /&#39;${device#/}&#39;.*[0-9]$/ {print $4}&#39; /proc/partitions )</div><div>+    partition=$1</div><div>+    path=/dev/$(basename $path)</div>

<div>+    partnum=${path##$device}</div><div>+    [[ -z &quot;$partnum&quot; ]] &amp;&amp; partnum=${partition##$device}</div><div>+    device=&quot;/dev/$device&quot;</div><div> }</div><div> </div><div> resetMBR() {</div>

<div>@@ -157,16 +160,17 @@ createGPTLayout() {</div><div>     echo &quot;WARNING: THIS WILL DESTROY ANY DATA ON $device!!!&quot;</div><div>     echo &quot;Press Enter to continue or ctrl-c to abort&quot;</div><div>     read</div>

<div>-    umount ${device}? &amp;&gt; /dev/null</div><div>+    umount ${device}* &amp;&gt; /dev/null</div><div>     /sbin/parted --script $device mklabel gpt</div><div>     partinfo=$(LC_ALL=C /sbin/parted --script -m $device &quot;unit b print&quot; |grep ^$device:)</div>

<div>     size=$(echo $partinfo |cut -d : -f 2 |sed -e &#39;s/B$//&#39;)</div><div>     /sbin/parted --script $device unit b mkpart &#39;&quot;EFI System Partition&quot;&#39; fat32 17408 $(($size - 17408)) set 1 boot on</div>

<div>-    USBDEV=${device}1</div><div>     # Sometimes automount can be _really_ annoying.</div><div>     echo &quot;Waiting for devices to settle...&quot;</div><div>     /sbin/udevadm settle</div><div>     sleep 5</div>
<div>
+    partnum=$( awk &#39;$4 ~ /&#39;${device#/}&#39;.*[0-9]$/ {print $4}&#39; /proc/partitions )</div><div>+    USBDEV=${device}${partnum}</div><div>     umount $USBDEV &amp;&gt; /dev/null</div><div>     /sbin/mkdosfs -n LIVE $USBDEV</div>

<div>     USBLABEL=&quot;UUID=$(/sbin/blkid -s UUID -o value $USBDEV)&quot;</div><div>@@ -179,16 +183,17 @@ createMSDOSLayout() {</div><div>     echo &quot;WARNING: THIS WILL DESTROY ANY DATA ON $device!!!&quot;</div><div>

     echo &quot;Press Enter to continue or ctrl-c to abort&quot;</div><div>     read</div><div>-    umount ${device}? &amp;&gt; /dev/null</div><div>+    umount ${device}* &amp;&gt; /dev/null</div><div>     /sbin/parted --script $device mklabel msdos</div>

<div>     partinfo=$(LC_ALL=C /sbin/parted --script -m $device &quot;unit b print&quot; |grep ^$device:)</div><div>     size=$(echo $partinfo |cut -d : -f 2 |sed -e &#39;s/B$//&#39;)</div><div>     /sbin/parted --script $device unit b mkpart primary fat32 17408 $(($size - 17408)) set 1 boot on</div>

<div>-    USBDEV=${device}1</div><div>     # Sometimes automount can be _really_ annoying.</div><div>     echo &quot;Waiting for devices to settle...&quot;</div><div>     /sbin/udevadm settle</div><div>     sleep 5</div>
<div>
+    partnum=$( awk &#39;$4 ~ /&#39;${device#/}&#39;.*[0-9]$/ {print $4}&#39; /proc/partitions )</div><div>+    USBDEV=${device}${partnum}</div><div>     umount $USBDEV &amp;&gt; /dev/null</div><div>     /sbin/mkdosfs -n LIVE $USBDEV</div>

<div>     USBLABEL=&quot;UUID=$(/sbin/blkid -s UUID -o value $USBDEV)&quot;</div></div></div></div></div>