hypriot / flash

Command line script to flash SD card images of any kind
MIT License
1.01k stars 173 forks source link

Flash should check the image file before flashing #95

Closed ggtools closed 5 years ago

ggtools commented 7 years ago

I curled the latest image forgetting to put the -L argument resulting in a .zip file containing HTML code indicating the redirection to S3:

$ file hypriotos-rpi-v1.1.3.img.zip
hypriotos-rpi-v1.1.3.img.zip: HTML document text, ASCII text, with very long lines, with no line terminators

However when attempting to flash I had little feedback:

Is /dev/disk2 correct? y
Unmounting disk2 ...
Unmount of all volumes on disk2 was successful
Unmount of all volumes on disk2 was successful
Flashing hypriotos-rpi-v1.1.3.img.zip to disk2 ...
Password:
 605 B 0:00:00 [6.27MiB/s] [=====================================================>] 100%
dd: /dev/rdisk2: Invalid argument
0+1 records in
0+0 records out
0 bytes transferred in 0.000066 secs (0 bytes/sec)
Unmounting and ejecting disk2 ...
Unmount of all volumes on disk2 was successful
Unmount failed for /dev/disk2s2
Disk /dev/disk2 ejected
🍺  Finished.

The final message give the impression that everything have gone smoothly and the only indications are the number of record transferred and the dd: /dev/rdisk2: Invalid argument message which gives the impression of a problem with the device rather than a problem with the image file.

For information, when downloaded correctly the final image file should look like:

file hypriotos-rpi-v1.1.3.img
hypriotos-rpi-v1.1.3.img: DOS/MBR boot sector; partition 1 : ID=0xc, start-CHS (0x0,32,33), end-CHS (0x8,73,1), startsector 2048, 131072 sectors; partition 2 : ID=0x83, start-CHS (0x8,73,2), end-CHS (0x7f,122,58), startsector 133120, 1914879 sectors

I don't know if checking DOS/MBR boot sector will be too restrictive or if there is a smarter way to check this. At any rate it might be great to give at least a warning before proceeding to the dd part

StefanScherer commented 7 years ago

Difficult to solve this. But you can use flash with the download URL, it does everything for you in one step.