Specifying tmp for tar

Rick Stevens rstevens at internap.com
Fri Aug 31 21:35:36 UTC 2007


On Fri, 2007-08-31 at 14:13 -0700, Rick Stevens wrote:
> On Fri, 2007-08-31 at 23:53 +0300, Dotan Cohen wrote:
> > On 31/08/2007, Rick Stevens <rstevens at internap.com> wrote:
> > > On Fri, 2007-08-31 at 23:18 +0300, Dotan Cohen wrote:
> > > > I have a 2 GB bz2 archive that unzips to over 10 GB (wikipedia dump).
> > > > Although I have over 50 GB free in /home, / has only about 8 GB free.
> > > > Thus, as tar uses /tmp, the / filesystem fills up and I cannot
> > > > continue. How can I specify a tmp directory for tar in my home
> > > > directory? Note that man tar makes no mention of a tmp option.
> > >
> > > Boot in single user mode,  Then as root:
> > >
> > >         # mkdir /home/tmp
> > >         # chmod 777 /home/tmp
> > >         # mv /tmp /tmp-old
> > >         # ln -s /home/tmp /tmp
> > >         # cp -a /tmp-old/* /tmp
> > >
> > > That creates a /home/tmp directory, allows everyone access, renames the
> > > old /tmp to /tmp-old, symlinks /home/tmp to /tmp, then copies everything
> > > that was in the old /tmp to the new one.  Once that's done, you can
> > > reboot and all references to /tmp will now access /home/tmp.
> > 
> > Thanks, Rick, I'll try that. I can then simply erase the symlink? I
> > know that "rm /tmp" will not erase the symlink, rather the content of
> > /home/tmp so how can I remove it afterwards? Thanks.
> 
> No, "rm /tmp" will remove the symlink.  If you want to revert to the
> original /tmp, reboot in single user mode again and as root:
> 
> 	# cp -a /tmp/* /tmp-old
> 	# rm -f /tmp
> 	# mv /tmp-old /tmp
> 
> which will copy any changes from /home/tmp (/tmp) to the original /tmp
> directory, then deletes the symlink and renames /tmp-old to /tmp.

I should have added that you could then "rm -rf /home/tmp" to recover
the space used on /home for the temporary "tmp" directory.  That would
be after the "mv" command above.

> > Also, as a learning experience, is there a way a user without root
> > access could unpack the tar? It's not a problem, but I'd like to
> > learn. Thanks.
> 
> If you were doing
> 
> 	bunzip2 name-of-tar.bz2
> 	tar xf name-of-tar
> 
> or even
> 
> 	bzcat name-of-tar.bz2 | tar xf -
> 
> then you're going to use /tmp.  Do it all in one command:
> 
> 	tar xJf name-of-tar.bz2
> 
> to unzip and untar the thing.  Should do it all in the current
> directory.

----------------------------------------------------------------------
- Rick Stevens, Principal Engineer             rstevens at internap.com -
- CDN Systems, Internap, Inc.                http://www.internap.com -
-                                                                    -
-  BASIC is the Computer Science version of `Scientific Creationism' -
----------------------------------------------------------------------




More information about the users mailing list