LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 11-25-2009, 04:06 AM   #1
huyangyang
Member
 
Registered: Nov 2009
Posts: 38

Rep: Reputation: 15
file size questions


my system is RHEL5.2
[root@joy ~]# uname -r
2.6.18-92.el5
[root@joy ~]# mount
/dev/sda3 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/dev/sdb on /mnt type ext3 (rw)
[root@joy ~]# df -T
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/sda3 ext3 7002712 2631988 4009264 40% /
/dev/sda1 ext3 101086 11139 84728 12% /boot
tmpfs tmpfs 257744 0 257744 0% /dev/shm
/dev/sdb ext3 20642428 176200 19417652 1% /mnt

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
append 2 byte data for the file ,size change 8k
[root@joy tmp]# echo i > joy
[root@joy tmp]# ll -sh joy
8.0K -rw-r--r-- 1 root root 2 Oct 31 04:59 joy
 
Old 11-25-2009, 04:25 AM   #2
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
There is a difference between the actual size of the content of a file (in your case, 2 bytes) and the size it takes up on disk.
The latter is always a multiple of the block size, which in your case seems to be 8KB (a fairly standard value).
This is related to how disk reading/writing/caching works, which is related to your operating system (Linux) and the
organization of the data on your hard drive (the filesystem).
 
Old 11-25-2009, 04:25 AM   #3
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

This is probably blocksize related.

The blocksize is the minimum size that can be occupied on a disk.

A file that is one bit, will occupy 1 block, which size could be anything from 1K to 64K (largest I've seen).

I don't know which alias ll has, but maybe the -s option is in there.

Quote:
touch foo
ls -ls foo
0 -rw-r--r-- 1 kpimet users 0 2009-11-25 11:23 foo

echo "x" >> foo
ls -ls foo
4 -rw-r--r-- 1 kpimet users 2 2009-11-25 11:23 foo
Blocksize is in red, filesize is in green.
 
Old 11-26-2009, 11:42 PM   #4
huyangyang
Member
 
Registered: Nov 2009
Posts: 38

Original Poster
Rep: Reputation: 15
thank you
 
Old 11-27-2009, 03:13 AM   #5
huyangyang
Member
 
Registered: Nov 2009
Posts: 38

Original Poster
Rep: Reputation: 15
what is this?
Device: 803h/2051d
.000000000 +0800
 
Old 11-27-2009, 04:14 AM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

This +0800 is the offset compared to UTC (+ 8 hours would put you in this area of the world).

This 803h/2051d shows (hex and decimal) the physical device and partition that the file is on.

Try a ls -l /dev/sd[ab]* you should see something like this:
Code:
# ls -l /dev/sd[ab]*
brw-r----- 1 root disk 8,  0 Sep 12 12:43 /dev/sda
brw-r----- 1 root disk 8,  1 Sep 12 12:43 /dev/sda1
brw-r----- 1 root disk 8,  2 Sep 12 12:43 /dev/sda2
brw-r----- 1 root disk 8,  3 Sep 12 12:43 /dev/sda3
brw-r----- 1 root disk 8,  4 Sep 12 12:43 /dev/sda4
brw-r----- 1 root disk 8,  5 Sep 12 12:43 /dev/sda5
brw-r----- 1 root disk 8,  6 Sep 12 12:43 /dev/sda6
brw-r----- 1 root disk 8, 16 Sep 12 12:43 /dev/sdb
brw-r----- 1 root disk 8, 17 Sep 12 12:43 /dev/sdb1
The bold entry is 0803 (major number 8, minor number 3)

Hope this helps
 
Old 11-28-2009, 12:04 AM   #7
huyangyang
Member
 
Registered: Nov 2009
Posts: 38

Original Poster
Rep: Reputation: 15
thank you,but my compute has only a harddisk. why start disk 8
 
Old 11-28-2009, 03:19 AM   #8
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
Your computer may have only one hard disk device, but probably has multiple bus connections to add more.
 
Old 11-28-2009, 03:20 AM   #9
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

This is by convention.

There are a lot of different devices you can connect to your box, a (scsi) HD is just one of those.

Take a look at this article: LINUX ALLOCATED DEVICES

If you scroll down to 8 block you see the scsi disk devices (8 being the so called major number), next to it a breakdown per disk (sda/sdb etc) with the starting minor number.

One none partitioned scsci disk will have major number 8 and minor number 0. The first partition will be 8 1, then 8 2 etc. This also explains why you can have a maximum of 15 partitions on one disk. (0 -> 16. One for the disk itself, 15 for partitions).

Hope this clears things up a bit.
 
Old 11-28-2009, 03:38 AM   #10
huyangyang
Member
 
Registered: Nov 2009
Posts: 38

Original Poster
Rep: Reputation: 15
Thank you very much.
 
Old 12-01-2009, 12:07 AM   #11
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
Also note that the directory file-sizes may be out of date at any particular time, because the directory entries are updated infrequently.
 
  


Reply



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
file size questions huyangyang Linux - Newbie 20 11-25-2009 03:58 AM
[SOLVED] Questions about file size and dd djeikyb Linux - Software 3 10-15-2008 04:29 PM
any ideas to reduce log file size or make log file size managed? George2 Programming 2 08-13-2006 06:55 AM
file system size larger than fysical size:superblock or partition table corrupt klizon Linux - General 0 06-18-2004 04:18 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 11:19 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
Open Source Consulting | Domain Registration