12-17-2019, 07:16 PM
(This post was last modified: 12-20-2019, 02:48 AM by Arglebargle.)
Hi all,
I've seen a lot of people struggling flashing images to sd cards/emmc from the command line and even more people asking for support after flashing images improperly or without media verification. I wrote a script to make this process easier, hopefully it will reduce the number of problems people are experiencing.
The script handles both raw images (.img files) and xz compressed images and will write and then verify, or with the --verify-only flag simply verify, that your media has been written correctly.
The script is located here: https://github.com/foundObjects/sbc-flasher
Installation is simple, either download the script and optionally make it executable and place it somewhere in your path or just run the installer code below. If pv isn't installed in your distribution by default you'll need to install it if you want pretty progress meters. The installer will ask for sudo permission to install the script in /usr/local/sbin as needed, so there's no need to run it with sudo or as root.
Use:
Flashing an image:
Flash verification is simple as well:
Debugging:
Run the script with -x: `sudo flasher.sh -x yourimage /dev/flash_target |& tee flashlog` to see what's going wrong and dump execution flow to a file. Please use pastebin.com (or hastebin.com, everyone should use hastebin because hastebin is awesome) instead of pasting debug output here if you need help.
You're welcome to do whatever you want with this script, hopefully it saves everyone some time.
I've seen a lot of people struggling flashing images to sd cards/emmc from the command line and even more people asking for support after flashing images improperly or without media verification. I wrote a script to make this process easier, hopefully it will reduce the number of problems people are experiencing.
The script handles both raw images (.img files) and xz compressed images and will write and then verify, or with the --verify-only flag simply verify, that your media has been written correctly.
The script is located here: https://github.com/foundObjects/sbc-flasher
Installation is simple, either download the script and optionally make it executable and place it somewhere in your path or just run the installer code below. If pv isn't installed in your distribution by default you'll need to install it if you want pretty progress meters. The installer will ask for sudo permission to install the script in /usr/local/sbin as needed, so there's no need to run it with sudo or as root.
Code:
bash <(wget -o /dev/null -qO- https://raw.githubusercontent.com/foundObjects/sbc-flasher/master/install.sh)
sudo apt install -y pv
Use:
Code:
# sudo flasher.sh
Usage: /usr/local/sbin/flasher.sh (--flags) image(.img|.xz) /dev/target_block_device
Flags:
-W | --write-only | --write Write pass only, no verification
-V | --verify-only | --verify Verify only
-x | --debug Extremely verbose output (like bash -x ...)
--no-pv Don't use pipeviewer
Flashing an image:
Code:
root@pinebookpro:/data/images# flasher.sh pinebookpro-debian-mrfixit-191127.img.xz /dev/mmcblk0
writing xz compressed image to /dev/mmcblk0
5.01GiB 0:02:46 [30.8MiB/s] [==================================================================>] 100%
0+574861 records in
0+574861 records out
5377097728 bytes (5.4 GB, 5.0 GiB) copied, 181.469 s, 29.6 MB/s
Write successful
Verifying xz image
5.01GiB 0:03:37 [23.6MiB/s] [==================================================================>] 100%
Image verified successfully
Flash verification is simple as well:
Code:
root@pinebookpro:/data/images# flasher.sh --verify-only pinebookpro-debian-mrfixit-191127.img /dev/mmcblk0
Verifying raw image
335MiB 0:00:11 [26.6MiB/s] [===> ] 6% ETA 0:02:37
Debugging:
Run the script with -x: `sudo flasher.sh -x yourimage /dev/flash_target |& tee flashlog` to see what's going wrong and dump execution flow to a file. Please use pastebin.com (or hastebin.com, everyone should use hastebin because hastebin is awesome) instead of pasting debug output here if you need help.
You're welcome to do whatever you want with this script, hopefully it saves everyone some time.