LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 09-02-2008, 02:00 AM   #1
edenCC
Member
 
Registered: May 2006
Location: China
Distribution: Debian
Posts: 198
Blog Entries: 1

Rep: Reputation: 32
any simple ways to find these files with hole?


Hi, List;
Is there any simple ways for me to find out these files that have "holes" in them?

Code:
[admin@admon ~]$ls -sh /data/00/091/_3FFA3951AE8D
 40K /data/00/091/_3FFA3951AE8D
[admin@admon ~]$ll /data/00/091/_3FFA3951AE8D    
-rw-r--r--    1 coremail coremail 805366246 Apr 15  2005 /data/00/091/_3FFA3951AE8D
I also found a issue that,when using rsync(version 2.6.3) to copy these files to another server, they would take exact 805366246 bytes size, no 40KB.
 
Old 09-02-2008, 07:59 PM   #2
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
What do you mean by "holes"?
 
Old 09-02-2008, 09:26 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
I was guessing sparse ( http://en.wikipedia.org/wiki/Sparse_file) files, but there doesn't seem to be a switch in ls to list them.
 
Old 09-02-2008, 09:44 PM   #4
JonnerR
LQ Newbie
 
Registered: Dec 2005
Posts: 22

Rep: Reputation: 17
Sparse file detection

Quote:
Originally Posted by edenCC View Post
Hi, List;
Is there any simple ways for me to find out these files that have "holes" in them?

Code:
[admin@admon ~]$ls -sh /data/00/091/_3FFA3951AE8D
 40K /data/00/091/_3FFA3951AE8D
[admin@admon ~]$ll /data/00/091/_3FFA3951AE8D    
-rw-r--r--    1 coremail coremail 805366246 Apr 15  2005 /data/00/091/_3FFA3951AE8D
I also found a issue that,when using rsync(version 2.6.3) to copy these files to another server, they would take exact 805366246 bytes size, no 40KB.
Files with holes in them are called sparse files and are described in http://administratosphere.wordpress....t-why-and-how/. So basically, to detect the sparseness of a file, compare the size of the number of blocks allocated to the reported size of the file. If blocks * block_size is bigger than the reported size, you've got sparseness.

Unfortunately, there don't seem to be good tools to detect and deal with these files in general. I can use 'stat -c "%s -(%b * %B)" FILENAME |bc' to detect sparse files. For a typical non-sparse file, this gives me a negative number, since the size isn't an exact multiple of the block size. However, for a sparse file, it gives me a positive number which is the number of bytes in holes, which are not taking up any disk space.

Rsync can detect and create holes in files, but you have to give it the "--sparse" option.
 
1 members found this post helpful.
  


Reply



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
linux find to find files with multiple patterns subu_s Programming 6 12-15-2010 12:15 AM
LXer: 9 Simple Ways To Recover Your Screen on Linux and Unix LXer Syndicated Linux News 0 08-22-2008 03:41 PM
Simple find&replace across 100 files saphil Linux - Newbie 2 01-03-2008 12:21 PM
Is there a way to find recently created/edited files without using find? BrianK Linux - General 2 10-15-2007 09:41 PM
find security hole... os2 Linux - Security 5 10-13-2005 11:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 12:23 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
Open Source Consulting | Domain Registration