9

I have a Linux TAR file that I would like to convert directly into an ISO. Is there a way to do this, preferably, without having to extract the contents of the file first?

This would be similar to the following question; however, this is focused on plain or straight-up tar files and not related to bzip or a bzipped tar.

This is also something that I intended to use within a script and the reason that I do not want to extract it first.

John
  • 2,266
  • 6
  • 44
  • 60
  • Theoretically it could be done without having to extract each of the files *to disk* (they have to be extracted from the archive in order to be put into the new image), but I don't know of anything that does. – Ignacio Vazquez-Abrams Sep 29 '11 at 20:20
  • Why do you want to do this without extracting the tar? – Nils Sep 29 '11 at 20:23
  • I wonder if there is a way to pipe it to something like stdin and then pipe it on over to the iso file ??? – John Sep 29 '11 at 20:23
  • I am not sure if this would work or not, since I am not 100% for sure what the command is doing. -- tar -jxf /dev/stdin file.tar | mkisofs -o file.iso -stream-media-size 512 – John Sep 29 '11 at 20:39
  • The -stream-media-size option was actually made for this! :-) See [the genisoimage man page](http://linux.die.net/man/1/genisoimage) for info -- currently it mentions tar in the docs for this option (and uses it in the examples for it). – Abbafei Dec 28 '12 at 06:08

4 Answers4

6

Use AVFS to access the contents of the tar archive as if it was a directory. AVFS is a virtual filesystem built on FUSE. Point your favorite ISO builder to the directory inside the tar archive.

mountavfs
cd ~/.avfs/path/to/archive.tar\#
genisoimage -o /path/to/iso .
  • @ Gilles - thanks for the idea. This looks like it might be an excellent idea; however, I am on CentOS 6 and am running into problems trying to get AVFS installed. – John Sep 29 '11 at 22:03
2

If your primary objectives are to expedite the process and to avoid unnecessary disk activity for performance reasons, and you have plenty of RAM to spare relative to the size of your tarball, you can extract the .tar into RAM using tmpfs. This option is very likely the fastest available, unless you're able to get @bulleric's pipe approach to work and you're reading from one disk and writing to another.

Skyhawk
  • 14,149
  • 3
  • 52
  • 95
2
archivemount /file.tar /media/ISO

or uncompressed .tar and

genisoimage -o myfile.iso directory_src

(can be folder /media/ISO or point mount /media/cdrom)

techraf
  • 4,163
  • 8
  • 27
  • 44
eternoi
  • 21
  • 1
-2

You must extract it but you dont must extract it to your harddrive you can use stdtout and pipe it to genisoimage or mkisofs

tar --to-stdout xf tareddata.tar | genisoimage -o image.iso tareddata

test it: mount -o loop image.iso /mnt

you can write a small script to automize this issue

greez bull

bulleric
  • 239
  • 1
  • 2
  • 8
  • And how would it tell one file from the next? – Ignacio Vazquez-Abrams Sep 29 '11 at 21:02
  • When I run this I get a series of errors, the first is: tar: You must specify one of the `-Acdtrux' or `--test-label' options. The next error is: I: -input-charset not specified, using utf-8 (detected in locale settings). The last error is: genisoimage: No such file or directory. Invalid node - 'tareddata'. – John Sep 29 '11 at 21:09
  • the first problem i solvet i have take a wrong option in tar ; the 2nd one hmm in my opinion the first directory get extractet the same name as the as the unextracted directory like tardata.tar tardata – bulleric Sep 29 '11 at 21:15
  • Sorry, I'm fairly sure there's no way this can work; -1 . – MadHatter Sep 30 '11 at 09:00