LinuxQuestions.org
Review your favorite Linux distribution.
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 06-10-2009, 02:56 PM   #1
KenShelby
LQ Newbie
 
Registered: Oct 2008
Location: Somers, New York, USA
Distribution: Red Hat
Posts: 12

Rep: Reputation: 0
How can I force tar to over-write busy files?


I'd like to just blast a tar archive's files down onto a (RHEL 3 update 8) machine and ignore all "text file busy" errors that would prevent writing a file. How can I do that, please?
 
Old 06-10-2009, 03:29 PM   #2
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 164Reputation: 164
Quote:
Originally Posted by KenShelby View Post
I'd like to just blast a tar archive's files down onto a (RHEL 3 update 8) machine and ignore all "text file busy" errors that would prevent writing a file. How can I do that, please?
The easiest method is boot into single user mode or alternate shutdown pretty much everything so the files aren't in use.

The alternative is extract it elsewhere and then mv -f or rsync it into place... but that's delving into scary territory. You might want to make sure your basic tools are statically linked before doing that.
 
Old 06-10-2009, 04:45 PM   #3
KenShelby
LQ Newbie
 
Registered: Oct 2008
Location: Somers, New York, USA
Distribution: Red Hat
Posts: 12

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by rweaver View Post
The easiest method is boot into single user mode or alternate shutdown pretty much everything so the files aren't in use.

The alternative is extract it elsewhere and then mv -f or rsync it into place... but that's delving into scary territory. You might want to make sure your basic tools are statically linked before doing that.
Thanks very much for the rapid reply!

I've already tried bringing the machine down into single-user mode: no joy.

I have no need whatever for the files that currently exist on the target machine, so it's not really all that scary. I need to somehow get tar to simply extract ALL the files. Is there any way to avoid those "text file busy" errors and just write, regardless?
 
Old 06-10-2009, 09:03 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,241

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
Which files are causing a problem?
If(!) they are still in use in single user mode, makes them pretty vital...
You could try using a rescue mode CD/DVD, that way (almost?) no files on the hdd are open when you mount it.
 
Old 06-11-2009, 10:31 AM   #5
KenShelby
LQ Newbie
 
Registered: Oct 2008
Location: Somers, New York, USA
Distribution: Red Hat
Posts: 12

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by chrism01 View Post
Which files are causing a problem?
If(!) they are still in use in single user mode, makes them pretty vital...
You could try using a rescue mode CD/DVD, that way (almost?) no files on the hdd are open when you mount it.
Thanks for the input!

But I have *absolutely* no need to preserve the files that are currently on the target machine. And the target box has no CD/DVD drive, so I'm getting my tar archives there via ftp.

The simplest solution would be to force tar to over-write ALL the files and ignore the "text file busy" errors. Is there no way to do this?
 
Old 06-12-2009, 11:56 AM   #6
KenShelby
LQ Newbie
 
Registered: Oct 2008
Location: Somers, New York, USA
Distribution: Red Hat
Posts: 12

Original Poster
Rep: Reputation: 0
This is a snippet of the Korn script I'm now testing, for each of the tar archives I have...


"...
tar --extract --verbose --overwrite --same-owner --preserve-permissions \
--gunzip --file ${LocalDir}/${Tarfile} 1>>${LocalDir}/update.log 2>>${LocalDir}/tar-errors.txt
ReturnStatus="$?"
if [[ "$ReturnStatus" != "0" ]] ; then
grep -i 'file busy' ${LocalDir}/tar-errors.txt |\
awk '{print $2}' | \
tr ':' ' ' | \
awk '{print $1}' | \
while read BusyFile
do
if [[ ! -z "$BusyFile" ]] ; then
echo "Extracting with unlink: $BusyFile" >>${LocalDir}/update.log
tar --extract --verbose --unlink-first --same-owner --preserve-permissions \
--gunzip --file ${LocalDir}/${Tarfile} ${BusyFile} 1>>${LocalDir}/update.log
fi
done
fi
sync
..."
 
Old 06-15-2009, 10:49 AM   #7
KenShelby
LQ Newbie
 
Registered: Oct 2008
Location: Somers, New York, USA
Distribution: Red Hat
Posts: 12

Original Poster
Rep: Reputation: 0
Well, that was a bad idea. Using the "--unlink-first" switch of tar only got me into more trouble when it ran into a place with softlinks pointing at real files that were busy, for example, in the "/lib/tls" directory. Dropping the files into a temporary area and using a forced move ("mv -f") failed, too.

Is there no-one out there in Linuxquestionsland who knows how I can simply over-write every single file on a machine with files from a tar archive?
 
Old 06-15-2009, 01:41 PM   #8
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 164Reputation: 164
Quote:
Originally Posted by KenShelby View Post
Well, that was a bad idea. Using the "--unlink-first" switch of tar only got me into more trouble when it ran into a place with softlinks pointing at real files that were busy, for example, in the "/lib/tls" directory. Dropping the files into a temporary area and using a forced move ("mv -f") failed, too.

Is there no-one out there in Linuxquestionsland who knows how I can simply over-write every single file on a machine with files from a tar archive?
I've never done it with tar (forced overwrite) but if a mv -f fails... you've got something else going on you need to look into.

I doubt this will work if mv -f didn't but try untaring them somewhere else and rsyncing them over the current system.
 
Old 06-15-2009, 09:47 PM   #9
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,241

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
You still haven't told us which files these are. Just because you don't think you need to worry, doesn't mean the system agrees.
If they're busy, it means they are open and being used. You need to shutdown the relevant process first, then untar.
 
Old 06-16-2009, 02:10 PM   #10
KenShelby
LQ Newbie
 
Registered: Oct 2008
Location: Somers, New York, USA
Distribution: Red Hat
Posts: 12

Original Poster
Rep: Reputation: 0
Thanks once more for the input, but I really do not care at all about the files that are on the machine currently. As I said at the top, all I want to do is "...blast a tar archive's files down onto a machine..."

Is there really no way to do this?
 
Old 06-16-2009, 03:45 PM   #11
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 164Reputation: 164
Quote:
Originally Posted by KenShelby View Post
Is there really no way to do this?
I've rsync'd over live machines in the past... you just need to exclude certain 'special' items, like /dev, /proc, etc. You can't do a force overwrite on some locations.

If mv -f is failing, please tell us what file you're attempting to overwrite that is failing and we might be able to tell you why, at this point we can't help you any further without additional information.
 
Old 06-17-2009, 10:41 AM   #12
KenShelby
LQ Newbie
 
Registered: Oct 2008
Location: Somers, New York, USA
Distribution: Red Hat
Posts: 12

Original Poster
Rep: Reputation: 0
Thanks, one and all, for your replies.

I'm going to try a different approach (in a new thread) to my basic problem, which is installing a new O/S and applications on a machine that has no CD/DVD or floppy and cannot boot from USB.
 
Old 06-17-2009, 07:36 PM   #13
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,241

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
If you're using RH, kickstart has a netboot (bootp ?) option
 
  


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
Force Check done ever time. Unmount won't work on "Busy device"... R4ndom Linux - Newbie 1 04-21-2009 01:52 PM
How to force write cache mode on aacraid? pofcorn Linux - Hardware 1 03-21-2007 09:19 AM
vi changing owner and group on a force write fukawi2 Linux - Security 8 10-12-2006 06:59 PM
how can i force unmount a busy CD drive mailavj Linux - Software 1 04-04-2005 07:21 PM
How can i force unload a module that is busy Doomhammer Linux - Software 1 03-23-2005 02:25 PM


All times are GMT -5. The time now is 06:26 PM.

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