How to Create a Bootable Linux USB on a Debian-Based System
TL;DR:
This tutorial guides users on creating a bootable Linux USB on a Debian-based system. It covers identifying the USB drive, unmounting and formatting it, flashing a Linux-based ISO using dd, ensuring data integrity, and safely ejecting the USB. It also includes troubleshooting tips for common issues.
Creating a bootable Linux USB drive is essential for installing or repairing a Unix-based system. This guide walks through the process of identifying a USB drive, formatting it, and flashing a Linux-based ISO onto it using the terminal. No specialized software needed!
Prerequisites
- A Debian-based system (e.g., Debian, Ubuntu, or Linux Mint)
- A USB flash drive (at least 4GB recommended)
- A Linux ISO file (e.g., Debian, Ubuntu, Arch, Fedora, etc.)
- Basic familiarity with the Linux terminal
Step 1: Identify the USB Drive
Before writing the ISO file, find the correct USB device name to avoid overwriting important data.
Open a terminal and run:
lsblk
This displays all connected storage devices. Look for your USB drive. It will typically be named something like /dev/sdb, /dev/sdc, or /dev/sda. For example:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 1 8G 0 disk
├─sda1 8:1 1 7.9G 0 part
nvme0n1 259:0 0 1.8T 0 disk
├─nvme0n1p1 259:1 0 512M 0 part /boot/efi
├─nvme0n1p2 259:2 0 1.8T 0 part /
└─nvme0n1p3 259:3 0 977M 0 part [SWAP]
Here, the USB drive is identified as /dev/sda. Ensure you choose the correct device, as selecting the wrong one can erase your system.
Step 2: Unmount and Format the USB Drive
If the USB drive is mounted, unmount it before proceeding:
sudo umount /dev/sda*
To format the USB, use the mkfs command:
sudo mkfs.vfat -F32 /dev/sda
For a completely clean state, you can wipe the drive first:
sudo wipefs --all /dev/sda
Step 3: Flash the Linux ISO to the USB
Use the dd command to write the ISO file to the USB device. Replace linux.iso with the correct path to your ISO file.
sudo dd if=/home/user/Downloads/linux.iso of=/dev/sda bs=4M status=progress
Explanation of the command:
- if= specifies the input file (ISO file location)
- of= specifies the output device (USB drive)
- bs=4M optimizes the write speed by using 4MB blocks
- status=progress shows real-time progress
This process may take several minutes. Do not interrupt it.
Step 4: Ensure Data is Fully Written
Run:
sync
This ensures that all data is written to the USB before removal.
Step 5: Eject the USB Drive
sudo eject /dev/sda
Now you can safely remove the USB drive.
Booting from the USB
- Insert the USB into the target system.
- Restart the system and enter the BIOS/UEFI settings (usually by pressing
F2,F12,DEL, orESCduring boot). - Select the USB drive as the boot device.
- Follow the on-screen instructions to install or run the Linux distribution.
Troubleshooting
1. USB Not Detected in BIOS
- Ensure the USB is plugged into a primary USB port.
- Try using a different USB drive.
- Check if Secure Boot is enabled and disable it if necessary.
2. dd Command Stuck
- Some systems may not show progress. Let it run for a few minutes.
- If unsure, check the write process with:
sudo dmesg | tail
3. Permission Denied Errors
Ensure you have sudo privileges when running dd:
sudo dd if=/path/to/iso of=/dev/sdX bs=4M status=progress
Conclusion
By following these steps, you can successfully create a bootable Linux USB drive using the command line. This method ensures a clean and efficient process without the need for third-party tools. 🚀
Latest Comments
Sign in to add a commentNo comments yet. Be the first to comment!