How to Solve Zero Length File Problem in Linux’s Ext4 File System
By Tom Patrick
The ext4 (fourth extended) is a journaled file system of Linux that has many benefits compared to its predecessors, such as support for backward compatibility, large file system, delayed allocation, etc. However, the delayed allocation feature sometimes poses problems for the Linux system. The Linux system based on ext4 file system may encounter inconsistencies in the files in case of a power surge. To overcome this behavior, you should take appropriate corrective measures. However, if no method employed by you is successful then you should use a third-party Linux recovery software to do the needful.
Consider a scenario wherein you are working on a Linux system. Suddenly, there is a power loss and the system shuts down abruptly. When the power is restored, you switch on the system and find that the files that you created just before the crash are showing zero bytes.
Cause:
The most possible cause for such behavior is the delayed allocation feature. What happens is when a file is closed after creation, the data blocks are allocated for the file after a minute or so. Because of this, the metadata of the modified file will show zero bytes as its size. The data allocation is done after the delayed allocation is over. Hence, in the case of a power surge the new file is considered as an empty file.
Resolution:
To resolve the issue, you can use the following methods:
Mounting the file system using “data write-back”
Using three patches designed for ext4 file system: The three patches (bf1b69c0, f32b730a, and 8411e347) enforce any file with delayed allocation will be allocated immediately when a file is created.
Mount the ext4 file system with the nodealloc mount option
Mount the system with the data=alloc-on-commit option: This would ensure that all blocks that had delayed allocation would be allocated and moved to disk before a commit takes place.
However, if you still are not able to recover the lost files then you should use a third-party Linux recovery software to perform data recovery for Linux system. Such read-only tools are able to recover lost data without overwriting the original data.
Tom Patrick is a magazine editor currently researching on linux recovery
Save a big deal on real exam with testking 650-393 course. Join testking 70-685 online training program and get certified testking 642-681 products to prepare and pass real exam on first try.





4 Comments to 'How to Solve Zero Length File Problem in Linux’s Ext4 File System'
May 10, 2010
The Incutio XML-RPC PHP Library -- WordPress/2.9.2
[...] How to Solve Zero Length File Problem in Linux’s Ext4 File System [...]
May 11, 2010
Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/533.2 (KHTML, like Gecko) Chrome/5.0.342.9 Safari/533.2
Just use journal_data if this is a problem. tune2fs -o journal_data as of yet it doesn’t support delayed allocation. Benchmarks of ext3 showed it faster at reads than ordered or writeback. I’m not sure ’bout ext4.
May 11, 2010
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.3) Gecko/20100401 SUSE/3.6.3-1.2 Firefox/3.6.3
Thanks for pointing out this mount option.
Is that file count scale on the graph correct? Looks like a graph bug.
May 11, 2010
SOAP::Lite/Perl/0.710.08
[...] This post was mentioned on Twitter by Yan-ren Tsai. Yan-ren Tsai said: ? ?? ext4 ???????http://tinyurl.com/28pn8th (How to Solve Zero Length File Problem in Linux’s Ext4 File System… http://plurk.com/p/55hiqu [...]
Leave a comment