zymbit/rpi-mkimg

Missing ${device} variable in check

fabianbaier opened this issue · 6 comments

Shouldn't line 18 be changed from:
fdisk -l ${device} | grep -q '/dev/sda1.*W95 FAT32'

to:
fdisk -l ${device} | grep -q '${device}1.*W95 FAT32'

And line 24 from:
fdisk -l ${device} | grep -q '/dev/sda2._Linux'
to:
fdisk -l ${device} | grep -q '${device}2._Linux'

that doesnt work fine :(

I use the internal SD Card Reader and they named the Card /dev/mmcblk0

if [[ ${device} == "/dev/sd"* ]]; then
win_partition=${device}1
linux_partition=${device}2
elif [[ ${device} == "/dev/mmcblk"* ]]; then
win_partition=${device}p1
linux_partition=${device}p2
fi;

fdisk -l ${device} | grep -q "${win_partition}.*W95 FAT32"
if [ "$?" != "0" ]; then
echo 'The first partition is expected to be FAT32' 1>&1;
exit 1;
fi;

fdisk -l ${device} | grep -q "${linux_partition}.*Linux"
if [ "$?" != "0" ]; then
echo 'The second partition is expected to be Linux' 1>&1;
exit 1;
fi;

Because of this I removed line 47.

In addition to @fabianbaier I tested and this is what worked for me (using lubuntu)
fdisk -l ${device} | grep -q ${device}1'.*W95 FAT32'
and
fdisk -l ${device} | grep -q ${device}2'.Linux'

Just a note (not an actual issue) I couldn't start the script if the SD card was mounted so I added this on line 51:
umount ${linux_partition} || /bin/true

However, always need to take care what kind of error we get (if any) while trying to umount.

Very nice script!
Could you update the downloadable with the comments of @fabianbaier ?

rca commented

Thanks for the feedback; will update shortly!

rca commented

Fixed in commit 43cf591, thanks!

rca commented

@PapaSpik3 Sounds like you're trying to image the card you are booted into; this is not recommended, you may get an inconsistent image. I would image a card you have connected externally with some sort of adapter like this one: http://www.adorama.com/KGFCRMRG2.html?hotlink=t&svfor=5m&gclid=CjwKEAiA0ZC2BRDpo_Pym8m-4n4SJAB5Bn4xKNmW6eXIcw30VA1jqbxXQrB4PfeXN2J4ZpPeZRXboxoCInvw_wcB

Hello thanks for your response.

No I use the internal card reader of my laptop.

But I changed the script while ago and worked for me fine :)