In this tutorial, we will explain how to create a bootable CentOS USB  stick from the Linux terminal. You can use this USB stick to boot and  test out or install CentOS on any computer that supports booting from  USB.

Prerequisites

  • An 8GB or larger USB stick drive
  • Computer running any Linux distribution

Downloading CentOS ISO file

Download the CentOS ISO file from the CentOS downloads page where you can choose between “DVD ISO” and “Minimal ISO”.

The  minimal installation image contains only the packages needed to have a  functional CentOS system. The DVD image contains all the packages that  can be installed using the installer.

Most likely you will want to download the “DVD ISO” version.

Creating Bootable CentOS 7 USB Stick on Linux

While  there are many different GUI tools that allows you to flash ISO images  to USB drives, in this tutorial, we will create a bootable CentOS 7 USB  stick using the dd command.

Creating Bootable CentOS 7 USB Stick on Linux is a quick and easy process, just follow the steps detailed below.

  1. Insert the USB flash drive into the USB port.

Find out the name of your USB drive with the lsblk command:

lsblk

The output will look like this:

NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda           8:0    0 465.8G  0 disk 
└─sda1        8:1    0 465.8G  0 part /data
sdx           8:16   1   7.5G  0 disk 
└─sdx1        8:17   1   7.5G  0 part /run/media/black/Kingston
nvme0n1     259:0    0 232.9G  0 disk 
├─nvme0n1p1 259:1    0   512M  0 part /boot
├─nvme0n1p2 259:2    0    16G  0 part [SWAP]
└─nvme0n1p3 259:3    0 216.4G  0 part /

In our case the name of the USB device is /dev/sdx but this may vary on your system.

On  most Linux distributions the USB flash drive will be automatically  mounted when inserted. Before flashing the image make sure the USB  device is not mounted. To do so use the umount command followed by either the directory where it has been mounted (mount point) or the device name:

sudo umount /dev/sdx1

The last step is to flash the CentOS ISO image to the USB drive. Make sure you replace /dev/sdx with your drive and do not append the partition number. Also, replace /path/to/CentOS-7-x86_64-DVD-1810.iso with the path to the ISO file. If you downloaded the file using a web browser then it should be stored in the Downloads folder located in your user account.

sudo dd bs=4M if=/path/to/CentOS-7-x86_64-DVD-1810.iso of=/dev/sdx status=progress oflag=sync

The command will show a progress bar while flashing the image.

The  process may take several minutes, depending on the size of the ISO file  and the USB stick speed. Once completed you will see something like  below:

1094+0 records in
1094+0 records out
4588568576 bytes (4.6 GB) copied, 30.523 s, 150 MB/s

That’s all, at this point you have a bootable CentOS on your USB stick.

Conclusion

In this article, you’ve learned how to create a bootable CentOS USB stick from the Linux command line.

If you hit a problem or have feedback, leave a comment below.