There are two ways to create ISO file in Linux.
Method 1 :
Suppose you have any CD or DVD then you can create iso file using dd command as below. Please make sure that, while creating iso file the cd or dvd should not be mounted position.
# dd if=/dev/cdrom of=mycd.iso
This command will create iso file from CD or DVD.
But in real life, you come across many situations, where you have to create iso file of existing folder in hard disk. Consider following example.
Suppose you have /mydata folder and you are supposed to create iso file of this folder for writing it on cd or dvd. You can approach the task as below
First check the size of folder using du command.
# du -sh /mydata
If the size of the folder is up to 700 MB then you can write cd otherwise you need dvd to write the same.
Second, create iso file using mkisofs command as below. You need to install the package first.
# yum install genisoimage -y
then create iso file,
# mkisofs -R -o mydata.iso /mydata
Here,
-R option tells command to use Rock Ridge extensions. It means preserve the long file names intact while creating iso file.
-o option specifies the output file name. In this case it is mydata.iso
You can also test the created file using file command as below.
# file mydata.iso mydata.iso: ISO 9660 CD-ROM filesystem data 'CDROM'