LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-07-2011, 05:42 PM   #1
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,485

Rep: Reputation: 51
cp has mysterious ways.


Hi: Watch this.
Code:
semoi@darkstar:~$ du -hs /hdbxp/sma_/
184M    /hdbxp/sma_/
semoi@darkstar:~$ cp -a -r /hdbxp/sma_ /hdaxp
semoi@darkstar:~$ du -hs /hdaxp/sma_/
109M    /hdaxp/sma_/
semoi@darkstar:~$
Is there any logical explanation for this behavior? This is kernel 2.6.21.5, slackware 12.0, cp 6.9.
 
Old 10-07-2011, 06:01 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Sparse files?
 
Old 10-07-2011, 06:49 PM   #3
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,485

Original Poster
Rep: Reputation: 51
Code:
     --apparent-size
              print apparent sizes,  rather  than  disk  usage;  although  the
              apparent  size is usually smaller, it may be larger due to holes
              in (`sparse') files, internal  fragmentation,  indirect  blocks,
              and the like
The only thing that I know is that a file lies in a hole number of blocks. If blocks are 32768 bytes in size and the file length is 33000 bytes, it will occupy 32768 * 2 bytes.

The files in /hdbxp/sma_ may very well be in a high state of fragmentation. And the copy process defragmentated them. But I do not see how this can reduce the occupied space.

If I use the --all option of du I'll be able to count the files and compare. One detail I forgot to mention: the source file system is FAT32 and the destination one is NTFS.

EDIT: I am seeing directories occupy 16384 bytes in the FAT32 partition and only 4096 in the NTFS partition. If the difference in size between source and destination is due only to this, then there would have to be 6103 directories in the source (and in the destination). But the number of files plus the number of directories is 6995. Absurd.

Oh, oh, oh ... There is another consideration. Block size. See this:
Code:
semoi@darkstar:~$ du --apparent-size -hs /hdbxp/sma_/
103M    /hdbxp/sma_/
semoi@darkstar:~$ du --apparent-size -hs /hdaxp/sma_/
99M     /hdaxp/sma_/
Now the difference is much smaller, and can be accounted for by the difference in the directories sizes (16384 vs 4096). The large difference yielded by du without the --apparent-size option means that the block size is much less in the NTFS partition (/hdaxp).

Last edited by stf92; 10-07-2011 at 07:49 PM.
 
  


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
LXer: 15 Ways Nokia’s N900 Is Better Than Apple’s iPhone (and 5 ways it’s not) LXer Syndicated Linux News 0 11-14-2009 09:20 AM
Mysterious crashes Philip87 Linux - Newbie 7 09-09-2008 09:10 AM
mysterious computer housemusic42 Linux - Networking 9 02-22-2007 08:47 PM
Mysterious Slowing billquinn Linux - General 2 09-14-2005 06:16 PM
Mysterious Directory Dooley Mandriva 3 07-03-2004 01:26 AM


All times are GMT -5. The time now is 10:45 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration