Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

So in this scenario:

I create tar.gz file. with very important files.

Before I power down computer, electricity goes out.

is it safe to files written in tar file will not get corrupted?

is it ok to check just tar file for integrity and not individual files?

How can I check tar.gz file integrity?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

Yes, this is definitely possible.

Because hard disks are exceptionally slow compared to the rest of your computer, there is virtually always a delay between when a piece of software is told a write to a file is finished and that file actually gets physically written to the hard disk. This keeps slow disks from making it difficult to keep using the computer. But until this write finishes, the data may only exist in your computer's RAM.

There are mechanisms applications can use to ensure data has been written out to disk, but there is a significant performance cost to using them, so a low-level application like tar will not use them and rely on a higher-level tool to ensure data integrity.

Since tar is not doing this for you, you can ensure that any pending writes have been flushed out to disk using the sync command. Once that command returns, you can be sure that any disk writes that happened before running sync have been successfully written to the hard disk.

Additionally, if you cleanly shut down your system, one of the last things that happens is that any pending writes are synced out. So in the case of power loss, data may not have been written out to the disk, but in the case of a clean shut down, everything should be.

share|improve this answer
    
It's also possible that data that were already written may be damaged when power is suddenly cut--the hard disk's read/write head could nick the disk and damage any data. And it's also possible, though considerably less likely, that the data became corrupted, but not due to the loss of power; magnetic storage is not 100% reliable, though as implemented in modern hard disks it's considerably more reliable than other forms of store like optical media. –  Eliah Kagan Nov 14 '11 at 23:10
    
@EliahKagan Although a well-constructed hard disk should minimize that sort of thing. –  AJMansfield Jan 23 '13 at 21:43

To check integrity of tar.gz files: Check tar.gz. I guess that if the tar.gz file is ok, files inside it are ok aswell.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.