file size questions
create a empty file,but this file size is 4k
[root@joy tmp]# touch joy [root@joy tmp]# ll -sh joy 4.0K -rw-r--r-- 1 root root 0 Oct 30 17:23 joy [root@joy tmp]# stat joy File: `joy' Size: 0 Blocks: 8 IO Block: 4096 regular empty file Device: 803h/2051d Inode: 1421279 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2009-10-30 17:23:50.000000000 +0800 Modify: 2009-10-30 17:23:50.000000000 +0800 Change: 2009-10-30 17:23:50.000000000 +0800 |
As far as I know, no filesystem will take a block to store an empty file, are you sure you used touch and that you didn't edit the file and then saved it? If the file has a single byte inside, that's enough to make it significant, and hence, it will take a whole fs block (what stat calls IO Block).
What fs are you using? |
no i don`t edit the file.i used ext3 fs.
[root@joy ~]# uname -r 2.6.18-92.el5 [root@joy ~]# fdisk -l Disk /dev/sda: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 13 104391 83 Linux /dev/sda2 14 144 1052257+ 82 Linux swap / Solaris /dev/sda3 145 1044 7229250 83 Linux [root@joy ~]# cd /tmp/ [root@joy tmp]# rm joy rm: remove regular empty file `joy'? y [root@joy tmp]# touch joy [root@joy tmp]# ll -sh joy 4.0K -rw-r--r-- 1 root root 0 Oct 30 17:46 joy [root@joy tmp]# stat joy File: `joy' Size: 0 Blocks: 8 IO Block: 4096 regular empty file Device: 803h/2051d Inode: 1421279 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2009-10-30 17:46:40.000000000 +0800 Modify: 2009-10-30 17:46:40.000000000 +0800 Change: 2009-10-30 17:46:40.000000000 +0800 [root@joy tmp]# |
dddddddddddd
|
I think the inode entry in the dir inode has to point to something(!), so it 'reserves' the initial (4k) file block, even if it's empty.
|
I tested this same stuff (also on ext3) and empty files take 0 bytes, as far as I know it has always been the same for me. So I am not sure what to think.
Code:
$ cd /home/i92guboj/media/conceptronic/ |
why are you using
Code:
ll -sh joy Code:
ls joy |
Quote:
$echo i > foo and stat foo. |
Quote:
|
Quote:
If you edit the file then the file length might not be zero anymore, it depends on what your editor is doing. "touch" by default creates an zero-length file which shouldn't take any block in your disk. |
Quote:
|
[root@joy tmp]# touch joy
[root@joy tmp]# ll -sh joy 4.0K -rw-r--r-- 1 root root 0 Oct 30 17:46 joy [root@joy tmp]# stat joy File: `joy' Size: 0 Blocks: 8 IO Block: 4096 regular empty file Device: 803h/2051d Inode: 1421279 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2009-10-30 17:46:40.000000000 +0800 Modify: 2009-10-30 17:46:40.000000000 +0800 Change: 2009-10-30 17:46:40.000000000 +0800 [root@joy tmp]# |
what about
Code:
ls -s -h joy |
Quote:
4.0K joy [root@WOLK-TECH tmp]# |
because your system's the size of default block is 4K,every file will take up one block at least.
|
All times are GMT -5. The time now is 01:19 AM. |