Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    HowTo: Copy NanoBSD images on the fly with ETA + nice progress bar using DD

    Scheduled Pinned Locked Moved Problems Installing or Upgrading pfSense Software
    1 Posts 1 Posters 515 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      robi
      last edited by

      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
      
      

      1 Reply Last reply Reply Quote 0
      • First post
        Last post
      Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.