Skip to content

Instantly share code, notes, and snippets.

@araujo88
Created February 14, 2024 12:42
Show Gist options
  • Save araujo88/6943d4e789c890d9749d19f73bc8c596 to your computer and use it in GitHub Desktop.
Save araujo88/6943d4e789c890d9749d19f73bc8c596 to your computer and use it in GitHub Desktop.
Create bootable usb stick with dd

Creating a bootable USB stick using the dd command is a common task for installing or running a Linux distribution from a USB drive. The dd command is a powerful Unix utility for converting and copying files, and when used correctly, it can write an ISO image of an operating system to a USB stick, making it bootable. Here's a general outline of the steps you need to follow to use dd to create a bootable USB stick:

Step 1: Download the ISO Image

First, you need to download the ISO image of the operating system you want to install. Ensure you have the ISO file saved on your system.

Step 2: Identify the USB Stick

Before using dd, you need to identify the USB stick's device name in your system. Be very careful during this step because selecting the wrong device could overwrite data on another disk.

  1. Insert the USB stick into your computer.
  2. Open a terminal.
  3. Run lsblk or df -h to list all the disks and find your USB stick. The device name is usually something like /dev/sdb or /dev/sdc.

Step 3: Unmount the USB Stick

If your USB stick is automatically mounted, you need to unmount it before proceeding. Replace sdX with your actual device name:

umount /dev/sdX*

Step 4: Use dd to Write the ISO to the USB Stick

Now, use the dd command to write the ISO file to the USB stick. Be sure to replace /path/to/your.iso with the path to your ISO file and sdX with your USB stick's device name. Warning: This will erase everything on the USB stick.

sudo dd bs=4M if=/path/to/your.iso of=/dev/sdX status=progress oflag=sync
  • bs=4M sets the block size to 4MB for faster writing.
  • if= specifies the input file (your ISO image).
  • of= specifies the output file (your USB stick).
  • status=progress shows the progress.
  • oflag=sync ensures the write operation is completed before it's reported as finished.

Step 5: Eject the USB Stick Safely

After the dd command completes, it's a good idea to safely eject the USB stick:

sudo eject /dev/sdX

Important Notes

  • Be very careful with the device name of your USB stick. If you specify the wrong device, you could erase important data.
  • The dd command does not show progress in the traditional way. If you've included status=progress, you will see how much data has been copied in real-time.
  • Depending on the size of the ISO and the speed of your USB stick, the dd process may take a while.

After completing these steps, your USB stick should be bootable with the OS you've chosen. You can then use it to install the OS on a computer by selecting the USB stick as the boot device in the computer's BIOS or boot menu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment