LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-03-2006, 05:53 AM   #1
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,661

Rep: Reputation: 54
mounting a tarball to read its content


Hi folks,

I forget the command line mounting a tarball to read its content without decompressing it.

# mount tarball.tar.bz2 -o loop /mnt/point

did not work. Having searched around on Internet and could not find the command.

Please advice.

TIA

BR
satimis
 
Old 02-03-2006, 07:05 AM   #2
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,397
Blog Entries: 1

Rep: Reputation: 64
uh ? I think mounting a tar ball is not possible.
Instead you can shows the contents by "tar -tjvf tarball.tar.bz2" and extracting by "tar -xjvf tarball.tar.bz2".

AFAIK, you can mount only filesystems and a tar bziped file is not a filesystem.

I hope I am right :-)
 
Old 02-03-2006, 07:50 AM   #3
british_76
Member
 
Registered: Dec 2003
Distribution: kubuntu breezy badger
Posts: 30

Rep: Reputation: 15
Quote:
Originally Posted by marozsas

AFAIK, you can mount only filesystems and a tar bziped file is not a filesystem.

I hope I am right :-)
afaIk, you can also mount files containing file-systems ..

.... quite usefull: mount -o loop -t iso9660 file.iso /mnt/test

..... just for telling the world, that i'm sooooooo clever
 
Old 02-03-2006, 08:22 AM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 15,266

Rep: Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624Reputation: 1624
You can list the contents of the archive without decompressing. See man pages for details.
 
Old 02-03-2006, 08:34 AM   #5
pokemaster
Member
 
Registered: Apr 2005
Location: Massachusetts, USA
Distribution: debian,ubuntu,slackware
Posts: 110

Rep: Reputation: 17
if you'd like to look at the files, double click it from within the gui -- then you can extract individual files you'd like to look at. Otherwise, you're stuck with the above suggestions, i.e. using the -t option will list the files, and using the -x option and placing an extra argument with the name of a file will extract only the one you want. michaelk had it right on, the man pages are great (man tar if you're unfamiliar)
 
Old 02-03-2006, 10:06 AM   #6
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,661

Original Poster
Rep: Reputation: 54
Hi michaelk and pokemaster,

Tks for your advice.

Most times I double-click the tarball on Konqueror to decompress it. For such a reason I already forgot the command learned at the beginning to read its content without decompressing the tarball. I read 'man tar' but could not figure out a solution. What I want to do is similar to the steps working on a gunzip file as follows;

# gzip -dc initrd.gz >initrd.img
# mkdir initrd

# mount -o loop initrd.img initrd
# nano /initrd/files (to edit the file/files)

to recompress it after editing
# gzip --best initrd.img initrd.gz

I expect to do it on the tarball. Is it possible? If YES, any hint? TIA

B.R.
satimis
 
Old 02-03-2006, 10:11 AM   #7
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,661

Original Poster
Rep: Reputation: 54
Hi marozsas,

Quote:
Instead you can shows the contents by "tar -tjvf tarball.tar.bz2" and extracting by "tar -xjvf tarball.tar.bz2".
Noted with tks.

satimis
 
Old 02-03-2006, 10:22 AM   #8
pokemaster
Member
 
Registered: Apr 2005
Location: Massachusetts, USA
Distribution: debian,ubuntu,slackware
Posts: 110

Rep: Reputation: 17
Hmm... in the gzip commands you're using, the mounting is not a property of gunzip (or of tar for that matter). It's a property of the initrd image (keyword here, image). An initrd is a memory image the computer can load at boot to get some extra modules before the kernel gets up and running (i.e.... hard drive helps, if it's not compiled into the kernel), so all you're doing is mounting this image to a folder. But you're decompressing the whole thing, which can be achieved with a tarball by
Code:
mkdir temp
cd temp
tar -xzvf ../tarballname.tar.gz
Now you can edit files to your heart's content, then when you're done, from the dir with the tarball,
Code:
mv tarballname.tar.gz tarballname.tar.gz.bak
tar -czf tarballname.tar.gz temp/*
And it'll be re-tarred and compressed.... AFAIK you can't at all read / edit without decompressing first... it would rather defeat the purpose of decompressing at all?
 
Old 02-03-2006, 11:18 PM   #9
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,661

Original Poster
Rep: Reputation: 54
Hi pokemaster,

Can edited files be recompressed to the original tarball overwriting the old files? If YES then the files can be copied without decompressing the tarball with -t option.

BR
satimis
 
Old 02-04-2006, 07:18 AM   #10
pokemaster
Member
 
Registered: Apr 2005
Location: Massachusetts, USA
Distribution: debian,ubuntu,slackware
Posts: 110

Rep: Reputation: 17
well, it's a nice thought... you can do it with an uncompressed tar, but once you have a compressed tar, adding individual files is not possible without decompressing / recompressing the entire archive.

You could just decompress it, leave it as a tar, extract one file, edit it and put it back in (use the u option (tar -u tarball.tar file)), Then recompress when you're done...

There may be some little tricks I don't know about (certainly wouldn't be the first time), but AFAIK, the update file and append file options don't work with compression.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ file I/O, read content as int value Artanicus Programming 7 12-18-2005 02:31 PM
How do i read the content of a CD? therealkilkenny Linux - Newbie 6 12-09-2005 10:43 AM
Read KDE clipboard content neranjana Linux - General 3 05-10-2005 01:12 PM
Apache serving content after the content is removed? jrbush82 Linux - Software 6 05-05-2004 05:39 AM
A Good Read... good content on this machine Banshee Linux - Newbie 0 08-06-2002 01:15 AM


All times are GMT -5. The time now is 06:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration