Bootable USB using dd command in GNU/Linux system

  • Posted on: 9 January 2020
  • By: dexter

With CD/DVD drives almost gone from our systems, the easiest way today to install a new system is via a USB pen drive.  The following are the steps how to create a USB bootable drive by writing a ISO image to the same.

Prerequisites:

  1. Downloaded iso image.
  2. Verify the checksum of the image.
  3. Make sure you have "dd" command installed. (This should be there by default)
  4. A USB pen drive equal to or greater than the size of ISO image. (A bit higher capacity would be preferred)
    1. Be aware that all contents from the pen drive will be wiped. So make sure either you have copied the contents or you do not need them.

Steps

  • Verify the checksum
    • From where ever you download your ISO you will get the checksum file also.
    • Depending upon the checksum type value available we will run the checksum on the downloaded file.
    • Lets say we have download a file  linux-mint.iso and its sha256sum is 7b53b29a34cfef4ddfe24dac27ee321c289dc2ed8b0c1361666bbee0f6ffa9f4
    • Run the following command:
      • sha256sum linux-mint.iso
      • The output value of this command and the sha256sum value should be exactly same.
      • sha256sum check on a file
    • If the values are same you can proceed safely ahead. Else download the file again.
  • Verify if the iso image is bootable
    • Run the following command on iso image.
      • file isofilename.iso
      • If you can see " DOS/MBR boot sector;" some where, it means you image is bootable. And you need to follow the next step.
      • Linux file command output for iso image
  • Making iso image bootable
    • To make ISO image bootable we use the isohybrid command.
    • isohybrid isofilename.iso
      • Use -u option to enable uefi mode.
      • Make a copy of original image before hand if needed.
      • isohybrid command to convert iso image to bootable
  • Finding out pen drive device name.
    • Run dmesg command to find out the device name
    • usually toward the end  you will see some message indicating what is your device name.
    • Note this down, it is very important to identify the device name correctly, If you end up mentioning wrong device name with the dd command you can mess up the system.
    • Linux dmesg command output after connecting usb device
    • In above we can see that our device is sdc.
    • Note that if your device was mounted automatically we need to unmount it before proceeding.
      • run the following command as root or using sudo
      • umount /dev/sdc1
      • umount /dev/sdc2
  • Writing image to the pen drive
    • Note: double check all the file name and device name before running the command
    • We will use the dd command to write the image to the pendrive
      • The iso image name with us that will be the inputfile.
      • The device file name i.e. /dev/sdc this will be our outputfile.
      • Block size of 4MB that will be our bs value.
      • And finally the option status=progress to see what is happening.
    • Run the following command as root or using sudo (replace filename accordingly)
      • dd if=myisofilename.iso of=/dev/sdc bs=4MB status=progress
    • If you do not get any error, congrats your pen drive is now bootable.

Add new comment

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.