Linux Tactic

Creating a Bootable CentOS USB Stick on Linux: A Step-by-Step Guide

Creating Bootable CentOS USB Stick on Linux

Have you ever needed to install a new operating system, but you didn’t have a CDROM drive, or just didn’t want to burn a disk? Fortunately, there is a solution – a USB stick! In this article, we’ll show you how to create a bootable CentOS USB stick on Linux.

Prerequisites

Before we begin, we need to make sure we have the following:

– A USB stick with at least 8GB of space

– A Linux distribution installed on your computer

– A CentOS ISO file downloaded.

Downloading CentOS ISO file

First, we need to download the CentOS ISO file. You can find the downloads for CentOS at their website.

We recommend downloading the minimal ISO or DVD ISO for the version of CentOS you plan to use.

Using dd command

Now that we have our ISO file, we can use the dd command to create our bootable CentOS USB stick. The dd command is used to flash ISO images onto USB flash drives.

Follow these steps:

Step 1: Insert your USB flash drive into your computer.

Step 2: Open a terminal window and enter the following command to find the name of the USB device:

“`lsblk“`

This command lists all the available block devices.

We need to locate the USB flash drive. You can identify the USB flash drive by its size.

Once you have identified it, make a note of the device name (for example, /dev/sdb). Step 3: Unmount the USB device using the umount command:

“`sudo umount /dev/sdb“`

This command ensures that the USB flash drive is not mounted, meaning it is not currently in use by the operating system.

Step 4: Flash the CentOS ISO image to the USB flash drive using the dd command:

“`sudo dd bs=4M if=/path/to/centos.iso of=/dev/sdb conv=fdatasync status=progress“`

Here, we are writing the CentOS ISO image to the USB flash drive located at /dev/sdb. You will need to replace /path/to/centos.iso with the actual path to your CentOS ISO file.

The bs=4M option sets the block size for the dd command to 4 megabytes, which is generally faster than a smaller block size. The conv=fdatasync option ensures that all data is written to the USB flash drive before the command exits.

The status=progress option shows the progress of the write operation in real time. After a few minutes (depending on the speed of your computer and USB flash drive), the CentOS ISO image will be written to the USB flash drive.

Congratulations! You now have a bootable CentOS USB stick.

Finding the USB Device Name

Sometimes it can be difficult to determine the name of your USB device. If you are having trouble finding your USB flash drive, follow these steps:

Step 1: Insert your USB flash drive into your computer.

Step 2: Open a terminal window and enter the following command:

“`lsusb“`

This command lists all the USB devices connected to your system. We are looking for information about the USB flash drive.

Step 3: Look for the line that has your USB flash drive’s manufacturer and model. It should look something like this:

“`Bus 001 Device 007: ID 0951:1665 Kingston Technology“`

Here, we can see that the USB flash drive is made by Kingston Technology.

Step 4: Now, we need to find the device name. Enter the following command:

“`dmesg | grep -i ‘usb’“`

This command shows the kernel messages related to USB devices.

We are interested in the messages that are related to the USB flash drive. Step 5: Scroll through the output until you find the message that includes the manufacturer and model of your USB flash drive.

“`[119768.983657] usb 1-2: Manufacturer: Kingston“`

“`[119768.983658] usb 1-2: SerialNumber: 00123456789ABCEF“`

Here, we can see that the USB flash drive is connected to USB port 1-2. Make note of the USB port and use the following command to find the device name:

“`lsusb -t“`

This command shows the topology of the USB devices.

We need to find the USB port that our USB flash drive is connected to. In the output of the lsusb -t command, look for the USB port number that matches the USB port number from the dmesg command.

For example:

“` /: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 480M“`

“`/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 5000M“`

“`/: Bus 01.Port 2: Dev 4, If 0, Class=Mass Storage, Driver=usb-storage, 5000M“`

Here, we can see that the USB flash drive is connected to Bus 01, Port 2. The device name will be /dev/sdX, where X is a letter representing the USB flash drive.

You can use the lsblk command as described above to confirm.

Conclusion

Creating a bootable CentOS USB stick on Linux may seem complicated, but with the right tools and commands, it can be a breeze. In this article, we covered how to download the CentOS ISO file, how to use the dd command to flash the ISO image to the USB flash drive, and how to find the name of the USB device using the lsblk and dmesg commands.

With this knowledge, you can install a new operating system on your computer without the need for a CDROM drive.

Flashing the CentOS ISO Image to the USB Drive

Creating a bootable CentOS USB stick on Linux is a great way to install a new operating system. It’s faster than burning a CDROM, and it doesn’t require a CDROM drive.

In the previous section, we covered how to prepare your system and download the CentOS ISO file. In this section, we’ll show you how to flash the CentOS ISO image to your USB flash drive using the dd command.

Using the dd Command

The dd command is a powerful tool that allows you to copy and convert files. In our case, we will use it to flash the CentOS ISO image to our USB flash drive.

Before we start, we need to make sure we have the following:

A USB flash drive with at least 8GB of space. A CentOS ISO file downloaded.

The path to the CentOS ISO file. To begin, plug your USB flash drive into your computer’s USB port.

Once it’s plugged in, open a terminal window. Next, type the following command to get the path to your USB flash drive:

“`$ sudo fdisk -l“`

This command displays all of the disks available on your system.

Look for the device that corresponds to your USB flash drive. Its name typically starts with /dev/sd, followed by a letter.

For instance, /dev/sdb. To avoid any errors and get the right image path, it’s best to unmount the USB flash drive before beginning.

To do this, use the following command:

“`$ sudo umount /dev/sdX“`

Replace “X” with your USB flash drive letter. After successfully unmounting, we can begin the ISO image flashing process using the dd command.

Insert the CentOS ISO file path and the USB flash drive path in the terminal window, and execute the following command:

“`$ sudo dd if=/path/to/centos.iso of=/dev/sdX bs=4M status=progress“`

If the CentOS ISO file is in your Downloads folder, the command should look like this:

“`$ sudo dd if=~/Downloads/centos.iso of=/dev/sdX bs=4M status=progress“`

The options in the command do the following:

– if: specifies the path to the source image file (centos.iso). Be sure to specify the correct path.

– of: specifies the output device (the USB flash drive). Replace X with the device letter that corresponds to your USB flash drive.

– bs: this option specifies the block size. An optimum value is 4M, which means that the operation is executed with large-sized blocks.

Different values of block size might affect the progress bar. – status=progress: This option shows the progress of the operation.

Please note that writing the ISO image to the USB flash drive will take some time, and the progress bar will not be consistent. Depending on the USB stick’s speed, it can take from a few minutes to more than half an hour.

It’s best not to touch your USB stick while the command is running, as it can disrupt the process and result in a non-bootable USB stick.

Once the command finishes, the CentOS ISO image will be successfully flashed to your USB flash drive, and you’ll have a CentOS installation drive.

Conclusion

Creating a bootable CentOS USB stick on Linux is an essential skill every Linux user should have. In this section of the article, we have shown you how to flash the CentOS ISO image to your USB flash drive using the dd command.

Writing the ISO image to the USB flash drive takes time, and it’s crucial to avoid the temptation to cancel the command or remove the USB stick. Now that you have the CentOS installation drive, you can install the operating system via your computer’s boot manager.

In this article, we’ve covered how to create a bootable CentOS USB stick on Linux. We began by discussing the prerequisites and downloading the CentOS ISO file.

Next, we went through the process of using the dd command to flash the CentOS ISO image to the USB flash drive. Finally, we explained how to find the USB device name and unmount the USB device.

By following these steps, you’ll be able to install a new operating system on your computer seamlessly. The importance of this skill cannot be understated, as it’s a faster and more convenient way of installing an operating system.

Remember to follow the instructions carefully and avoid canceling the command mid-process. With this knowledge, your Linux experience will be more rewarding and productive.

Popular Posts