Oct 102011
 

Sometimes it happen to have the need of check what’s inside a .tar.gz file archive or perhaps you just need to extract a couple of files from another archive, this is possible you just have to remember all the flags or simply extract all in /tmp and then discard the files that you don’t need.

But there is also a smarter way to do this, use archivemount



What’s archivemount ? Quoting Wikipedia:

archivemount is a FUSE-based file system for Unix variants, including Linux. Its purpose is to mount archives (i.e. tar, tar.gz, etc.) to a mount point where it can be read from or written to as with any other file system. This makes accessing the contents of the archive, which may be compressed, transparent to other programs, without decompressing them.

This is exactly what we were searching to work on our archived files in a way totally transparent.

Installation

archivemount it’s available in most distribution, so install it using your distirbution package manager, on my Ubuntu 11.04 i’ve run from the terminal:

sudo aptitude install archivemount

Also add users that want to use it to the fuse group (and have them logout and login again if necessary), to do it use the command useradd from a terminal:

Syntax:
useradd -G {group-name} username

Example

sudo useradd -G fuse linuxaria

archivemount syntax

archivemount [-hVdfs] [-o options] archivepath mountpoint

There are many options for archivemount and in general for all fuse filesystems, but to start, just ignore them, so the basic syntax is just:
archivemount archivepath mountpoint

So you just need the complete path of your archive and a free directory where to mount the content of that archive.

EXAMPLE SESSION

Consider the gzipped tar archive “files.tgz” containing files “file1” and “file2”, and an empty directory “mnt”.

$ ls
files.tgz    mnt/

$ archivemount files.tgz mnt

$ ls mnt
file1    file2

[... Perform desired read/write operations on the archive via mnt/ ...]

$ umount mnt

[... Any changes are saved to the archive ...]

Because FUSE exposes its filesystems through the Linux kernel, you can use any application to load and save files directly into such mounted archives. This lets you use your favourite text editor, image viewer, or music player on files that are still inside an archive file. Going one step further, because archivemount also supports write access for some archive formats, you can edit a text file directly from inside an archive too.

Archive Formats

Archive format support is provided by the libarchive library. Read operations are supported for:

  • old-style tar archives,
  • most variants of the POSIX  ”ustar” format,
  • the POSIX  ”pax interchange” format,
  • GNU-format tar archives,
  • most common cpio archive formats,
  • ISO9660 CD images (with or without RockRidge extensions),
  • Zip archives.

Archives compressed with gzip, bzip2, or compress are automatically detected and transparently decompressed.

The following formats can be written:

  • POSIX-standard  ”ustar” archives,
  • POSIX  ”pax interchange format” archives,
  • POSIX octet-oriented cpio archives,
  • two different variants of shar archives.

Before writing, the original archive is renamed with a  ”.orig” extension appended to it. More detail about the read/write support can be found in the libarchive documentation.

Popular Posts:

flattr this!

 Leave a Reply

(required)

(required)


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>