1

I built an ISO that contains, for example:

Directory listing of /
d---------   0    0    0            2048 Mar 19 2015 [     29 02]  .
d---------   0    0    0            2048 Mar 19 2015 [     29 02]  ..
d---------   0    0    0            4096 Mar 19 2015 [     32 02]  target-rpms
d---------   0    0    0            2048 Mar 19 2015 [     34 02]  vat
Directory listing of /target-rpms/
d---------   0    0    0            4096 Mar 19 2015 [     32 02]  .
d---------   0    0    0            2048 Mar 19 2015 [     29 02]  ..
----------   0    0    0        32435902 Mar 18 2015 [     85 00]  file1.rpm
----------   0    0    0         2055833 Mar 18 2015 [  15923 00]  file2.rpm
Directory listing of /vat/
d---------   0    0    0            2048 Mar 19 2015 [     44 02]  .
d---------   0    0    0            2048 Mar 19 2015 [     29 02]  ..
----------   0    0    0               0 Apr 20 2015 [  56633 00]  file1.txt

I would like to add/remove file from ISO mounted image, so I did:

  sudo mount -o loop,ro /full/path/to/file.iso /mounted/path

In order to add file I found this method:

mkdir /path/where/put/addedFile/vat/
cp prova.txt /path/where/put/addedFile/vat/prova.txt
mkisofs -o /tmp/test.iso -A test-1.0 -copyright 'Test' -joliet-long -RU
 -uid 0 -gid 0 -iso-level 4 /mounted/path /path/where/put/addedFile

that works, mkisofs merged file into directory and test.iso contains all desired files.

I need some help on how to create test.iso without, for example, target-rpms/file2.rpm.

I know that I can do it using this procedure:

mkdir /path/where/rebuildIso
cp -R /mounted/path /path/where/rebuildIso
rm /path/where/rebuildIso/target-rpms/file2.rpm
mkisofs -o /tmp/test.iso -A test-1.0 -copyright 'Test' -joliet-long -RU
 -uid 0 -gid 0 -iso-level 4 /path/where/rebuildIso

but, due to iso dimension, I would like to avoid cp command.

I'm using mkisofs 2.01 (i686-pc-linux-gnu) on Red Hat Enterprise Linux AS release 3 (Taroon Update 2)

2
  • Do you have the -m and/or -exclude option?
    – Lambert
    Apr 23 '15 at 13:13
  • mkisofs-2.01 is from 2004, do you really like to use such an outdated version today?
    – schily
    Jul 9 '18 at 12:08
2

In fact mkisofs 2.01 points to genisoimage:

$ mkisofs --version
mkisofs 2.01 is not what you see here. This line is only a fake for too clever
GUIs and other frontend applications. In fact, this program is:
genisoimage 1.1.11 (Linux)

From man genisoimage you can try the -m option:

-m glob
          Exclude files matching glob, a shell wildcard pattern, from being written to CD-ROM.  glob may match either the filename component or the full pathname.  This option may be used multiple times.  For example:

               genisoimage -o rom -m '*.o' -m core -m foobar

          would exclude all files ending in `.o', or called core or foobar from the image.  Note that if you had a directory called foobar, it too (and of course all its descendants) would be excluded.

   -exclude-list file
          A file containing a list of shell wildcards to be excluded.  See -m.
1
  • genisoimage in fact is a mkisofs from May 2004 with some Debian specific bugs added. Since mkisofs fixed dozens of bugs since then (in special bugs that caused structural bugs in the created filesystem image) and since mkisofs doubled it's features since then, it is not recommended to use that outdated and long dead genisoimage.
    – schily
    Nov 7 '18 at 21:50
-3

An easier to remember way is to use the built in find (via libfind) seen in mkisofs versions since 12 years. So in case you did update your OS installation since summer 2006, you could use e.g.:

mkisofs -o /tmp/test.iso -R -find  /mounted/path ! -name '*.rpm'  -chown root -chgrp root

If you like to merge more than one source path, add more paths directly past -find.

If you like to play with the destination path, check the -graft-points option that works with the built in find as well.

See man page at: http://schilytools.sourceforge.net/man/man8/mkisofs.8.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.