Iso image files are distributed as a single downloadable file for bootable OS, games, etc. It is important to know how to create an iso file from a directory or existing USB bootable drive etc. The following article guides you on the same.
What is an Iso image file?
An Iso file also referred to as iso image is an archive file that contains a set of files/directories. The name Iso is derived from ISO 9660 filesystem that was used in CD-ROM media. It uses a file extension .iso
An Iso image is a sector by sector copy of data on an optical disk. Nowadays most of the operating systems are distributed as an iso image. It makes it easy to share so many files by archiving into one file. In this article, we will discuss a few command-line utilities that can be used to create an Iso file from a directory, CDs or DVDs, etc.
How to Create an Iso image file from a directory using genisoimage
The genisoimage application was developed as a part of the cdrkit project. It creates ISO9660/Joliet/HFS filesystem images. The iso image created by genisoimage can be burnt to a CD/DVD using a burning tool. Generally, it comes preinstalled with many Linux distributions. but if you don’t have in your system you can install it by using the following command-
sudo apt-get install genisoimage
To create an iso file from a directory first gather all the files into that directory and then execute the given command-
genisoimage -o output_file.iso directory_name
For example – I have a directory with the name Sample on my Desktop which contains few files. I want to create an iso file from it then simply I will use the commands that are given below-
cd Desktop
(Change the current working directory to Desktop)
genisoimage -o Sample.iso Sample
Now an iso file with the name Sample.iso is created on Desktop. You can also use the following command if you are intended to create an iso image from several file or folder-
genisoimage -o output_file.iso file1 file2 file3[alert color=”yellow”]Please note that iso image created from several files or folders will not have a single root directory.[/alert]
How to Create an Iso file from a CD or DVD?
CD/DVD optical drives are rare in a modern computer system where USB drives are dominating because of the form factor and large storage capacity. But still, if you have an optical drive then follow the below guide to create an iso image from a CD/DVD.
To create an ISO file from CD or Dvd we will use a utility called dd. It is a tool commonly used for Unix like operating systems to convert and copy files. First, unmount the device if it is already mounted by using given command-
umount /dev/cdrom
Then use the following command to create ISO image –
dd if= /dev/cdrom of= output_file.iso
Please make sure to remove /dev/cdrom
with your own CD’s location.
Where if and of are Input file and output file respectively.
How to Create an Iso file from an existing bootable USB drive
Earlier Siba had posted on how to create USB bootable from an iso image. Similarly, it is possible to create an iso image from an existing bootable USB drive.
To create an Iso file from the files stored in a bootable USB drive we will again use the dd command. Before creating the Iso file, insert your USB and find its name by using df command –
df -hT
As you can see the USB name in the above image i.e. /dev/sdb1
. The USB on your PC may have a different name so make sure to replace it with the exact name. And then execute the following command to create Iso file –
sudo dd if=/dev/sdb1 of=/home/lalit/Desktop/kali.iso
It may take a few seconds to copy and create an iso file on the mentioned path.