3

I'm copying over a bunch of files from an HFS+ volume to my Ext4 Ubuntu file system. They're all movie files. When I copy one over, it nearly always gets 4K larger. The copied file is exactly 4,096 bytes larger than the original.

I'm assuming this is because some metadata of some sort is being added, but what is it exactly?

Also, out of 600 files, two of them didn't grow in size. They're exactly the same. Why would this be?

2 Answers 2

2

I don't know. But this is normal.

You can try to look at the files with du:

du -c *.mov
du -c --apparent-size *.mov

The first command will tell the Disk Usage (how much space is occupied on disk).

The second will show the actual size of the data (independent of where the file is stored).

1
  • Ah, fantastic. I skimmed over the apparent-size flag in the du man page. Very useful. Thank you. May 18, 2011 at 5:20
1

I would guess that the two filesystems have different block sizes. A block is a storage unit that allows for some abstraction by the filesystem for tracking allocation of space. A single block is the minimum unit of storage; a filesystem that uses 4K blocks will use a 4K block to store a 1K file. More small blocks require more disk space for metadata. The optimal block size will vary depending upon the typical file size, the total capacity of the storage media, and the filesystem used. Modern filesystems will choose a reasonable block size, given the latter two factors; a sysadmin may tweak the block size or chooseb a filesystem given her expectations for the use of the filesystem.

So, the two filesystems may have different block sizes because the disks are different sizes, or because the two different file systems have different schemes for optimizing block sizes, most likely because of different handling of metadata. The two files that didn't take up an extra 4K may have been just small enough to take up one less block each.

1
  • Okay great. After Googling around, I've the block size on my system is 4K by running sudo dumpe2fs /dev/sdx | grep 'Block size'. Finding the block size for the HFS+ volume didn't work, but this chart indicates that on my 1GB drive it should be 2K. So, this doesn't make too much sense to me because the files increased by exactly one block, which would seem to indicate that they were a multiple of 4K to start. It would make more sense if they all increased by 2K. Regardless, Levchuk's comment has helped me confirm the sizes are the same. May 18, 2011 at 5:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .