Forum Topic - compressing directories using tar/gzip: (6 Items)
   
compressing directories using tar/gzip  
Hi,

I'm trying to perform a reasonably simple task of compressing a given directory (and all its subdirectories and files) 
into a archive for updating/rollback purposes.  To test this I'm simply trying to back-up the /etc directory to the /tmp
 directory.

I'm using the following command line:

   # tar -cvfz /tmp/etc.tar.gz /etc

With the following response:
   tar: Removing leading `/' from member names
   tar: /tmp/etc.tar.gz: Cannot stat: No such file or directory
   tar: /etc/: Cannot savedir: Function not implemented
   tar: Error exit delayed from previous errors
   # Cannot savedir: Function not implemented

Am I doing something wrong or isn't compression implemented on the ARM platform? My target is an i.MX31 ADS.  I can see 
that the file /tmp/etc.tar.gz is created (but only 20 bytes in size).

If I specify a single file then it works, however I need to compress an entire directory (recursively).

Regards,
Radek.
Re: compressing directories using tar/gzip  
Hi Radek,

first, give the command line options to 'tar' in the correct order. 
'-c', '-v', and '-z' are boolean options, and as such may appear in any order. '-f', though, is an option taking an 
argument -the output file name-, which must appear right after the 'f' (give or take a space or two). So please see what
 happens when you do
  # tar -czvf /tmp/etc.tar.gz /etc

You should still see
   tar: Removing leading `/' from member names
..that's pefectly ok.

You should no longer see
   tar: /tmp/etc.tar.gz: Cannot stat: No such file or directory

I'm not quite sure about the
   tar: /etc/: Cannot savedir: Function not implemented
   Cannot savedir: Function not implemented
messages - I wasn't able to reproduce those. Is your /etc directory special in any way? Maybe just some files inlined 
into your boot image?

Please try running tar on some other directory - one that really exists in your file system, and let me know.

Kind regards,
- Thomas
Re: compressing directories using tar/gzip  
I usually use the command:

tar -cv [list of files or directories] | gzip > <tar_filename>.tgz

I am not sure that "tar" will automatically perform the "gzip" compression, so if you want to create a .gz or .tgz file,
 you will need to manually invoke "gzip".

- Ed
RE: compressing directories using tar/gzip  
Yes, it does. That's what the -z option is for.


Steve Reid (stever@qnx.com)
Technical Editor
QNX Software Systems 
 

> -----Original Message-----
> From: Edward Lee [mailto:community-noreply@qnx.com] 
> Sent: Monday, August 24, 2009 9:10 AM
> To: momentics-community
> Subject: Re: compressing directories using tar/gzip
> 
> I usually use the command:
> 
> tar -cv [list of files or directories] | gzip > <tar_filename>.tgz
> 
> I am not sure that "tar" will automatically perform the 
> "gzip" compression, so if you want to create a .gz or .tgz 
> file, you will need to manually invoke "gzip".
> 
> - Ed
> 
> 
> 
> _______________________________________________
> 
> QNX Momentics Community Support
> http://community.qnx.com/sf/go/post36502
> 
> 
Re: RE: compressing directories using tar/gzip  
Okay with all the helpful hints I have managed to get it to work.  

In the end I think its because the /tmp directory does not allow directories to be created under it (RAM temporary 
directory) therefore it appears the tarring operations cannot complete successfully as they may require this feature. 
Changing the current working path to a writable media (such as /fs/usb0 or /fs/etfs) which can have sub-directories 
created works successfully.

e.g.
   cd /fs/usb0        
        (the current working directory must be on a device which supports mkdir)
   tar -czvf /tmp/test.tar.gz /etc 
        (then compressing to /tmp still works)

Cheers,
Radek.
Re: RE: compressing directories using tar/gzip  
... a slight correction/addition to the last post, I couldn't compress the /etc directory since as per Thomas' comment 
it is a little special in that it is part of the boot image.  That's fine however, as I will not need to compress any of
 the boot image files and rather only packages installed on the etfs file system.

Radek.