51

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.

Rui F Ribeiro
  • 55,929
  • 26
  • 146
  • 227
klingt.net
  • 1,615
  • 4
  • 17
  • 21

3 Answers3

80

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

Joseph R.
  • 38,849
  • 7
  • 107
  • 143
  • 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. Sep 15 '13 at 19:46
  • 3
    under unix `apropros` is a synonym for `man -k`. The latter being a little easier to remember/spell ;) – Drav Sloan Sep 15 '13 at 21:37
  • 13
    `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 May 31 '16 at 13:16
  • @schily At least for Debian, [`mkisofs` isn't an option; only `genisoimage` and `xorrisofs` are, ideally the latter](https://wiki.debian.org/genisoimage). – Michael A Nov 27 '19 at 21:45
  • 1
    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 Nov 28 '19 at 11:43
  • `OSS-hostile distro like Debian` what? I thought debian boasts itself in only providing Free Software in its repos. – xeruf Apr 17 '23 at 14:34
36

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

Chad Skeeters
  • 528
  • 4
  • 8
  • 2
    The Linux man page you mention is at least 15 years old and completely outdated since `mkisofs` more than doubled its features since then. The recent man page is here: http://schilytools.sourceforge.net/man/man8/mkisofs.8.html – schily Nov 28 '19 at 13:05
13

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
Jason Swartz
  • 156
  • 1
  • 3