How to create a iso image from a folder or single files via terminal commands? Currently i am doing this via Braseros GUI, but i want to do it with a shell script.

  • 1
    man genisoimage says it all as well.
    – poige
    Commented Sep 15, 2013 at 19:17

5 Answers 5


Seems to be pretty straightforward to do with genisoimage, in the package with the same name on Debian:

genisoimage -o output_image.iso directory_name

There are many options to cover different cases, so you should check the man page to see what fits your particular use case.

See also

  • 3
    @klingt.net In my case, I knew there was such a command but couldn't remember its name. So I did apropos iso, found genisoimage then used the search terms "generate iso with genisoimage".
    – Joseph R.
    Commented Sep 15, 2013 at 19:46
  • 3
    under unix apropros is a synonym for man -k. The latter being a little easier to remember/spell ;)
    – Drav Sloan
    Commented Sep 15, 2013 at 21:37
  • 14
    genisoimage is a dead fork from a mkisofs version from 2004. genisoimage creates filesystem images with defects. This problem can be avoided by using the original software mkisofs instead.
    – schily
    Commented May 31, 2016 at 13:16
  • @schily At least for Debian, mkisofs isn't an option; only genisoimage and xorrisofs are, ideally the latter.
    – Michael A
    Commented Nov 27, 2019 at 21:45
  • 2
    Even for a OSS-hostile distro like Debian, mkisofs is of course an option as you of course can compile it yourself. If you don't like to compile yourself, never use Debian. Note that genisoimage has approx. 100 Bugs listed in the Debian Bug database since 2004 and creates defective filesystems. xorriso on the other side is in a very early state of development and does not yet support the filesystem features (like e.g. UDF) people need.
    – schily
    Commented Nov 28, 2019 at 11:43

Making a CD from a folder can be performed with mkisofs.

mkisofs -lJR -o output_image.iso directory_name

-l : Allow full 31 character filenames.

-J : Generate Joliet directory records in addition to regular iso9660 file names.

-R : Generate System Use Sharing Protocol (SUSP) and Rock Ridge (RR) records using the Rock Ridge protocol

https://linux.die.net/man/8/mkisofs https://en.wikipedia.org/wiki/Rock_Ridge


Take this basic command of:

  mkisofs -o output_image.iso directory_name

One step further, by adding a volume label to the iso, and compressing the iso-image with gzip

  mkisofs -V volume_label -r folder_location | gzip > output-image-comressed.iso.gz

I know it's old, but I found this in Nov/2023 and I know another way to do this using xorriso.


From Debian wiki:

The classical command line interface for production of ISO 9660 filesystem images is the option set established by program mkisofs. For reasons of licensing and other problems with its author, Debian ships a fork of mkisofs, called genisoimage, which was split off in 2006 and then developed independently.

Meanwhile, genisoimage gets no new features and not even bug fixes. It is first choice only if its options -udf or -hfs are needed.

Replacement in most cases, especially for bootable ISO 9660 filesystems, is xorrisofs which starts the -as mkisofs emulation mode of program xorriso.

In most Debian-like systems the "mkisofs" is just an alias to "genisoimage". For example, in Linux Mint 21.2:

$ mkisofs --help
Usage: genisoimage [options] file...
  -nobak                      Do not include backup files
  -no-bak                     Do not include backup files

So, to create an ISO using mkisofs, genisoimage or xorrisofs you do the same way:

  • mkisofs -v -J -r -V MY_DISK_LABEL -o /home/user/file.iso /home/user/for_iso
  • genisoimage -v -J -r -V MY_DISK_LABEL -o /home/user/file.iso /home/user/for_iso
  • xorrisofs -v -J -r -V MY_DISK_LABEL -o /home/user/file.iso /home/user/for_iso

mean in particular:

  • -v lets the program be verbose about minor problems or noteworthy facts
  • -J enables the production of a second superblock and directory tree which is suitable for reading by MS-Windows. The Joliet filenames are specified in 16-bit Unicode and each path component can be up to 64 Unicode characters long. Linux will use this tree if no Rock Ridge information is added to the main directory tree.
  • -r enables production of Rock Ridge information which records typical POSIX file properties like ownership, permissions, timestamps, file type, symbolic link target. Different from option -R it does not preserve the ownership as on hard disk, but rather sets owner UID to 0 and permissions to read-only and inspect-only for everybody. If Rock Ridge is present, then Linux will mount the main directory tree and use Rock Ridge to show long names with original characters.
  • -V sets the name of the ISO 9660 filesystem. It will be used as link name in directory /dev/disk/by-label when the written optical medium is inserted into a reader drive that is watched by udev. Use your own unique name instead of MY_DISK_LABEL.
  • -o sets the name of the resulting ISO 9660 image file. Use any suitable path instead of /home/user/file.iso.
  • The argument /home/user/for_iso is not part of any option. Thus it is used as path of an input file or directory which shall be copied into the ISO 9660 filesystem. If it is a directory then all files and directories underneath are copied, too.

More than one input path may be given. In this case it is best to use option -graft-points and pathspecs of the form target=source.

Remembering: in Debian-like systems mkisofs is just an alias to genisoimage and xorrisofs is an emulation of mkisofs.

BUT, there is a way to create an ISO using xorriso, not in emulation mode

Here we go, it's not so easy as the classic mkisofs style above, but it's worth the learning.

xorriso \
    -x \
    -rockridge on \
    -find / -exec mkisofs_r -- \
    -volid "CD_LABEL" \
    -for_backup \
    -joliet on \
    -compliance "iso_9660_level=3:deep_paths:long_paths:long_names" \
    -file_size_limit off -- \
    -outdev /home/user/file.iso \
    -blank as_needed \
    -map /home/user/for_iso /
  • -x: execute commands below in an order that makes sense, so you can write them in any order, xorriso will read in the right order. It's usefull if you use too many arguments and commands.
  • rockridge on: same as -r in mkisofs, enable Rock Ridge for POSIX semantics.
  • -find / -exec mkisofs_r --: it's a complement to rockridge on. Finds all files in the root folder of ISO image and apply the stats of mkisofs -r option (and "--" ends this command). User id and group id become 0, all r-permissions get granted, all w denied. If there is any x-permission, then all three x get granted. s- and t-bits get removed.
  • -volid "CD_LABEL" is the CD label, same as -V in mkisofs. But there is no shortcut, you must use -volid not -V.
  • -for_backup: shortcut for
    • -hardlinks on
    • -acl on
    • -xattr any
    • -md5 on
  • joliet on: same as -J in mkisofs. Generate Joliet directory records in addition to regular iso9660 file names.
  • -compliance "iso_9660_level=3:deep_paths:long_paths:long_names": compliance allow apply rules:
    • "iso_9660_level=3" ECMA-119 rules, length 32 and files larger than 400g
    • "deep_paths" allows ECMA-119 file paths deeper than 8 levels.
    • "long_paths" allows ECMA-119 file paths longer than 255 characters.
    • "long_names" allows up to 37 characters with ECMA-119 file names (yes, it changes level 3 from 32 to 37).
  • -file_size_limit off -- disables file size limit, any limit is possible. Superseed iso_9660_level=3 rules.
  • -outdev mut be provided, it the path to the file that will be created and it's name: /home/user/file.iso.
  • -blank as_needed: make media ready for writing from scratch (if not -dummy is activated). This affects only the -outdev. "as_needed" cares for used CD-RW, DVD-RW.
  • -map: the source folder or files and WHERE they should be saved in ISO. For example -map /home/user/Images /images will record the content of folder ./my/images in your machine to the folder "images" in the root of ISO image. You can add as many "-map" as needed. If you don't provide a destiny folder in ISO (can be just a "/") it will record to the ISO with the same path of your machine. So /home/user/Images will be saved as /home/user/Images inside ISO.

The really minimum should be:

xorriso -outdev /home/user/file.iso -map /home/user/for_iso /


OpenBSD doesn't come with mkisofs but with mkhybrid, which is based on mkisofs.
The basic command is similar:

mkhybrid -o output_image.iso directory_name

Options are similar either, some highlights:
-J - Joliet (for Windows)
-l - allow full 32 character filenames
-L - allow filenames to begin with a period
-R - Rock Ridge (for *nix)
-r - like the -R, but saner file ownership and modes
-V - volume label

mkisofs is available via installing cdrtools package: pkg_add cdrtools
xorriso is available via installing xorriso package: pkg_add xorriso

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .