Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


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

Rep: Reputation: 51
cp has mysterious ways.

Hi: Watch this.
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_/
Is there any logical explanation for this behavior? This is kernel, slackware 12.0, cp 6.9.
Old 10-07-2011, 05:01 PM   #2
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

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

Original Poster
Rep: Reputation: 51
              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:
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 06:49 PM.


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 08:20 AM
Mysterious crashes Philip87 Linux - Newbie 7 09-09-2008 08:10 AM
mysterious computer housemusic42 Linux - Networking 9 02-22-2007 07:47 PM
Mysterious Slowing billquinn Linux - General 2 09-14-2005 05:16 PM
Mysterious Directory Dooley Mandriva 3 07-03-2004 12:26 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:26 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration