Walker News

How To Convert Folder To ISO CD Image On Linux?

Since it is easier to zip or archive the installer folder using tar command, why bother convert the folder into ISO CD image file?

Let’s what are the benefits of using ISO image file before jumping to the following guide.

Firstly, it is convenient to keep just one single ISO image file of a folder containing hundreds or thousands of files. In additional, maintaining file checksum (for integrity assurance) of one CD image file is a lot simpler than a long list of individual files.

Secondly, one can easily mount the ISO CD image on Linux using loopback device (or virtual CD-drive on Windows) to access the image file contents.
For example, the download of IBM DB2 fix pack is normally a few hundred MB gzipped-tar archive file. When installing on virtual machine for testing, I have to spend time uploading it to the VM and then unpack it for installation. Why don’t convert the DB2 fix pack folder to ISO image file that can be mount on VM or virtual drive?

Using Linux mkisofs to create ISO image file from folder

Now, let’s see how to convert IBM DB2 fix pack directory into ISO CD image file:

Unpack the tar.gz or tgz file to folder. For example:
tar -zxvpf v9fp8_linuxx64_wse.tar.gz

Now, run this lengthy mkisofs command to create ISO image file (DB2v9fp4x64.iso) from the DB2 fix pack folder (v9fp8_linuxx64_wse):
mkisofs -log-file iso.log -o DB2v9fp4x64.iso -r -joliet-long -allow-leading-dots -iso-level 4 -allow-lowercase -allow-multidot v9fp8_linuxx64_wse

To verify the ISO image file content, run this command to mount (on RHEL5.2):
mount -o loop -t iso9660 DB2v9fp4x64.iso /media

Next, generate checksum of all files on both CD image and fix pack folder then run diff to compare the two sets of file checksum. For example:
cd /media
find . -exec md5sum {} \; >/tmp/cd.log
cat /tmp/cd.log | sort -k 2 >/tmp/cdsort.log

cd v9fp8_linuxx64_wse
find . -exec md5sum {} \; >/tmp/dir.log
cat /tmp/dir.log | sort -k 2 >/tmp/dirsort.log

diff /tmp/cdsort.log /tmp/dirsort.log | less

As far as my verification tells, the mkisofs works well, particularly for DB2 fix pack case. If you want to follow, please do verify the CD image content with those in original folder (as above).

Custom Search

2017  •  Privacy Policy