LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   /bin/tar: Cannot utime: Read-only file system (https://www.linuxquestions.org/questions/linux-software-2/bin-tar-cannot-utime-read-only-file-system-697604/)

fukawi2 01-15-2009 04:57 PM

/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 :)

kenneho 01-16-2009 01:25 AM

I'd like to know the answer to this myself, so please post back when you find the solution. :)

colucix 01-16-2009 02:00 AM

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.

fukawi2 01-16-2009 02:19 AM

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 :)

colucix 01-16-2009 02:41 AM

Quote:

Originally Posted by fukawi2 (Post 3410775)
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.

aldesha989 01-16-2009 08:48 AM

try this

chmod 755 /bin/tar :$

colucix 01-16-2009 10:12 AM

Quote:

Originally Posted by aldesha989 (Post 3410882)
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.

Quigi 01-16-2009 01:29 PM

Quote:

Originally Posted by fukawi2 (Post 3410775)
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

fukawi2 01-16-2009 02:51 PM

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 :D

fukawi2 01-16-2009 02:52 PM

[SOLVED] /bin/tar: Cannot utime: Read-only file system
 
Whoops, forgot to mark as solved. Done now :)

colucix 01-16-2009 04:18 PM

Quote:

Originally Posted by fukawi2 (Post 3411286)
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 :D

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.


All times are GMT -5. The time now is 09:35 AM.