osx - file size returned from ls - Linux vs OS X

12
2013-08
  • dtlussier

    I have been moving a large number of files between a Linux system (ext3) and Mac OS X (HFS) and have noticed the slight variation in how the file size is reported by the ls command.

    Having done some digging round the man pages I'm guessing this difference has to do with how the actual data is stored on the disk, and/or how the ls command on each system is looking at the size (i.e. disk usage, blocks used, etc.).

    However, I'm still confused and wondering if there is a simpler answer to the different file sizes between the two systems. Is this a difference in the ls command, or in the filesystems? etc.

  • Answers
  • John T

    Likely it's the file system. The command is probably reporting a value as the size on disk rather than the actual size, and since each machine may be using a different cluster size, you see different values. More on the topic in this question.

    You can use tune2fs -l to see how your file system is currently configured.

  • Matt Garrison

    Which version of OSX are you running? Snow Leopard now uses base-10 calculations instead of base-2. If you're on 10.5 or older, I would attribute it to filesystems. Try comparing filesizes from a FAT32 thumbdrive.


  • Related Question

    Why can't I delete a file marked as a socket from my linux ext3 filesystem?
  • Elijah

    I'm running Ubuntu 9.04 with a ext3 filesystem. A while ago I was hacking on the flock 2.0 source and I have just tried to delete the source directory, but a single file could not be deleted when using the rm -rf command. So, now I'm in the following state:

    #:$ sudo rm wizWaterMark.bmp.svn-base 
    rm: cannot remove `wizWaterMark.bmp.svn-base': Operation not permitted
    #: ls -lahi
    467275 drwxr-xr-x     2 elijah elijah 4.0K 2009-07-29 11:22 .
    467273 drwxr-xr-x     3 elijah elijah 4.0K 2009-07-29 11:22 ..
    467289 sr-s---r-t 53288  43274  44934 2.6G 1922-12-30 08:51 wizWaterMark.bmp.svn-base
    #: stat wizWaterMark.bmp.svn-base
      File: `wizWaterMark.bmp.svn-base'
      Size: 2708289673  Blocks: 1904771944 IO Block: 4096   socket
    Device: 806h/2054d  Inode: 467289      Links: 53288
    Access: (5505/sr-s---r-t)  Uid: (43274/ UNKNOWN)   Gid: (44934/ UNKNOWN)
    Access: 1962-09-19 07:25:47.000000000 -0700
    Modify: 1922-12-30 08:51:26.000000000 -0800
    Change: 2013-08-23 23:56:57.000000000 -0700
    #: sudo find . -inum 467289 -exec rm -i {} \;
    rm: remove socket `./wizWaterMark.bmp.svn-base'? y
    rm: cannot remove `./wizWaterMark.bmp.svn-base': Operation not permitted
    

    What I have just done is establish that I can't delete the file using rm. Nor does unlink work. I then tried to delete the file using the inode and that didn't work as well. Somehow this file/socket got installed when I was compiling or checking out the flock source. From what I can tell it is a socket file. How do I get rid of it?


  • Related Answers
  • vjt

    To me it looks like filesystem corruption, because that .svn-base file should not be a socket: it should contain the base revision of the wizWaterMark.bmp file checked out from subversion.

    Some hints should come from dmesg, but I would immediately remount the filesystem readonly (mount -o remount,ro /mountpoint) and do an fsck on it.

    Good luck!