How to Make ISO from Directory in Linux

Take Your Linux Skills to the Next Level All courses, certifications, ad-free articles & community — from $8/mo
Join Root →
Ad-free access to all premium articles
Access to all courses: Learn Linux, AI for Linux, Bash Scripting, Ubuntu Handbook, Golang and more.
Access to Linux certifications (RHCSA, RHCE, LFCS and LFCA)
Access new courses on release
Get access to weekly newsletter
Priority help in comments
Private Telegram community
Connect with the Linux community
From $8/mo · or $59/yr billed annually · Cancel anytime

Creating an ISO file from a directory in Linux is a useful task for various purposes, such as distributing software, creating bootable media, or backing up data.

ISO files are a standard format for storing and distributing data, and they can be easily created using the command line in Linux.

In this article, we will guide you through the process of creating an ISO file from a directory using the genisoimage command.

Step 1: Installing genisoimage Tool in Linux

The genisoimage package is used for creating ISO-9660 CD-ROM filesystem images in Linux. It is a pre-mastering program that can be used to create bootable CDs and CDs with support for the Macintosh HFS filesystem.

The package is part of the cdrkit suite and includes tools like mkzftree, dirsplit, and geteltorito for working with ISO images.

To install genisoimage on Linux, use the following appropriate command for your specific Linux distribution.

sudo apt install genisoimage         [On Debian, Ubuntu and Mint]
sudo yum install genisoimage         [On RHEL/CentOS/Fedora and Rocky/AlmaLinux]
sudo emerge -a sys-apps/genisoimage  [On Gentoo Linux]
sudo apk add genisoimage             [On Alpine Linux]
sudo pacman -S cdrtools              [On Arch Linux]
sudo zypper install genisoimage      [On OpenSUSE]    
sudo pkg install genisoimage         [On FreeBSD]

Step 2: Creating an ISO File from a Directory

Navigate to the parent directory of the directory you want to create the ISO file from using the cd command.

For example, let’s assume your directory is called my_folder and is located in your home directory, you can use the following command:

cd /home/ravi/

Now, run the genisoimage command to create the ISO file.

genisoimage -o my_folder.iso my_folder/

Here’s what each part of the command means:

  • genisoimage -: This is the command used to create the ISO file.
  • -o output.iso – This specifies the output file name for the ISO file. In this case, it will be named "my_folder.iso".
  • my_folder – This is the name of the directory you want to create the ISO file from.

Once the command completes, you should have an ISO file named my_folder.iso in your current directory. To verify that the ISO file was created correctly, you can use the ls command:

ls -lh my_folder.iso
Create ISO File from a Directory
Create ISO File from a Directory

Step 3: Mount the ISO File (Optional)

To ensure that the ISO file contains the correct data, you can mount it and check its contents. Create a mount point (a directory where you will mount the ISO) and mount the ISO file using the following commands:

sudo mkdir /mnt/iso
sudo mount -o loop my_folder.iso /mnt/iso

Now, you can navigate to /mnt/iso and check the files:

cd /mnt/iso
ls

This will show you the contents of the ISO file. When you’re done, unmount the ISO file:

cd ~
sudo umount /mnt/iso
Mount ISO File
Mount ISO File
Conclusion

Creating an ISO file from a directory in Linux is a simple process involving a few commands. By following this guide, you can easily create an ISO file for backups, distribution, or other purposes.

Root Plan
Premium Linux Education for Serious Learners

Take Your Linux Skills to the Next Level

Root members get full access to every course, certification prep track, and a growing library of hands-on Linux content — with new courses added every month.

What You Get
Ad-free access to all premium articles
Access to all courses: Learn Linux, AI for Linux, Bash Scripting, Ubuntu Handbook, Golang and more.
Access to Linux certifications (RHCSA, RHCE, LFCS and LFCA)
Access new courses on release
Get access to weekly newsletter
Priority help in comments
Private Telegram community
Connect with the Linux community
Ravi Saive
I'm Ravi Saive, an award-winning entrepreneur and founder of several successful 5-figure online businesses, including TecMint.com, GeeksMint.com, UbuntuMint.com, and the premium learning hub Pro.Tecmint.com.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

1 Comment

Leave a Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.

Root Plan Premium Linux Education for Serious Learners

Before You Go - Upgrade Your Linux Skills

Root members get everything in one place, with new courses added every month.

What You Get
Ad-free access to all premium articles
Access to all courses: Learn Linux, AI for Linux, Bash Scripting, Ubuntu Handbook, Golang and more.
Linux certifications: RHCSA, RHCE, LFCS and LFCA
Access new courses on release
Weekly newsletter, priority support & Telegram community
Join Root Today and Start Learning Linux the Right Way
Structured courses, certification prep, and a community of Linux professionals - all in one membership.
Join Root Plan →
$8/mo · or $59/yr billed annually