HowTo: Copy NanoBSD images on the fly with ETA + nice progress bar using DD
-
If you want to see ETA and a nice progress bar in the console during DD'ing the NanoBSD image to the CF or other flash-based media, you can use the linux tool named "bar". It's not there by default but it's only 140kb in size and can be installed in Ubuntu/Debian with apt-get install bar.
Also you can gunzip on the fly the image straight to dd, so you don't necessarily have to gunzip the image first to an uncompressed raw file.
Here's a script which automates all this stuff:
#!/bin/bash # sudo apt-get install bar dd awk image_name="pfSense-2.2-RELEASE-4g-i386-nanobsd-vga.img.gz" device="/dev/sdb" image_type="$(file -i $image_name | awk ' { print $2 }')" echo -n Copying $image_name to $device size=0 case "$image_type" in "application/gzip;") # Write a gzip compressed image size=$(gunzip -l $image_name | tail -n1 | awk ' { print $2 } ') echo , size $size gunzip -c $image_name | dd bs=512 2>/dev/null | bar -s $size -dan > $device ;; *) # If we don't know what image type it is assume is a raw image size=$(ls -l $image_name | awk ' { print $5 } ') echo , size $size dd if=$image_name bs=512 2>/dev/null | bar -s $size -dan > $device ;; esac