ThisCalculator

Everyday

Burn an ISO Image From the Command Line

Updated · Standard formula, shown below

Burn an ISO Image From the Command Line

Yes, you can burn an ISO image to a USB drive or optical disc entirely from the command line, and the process is often faster and more scriptable than using a graphical tool. You use built-in utilities like dd on Linux/macOS or cdrecord/wodim for CDs, and diskpart or Rufus (CLI) on Windows. This guide covers the exact commands for each platform, how they work, and how to avoid the common mistake of overwriting the wrong drive.

What an ISO Image Actually Is

An ISO file (named after the ISO 9660 filesystem standard) is a sector-by-sector archive of an optical disc. It contains not just files and folders, but also the boot sectors, volume descriptors, and file system metadata. When you “burn� it to a USB stick, you are not copying files onto a formatted drive; you are writing raw sectors to the device, replacing its existing partition table and filesystem. That is why the target drive appears “empty� or needs reformatting afterward.

This raw writing is what makes command-line tools so effective. They bypass the operating system’s file manager and write directly to the block device, which is exactly what the ISO format expects.

Linux: Using dd (The Most Common Method)

On Linux, the dd utility is the standard tool for writing an ISO to a USB drive. It is available on virtually every distribution and does not require installation. The basic syntax is:

sudo dd if=/path/to/image.iso of=/dev/sdX bs=4M status=progress && sync

Here is what each part means:

  • if= – input file, the ISO image
  • of= – output file, the target device (e.g., /dev/sdb)
  • bs= – block size; 4M is a good balance of speed and memory use
  • status=progress – shows a live progress bar (optional but helpful)
  • sync – flushes the write cache; without it, data may not be fully written before you unplug

Critical: the output must be the whole device (/dev/sdb), not a partition (/dev/sdb1). Writing to a partition will not make it bootable. Also, double-check the device letter with lsblk or fdisk -l before running; a wrong of= can wipe your hard drive.

macOS: Using dd with a Raw Disk

macOS also includes dd, but you need to identify the correct disk and use a raw device for speed. First, find the disk number:

diskutil list

Look for your USB drive (e.g., /dev/disk2). Then unmount it (not eject) and write:

diskutil unmountDisk /dev/disk2
sudo dd if=/path/to/image.iso of=/dev/rdisk2 bs=4M

Note the r before disk2 – that is the raw device node, which transfers data much faster. You do not need sync on macOS because dd writes synchronously by default. After it finishes, use diskutil eject /dev/disk2 to safely remove the drive.

Windows: Alternatives to Third-Party Tools

Windows does not have a native command-line tool that writes an ISO to a USB drive as raw sectors. The built-in diskpart can prepare a USB stick, but you must then copy the ISO’s contents manually, which does not create a bootable drive for most Linux ISOs. The practical command-line approach is to use Rufus (which has a command-line interface) or dd for Windows from a Unix-like environment (e.g., Git Bash).

With Rufus, the command looks like:

rufus.exe -i image.iso -d 2

where -d 2 is the device index (check with rufus.exe -l). For a pure native solution, you can use diskpart to clean and format the drive, then use expand or copy to place the ISO contents – but that only works for Windows ISOs that support being copied to a FAT32 drive. For Linux ISOs, a tool like Rufus or dd is required.

Burning to an Optical Disc (CD/DVD)

If you are burning to a physical disc, the command-line tools differ. On Linux, wodim (or its predecessor cdrecord) is the classic tool:

wodim -v -eject dev=/dev/sr0 -data image.iso

On macOS, hdiutil can burn an ISO to a disc:

hdiutil burn image.iso

On Windows, the built-in cdburn command is deprecated, but you can use PowerShell with the IMAPI2 COM object for scripting. However, most users prefer a GUI for optical burning because the command-line options are less standardized.

Choosing the Right Target Device

The biggest risk in command-line burning is selecting the wrong device. Here is how to avoid it:

  • Run lsblk (Linux) or diskutil list (macOS) before and after plugging in the USB drive to see which new device appears.
  • Check the size: if your ISO is 4 GB, the target should be at least that size. A 32 GB drive will show as ~31 GB, not 32.
  • Look for the device with no partitions (or one large partition) and a mount point under /media or /Volumes.
  • On Windows, use rufus -l to list devices with their index, model, and size.

If you accidentally write to your system disk, the damage is immediate and irreversible. There is no undo. Always triple-check the device identifier.

Common Problems and How to Fix Them

Even with the right command, things can go wrong. Here are the most frequent issues:

  • “Resource busyâ€� error on Linux/macOS: The drive is mounted. Unmount it first with umount /dev/sdX1 or diskutil unmountDisk.
  • Write is very slow: You might be using a small block size. Increase bs= to 4M or 8M. On macOS, use the raw device (rdisk).
  • USB drive not booting after write: The ISO may be a hybrid image (like many Linux ISOs) that works with dd, but some ISOs (especially Windows) require a different writing method. Also, ensure the system’s boot mode (UEFI vs. Legacy) matches the ISO’s support.
  • dd finishes instantly with no error: You likely wrote to the wrong device or the ISO file does not exist. Check the output with lsblk – it should show the ISO’s filesystem (e.g., ISO9660) on the drive.
  • Permission denied: Use sudo on Linux/macOS or run the terminal as Administrator on Windows.

Frequently Asked Questions

Is using dd safe for my USB drive?

Yes, if you target the correct device. dd overwrites the entire drive, so any existing data is lost. It does not harm the drive hardware itself. The risk is human error – writing to the wrong disk. Always verify the device identifier twice.

Can I use the same command for a Windows ISO?

For a Windows ISO, dd will write the raw image, but the resulting USB drive may not boot on all systems because Windows ISOs are not hybrid images. Microsoft’s official tool or Rufus is recommended for Windows ISOs, as they handle the necessary partition layout.

Do I need to format the USB drive before burning?

No. The ISO write replaces the entire partition table and filesystem. Formatting is unnecessary and actually counterproductive, as it may interfere with the raw write. Just make sure the drive is unmounted.

How long does it take to burn an ISO with dd?

It depends on the ISO size and the USB drive speed. A typical 4 GB ISO to a USB 3.0 drive takes about 1-2 minutes with bs=4M. Slower USB 2.0 drives can take 5-10 minutes. The status=progress option shows the speed and ETA.

What is the difference between /dev/sdb and /dev/sdb1?

/dev/sdb is the whole device (the entire USB stick), while /dev/sdb1 is the first partition on it. For burning an ISO, you must use the whole device. Writing to a partition will not make the drive bootable because the boot sector is at the beginning of the whole device.

Can I burn an ISO to an external hard drive?

Yes, the same commands work, but the entire drive will be overwritten. That means you lose all existing partitions and data. It is not recommended unless you intend to use the entire drive for the ISO.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.