TECH / Software & Services 3 min read

How to Write an IMG File to a USB Flash Drive on Windows and Linux

Antonio NEMCD Author
Published Jun 24, 2014 · 3 min

While most operating system installers come as .iso files, many server, router, and embedded distributions – including FreeBSD (memstick.img), OpenWrt, pfSense, OPNsense, Raspberry Pi OS, Home Assistant, and diagnostic tools like MemTest86 – are distributed as raw sector-by-sector disk images with an .img extension.

Flashing an IMG disk image to a USB flash drive with Win32 Disk Imager

Trying to unpack or burn a raw .img file with traditional ISO extractors like PowerISO or UltraISO usually leaves you with a drive that will not boot. An .img file must be written directly to the USB stick byte-for-byte.

Method 1. On Windows With Win32 Disk Imager, Rufus, or Etcher

All three free utilities write raw disk images properly (note that flashing overwrites all existing data on the USB stick):

  • Win32 Disk Imager: the classic minimalist utility with just two buttons. Pick your .img file under Image File, verify your USB drive letter under Device, and click Write. Download it directly from the official SourceForge project page.
  • Rufus: supports .img files natively alongside ISOs – click “Select”, pick your .img file, and click “Start” (Rufus automatically writes it in raw DD mode).
  • balenaEtcher: especially handy because it flashes compressed .img.gz, .img.xz, and .img.zip archives on the fly without making you extract them first.

Method 2. On Linux, macOS, and FreeBSD Using dd

On UNIX-like systems you do not need any extra software – use built-in dd:

# On Linux (verify your USB device name with lsblk first, e.g. /dev/sdb):
sudo dd if=FreeBSD-memstick.img of=/dev/sdb bs=4M status=progress conv=fsync

# On FreeBSD (for example, USB drive /dev/da0):
dd if=FreeBSD-memstick.img of=/dev/da0 bs=1m conv=sync

“It Ruined My USB Drive – It Shows 2 MB or Asks to Format!”

A couple of commenters worried that flashing an .img “broke” their 8 GB or 16 GB flash drive because Windows suddenly showed only a few megabytes of capacity or popped up “You need to format the disk before you can use it.”

Your flash drive is completely fine. FreeBSD, OpenWrt, and Linux images write their own partition tables with UFS or ext4 filesystems that Windows cannot read natively (Windows only sees the tiny EFI boot partition).

Whenever you are done with the bootable USB stick, restore its full factory capacity in 15 seconds using Windows’ built-in diskpart (run Command Prompt as Administrator):

diskpart
list disk
select disk X
clean
create partition primary
format fs=exfat quick
assign
exit
Double-check the disk X number: look closely at the drive size in list disk so you never accidentally run clean on your main system drive!

Another question from the comments: can you shrink an .img file if it is slightly too big for an older USB stick? Because an .img is a raw sector clone, truncating it breaks the inner filesystem – grabbing the next size up USB drive is always the safer route.

Related posts:

Leave a Comment