LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 01-15-2009, 04:57 PM   #1
fukawi2
Member
 
Registered: Oct 2006
Location: Melbourne, Australia
Distribution: ArchLinux, ArchServer, Fedora, CentOS
Posts: 448

Rep: Reputation: 34
/bin/tar: Cannot utime: Read-only file system


While doing a tar backup on my servers, I get this error:
Code:
/bin/tar: /usr/local/bin/sendEmail: Cannot utime: Read-only file system
The error happens on all files in /usr that I'm trying to backup. I know why the error is happening -- I deliberately mount /usr as read-only.

I'd like to know why tar is trying to "utime" my files and how I can stop that behaviour if possible?

This is my tar command:
Code:
tar cjf /mnt/backup/backup.tar.bz2 --label='backup_090116' --atime-preserve --no-wildcards-match-slash --files-from=/root/backup.include --exclude-from=/root/backup.exclude
TIA
 
Old 01-16-2009, 01:25 AM   #2
kenneho
Member
 
Registered: May 2003
Location: Oslo, Norway
Distribution: Ubuntu, Red Hat Enterprise Linux
Posts: 655

Rep: Reputation: 40
I'd like to know the answer to this myself, so please post back when you find the solution.
 
Old 01-16-2009, 02:00 AM   #3
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,458

Rep: Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941
The --atime-preserve defaults to --atime-preserve=replace, so that tar just remembers the previous access time and restore it after reading files. In this case the utime system call is attempted to change the access time of the inode. You can try the option --atime-preserve=system to avoid changes of the access time, but there are some caveats. Here an excerpt from the tar manual:
Quote:
‘--atime-preserve=system’ avoids changing time stamps on files, without interfering with time stamp updates caused by other programs, so it works better with incremental backups. However, it requires a special O_NOATIME option from the underlying operating and file system implementation, and it also requires that searching directories does not update their access times. As of this writing (November 2005) this works only with Linux, and only with Linux kernels 2.6.8 and later. Worse, there is currently no reliable way to know whether this feature actually works. Sometimes tar knows that it does not work, and if you use ‘--atime-preserve=system’ then tar complains and exits right away. But other times tar might think that the option works when it actually does not.

Currently ‘--atime-preserve’ with no operand defaults to ‘--atime-preserve=replace’, but this may change in the future as support for ‘--atime-preserve=system’ improves.

If your operating system does not support ‘--atime-preserve=system’, you might be able to preserve access times reliably by by using the mount command. For example, you can mount the file system read-only, or access the file system via a read-only loopback mount, or use the ‘noatime’ mount option available on some systems. However, mounting typically requires superuser privileges and can be a pain to manage.
You can give it a try and see if it works. Otherwise, since you have root's privileges you can always temporarily change the mount options and restore them when the job is done. Hope this helps.
 
Old 01-16-2009, 02:19 AM   #4
fukawi2
Member
 
Registered: Oct 2006
Location: Melbourne, Australia
Distribution: ArchLinux, ArchServer, Fedora, CentOS
Posts: 448

Original Poster
Rep: Reputation: 34
Thansk for the answer colucix -- very comphrehensive

I've changed my script (Kernel 2.6.27 so I should be right) and see how it goes tonight. Otherwise I'll remove the option completely - I'm not that fussed about keeping the atime, so if it's going to cause errors, I'll leave it out

Will report back after the next backup has run
 
Old 01-16-2009, 02:41 AM   #5
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,458

Rep: Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941
Quote:
Originally Posted by fukawi2 View Post
Otherwise I'll remove the option completely - I'm not that fussed about keeping the atime, so if it's going to cause errors, I'll leave it out
Well, the default behavior is to change the access time of the inode, since it is actually accessed by some program (tar). The --atime-preserve option of tar should tweak the way tar manages the access time.

--atime-preserve=replace (default) simply restores the previous access time, --atime-preserve=system does not change the access time at all. So if you leave it without the --atime-preserve option, the access time will be actually updated and most likely you will get the same error.

I suggest to do a test in real time (without waiting for the scheduled job execution) and see if the suggested option works. Otherwise we should re-think the entire issue to find a workaround.
 
Old 01-16-2009, 08:48 AM   #6
aldesha989
LQ Newbie
 
Registered: Oct 2008
Posts: 13

Rep: Reputation: 0
try this

chmod 755 /bin/tar :$
 
Old 01-16-2009, 10:12 AM   #7
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,458

Rep: Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941
Quote:
Originally Posted by aldesha989 View Post
try this

chmod 755 /bin/tar :$
aldesha989, can you elaborate why this should affect the behavior of tar against a read-only system? To me, since the tar command has been executed, it had the proper permissions.
 
Old 01-16-2009, 01:29 PM   #8
Quigi
Member
 
Registered: Mar 2003
Location: Cambridge, MA, USA
Distribution: Ubuntu (Dapper and Heron)
Posts: 377

Rep: Reputation: 31
Quote:
Originally Posted by fukawi2 View Post
I've changed my script (Kernel 2.6.27 so I should be right) and see how it goes tonight. Otherwise I'll remove the option completely - I'm not that fussed about keeping the atime, so if it's going to cause errors, I'll leave it out
Removing the --atime-preserve option is the first thing I'd try.

As the file system is mounted read-only, nothing should be able to change any content or attribute. Specifically, tar's reading shouldn't change atime. Hence no need to "utime" it back to what it was before.

/Quigi

Last edited by Quigi; 01-16-2009 at 01:30 PM. Reason: Clarify "anything" -> "any content or attribute"
 
Old 01-16-2009, 02:51 PM   #9
fukawi2
Member
 
Registered: Oct 2006
Location: Melbourne, Australia
Distribution: ArchLinux, ArchServer, Fedora, CentOS
Posts: 448

Original Poster
Rep: Reputation: 34
Changing --atime-preserve to --atime-preserve=system has solved the problem. I wanted to avoid removing it totally if possible because there's other path's not in /usr that aren't read-only.

Adding =system has solved the problem.

Thank-you very much colucix
 
Old 01-16-2009, 02:52 PM   #10
fukawi2
Member
 
Registered: Oct 2006
Location: Melbourne, Australia
Distribution: ArchLinux, ArchServer, Fedora, CentOS
Posts: 448

Original Poster
Rep: Reputation: 34
[SOLVED] /bin/tar: Cannot utime: Read-only file system

Whoops, forgot to mark as solved. Done now
 
Old 01-16-2009, 04:18 PM   #11
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,458

Rep: Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941
Quote:
Originally Posted by fukawi2 View Post
Changing --atime-preserve to --atime-preserve=system has solved the problem. I wanted to avoid removing it totally if possible because there's other path's not in /usr that aren't read-only.

Adding =system has solved the problem.

Thank-you very much colucix
You're welcome! As stated by the developers it will be the default behavior for the --atime-preserve option, as soon as they resolve the interoperability among different systems.
 
  


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
unpack .tar.gz2 (Cannot utime .... ERROR) ibex Linux - General 2 04-15-2006 11:24 PM
'Read-only file system' when untar a tar.bz2 file yinglcs Linux - General 1 02-18-2006 09:12 PM
/bin/tar: cannot execute binary file dhammika Linux - General 8 11-08-2005 04:17 PM
I need to know the command on how to install tar.bin file lakbay_taodev Linux - Software 9 10-19-2004 06:46 PM
tar problem "Cannor utime: Operation not Permitted' l32 Linux - Newbie 1 06-28-2004 05:18 PM


All times are GMT -5. The time now is 11:40 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration