Creating Linux Installation USB Media Using dd

Creating a bootable Linux USB disk using dd involves several steps. This is a step-by-step guide to help you create a Linux installation USB drive using the dd command on a Linux or macOS system. The process includes downloading the Linux ISO, identifying the correct USB device, and using dd to copy the image to the USB drive.

Prerequisites:

  1. A Linux or macOS computer.
  2. A USB flash drive with at least 4GB of storage (more for larger distributions).
  3. A downloaded Linux ISO file (e.g., Ubuntu, Fedora, etc.).
  4. Access to the terminal with sudo privileges.

Step 1: Download the Linux ISO

  1. Visit the website of the Linux distribution you want to install (e.g., Ubuntu: https://ubuntu.com/download).
  2. Download the ISO image file for the desired Linux distribution.

Step 2: Insert the USB Drive

  1. Insert the USB drive into your computer’s USB port.
  2. Important: Make sure no important data is on the USB drive because this process will erase all content on it.

Step 3: Identify the USB Device

You need to determine the device name of your USB drive. Use one of the following commands:

For Linux:

Open a terminal.

Run the command lsblk or fdisk -l to list all the storage devices connected to your system.
lsblk

Find the USB drive in the list (it is usually something like /dev/sdX, where X is a letter like b, c, etc.). For example, it might be /dev/sdb. Be careful to select the correct device! The wrong device can result in data loss.

For macOS:

Open the Terminal.

Run the following command to list disks:
diskutil list

Identify your USB drive in the list. For example, it could be /dev/disk2.

Step 4: Unmount the USB Drive (if mounted)

Before writing the ISO to the USB drive, you need to unmount it. This prevents the system from interfering with the process.

For Linux:

If the USB drive is mounted, unmount it using the following command (replace /dev/sdX1 with the partition on your USB drive, like /dev/sdb1):
sudo umount /dev/sdX1

 If multiple partitions are mounted, unmount each one (e.g., /dev/sdb2, /dev/sdb3, etc.).

For macOS:

If the USB drive is mounted, unmount it using the diskutil unmountDisk command (replace disk2 with the actual disk identifier):
sudo diskutil unmountDisk /dev/disk2

Step 5: Write the ISO to the USB Drive Using dd

Now, you’ll use the dd command to write the ISO image to the USB drive. Make sure you replace the paths below with the correct paths for your system.

For Linux:

Use the dd command to copy the ISO to the USB drive. Replace /path/to/linux.iso with the actual path to your downloaded ISO, and /dev/sdX with the correct USB device (e.g., /dev/sdb).
sudo dd if=/path/to/linux.iso of=/dev/sdX bs=4M status=progress oflag=sync

  1. Explanation:
    • if=/path/to/linux.iso: The input file (your Linux ISO image).
    • of=/dev/sdX: The output file (your USB drive; do not include a partition number like /dev/sdb1, just the device itself).
    • bs=4M: Sets the block size to 4MB for faster copying.
    • status=progress: Shows the progress of the copy.
    • oflag=sync: Ensures all data is written to the device before finishing.
  2. Important: Double-check that you are using the correct device path for your USB drive (/dev/sdX). Writing to the wrong device will overwrite other data.

For macOS:

Use the dd command to copy the ISO to the USB drive. Replace /path/to/linux.iso with the actual path to your downloaded ISO, and /dev/disk2 with the correct disk identifier.


sudo dd if=/path/to/linux.iso of=/dev/disk2 bs=1m status=progress

  1. Explanation:
    • if=/path/to/linux.iso: The input file (your Linux ISO image).
    • of=/dev/disk2: The output file (your USB disk; no partition number like disk2s1, just disk2).
    • bs=1m: Sets the block size to 1MB for faster copying.
    • status=progress: Shows the progress of the copy.
  2. Important: As with Linux, double-check that you’re writing to the correct disk (/dev/disk2), not a partition (e.g., /dev/disk2s1).

Step 6: Sync and Eject the USB Drive

Once the dd command completes, it’s important to ensure that all data has been written to the USB drive before removing it.

For Linux:

Run the sync command to flush any remaining data:
sudo sync

Once the process is complete, you can safely eject the USB drive.

For macOS:

Run the sync command:
sudo sync

Once the process is complete, eject the USB drive with:
sudo diskutil eject /dev/disk2

Step 7: Boot from the USB Drive

  1. Insert the USB drive into the target computer where you want to install Linux.
  2. Power on the computer and immediately press the boot menu key (usually one of the following: F12, Esc, F10, or Del).
  3. Select the USB drive as the boot device and proceed with the installation of Linux.

Troubleshooting Tips:

  • If dd hangs or takes too long: This could be due to a slow USB drive or a large ISO image. You can try using smaller block sizes (e.g., bs=1M) to see if it speeds up.
  • If the USB drive doesn’t boot: Ensure the BIOS or UEFI settings on the target computer are configured to boot from USB. You may need to disable Secure Boot in UEFI if you’re installing Linux on a newer system.

Similar Posts