LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-16-2003, 08:01 AM   #1
Bert
Senior Member
 
Registered: Jul 2001
Location: 406292E 290755N
Distribution: GNU/Linux Slackware 8.1, Redhat 8.0, LFS 4.0
Posts: 1,004

Rep: Reputation: 46
bits and bytes and files basics question


I'm having some trouble with the basics:

cat > touchtext.txt
a<Ctrl+D>

This creates a files with 1 byte - the letter 'a' with no CR (which would add a byte). This is confirmed by:

ls -l touchtext.txt
-rw-r--r-- 1 root root 1 Jan 16 13:28 touchtext.txt

OK. This is the size of the contents of the file. Now, I can see how much space on the disk this takes:

du -h touchtext.txt
4.0K touchtext.txt

If I make a sentence in the touchtext.txt file like 'Let's vanquish the world of this filthy DMCA trash! Get rid of this trash ... ' then the disk usage is still 4.0K. Not a problem, it's an estimate and it's the size on disk.

2 questions:

1. I'd like to see how much information is taken by storing the additional permissions and timestamp information.
Permissions should be 2 bytes (actually 12 bits?), owner 2 bytes (12 bits?), group 2 bytes (12 bits?), timestamp and name err .. a few bytes each. How can I see this information?

2. If my cluster size is 1024 bytes, why is the size on the disk (although it is only an estimate with du) need 4K?

Any ideas anyone. I'd really appreciate information on the first question especially.

Thanks for any help
Bert

PS. I put the questions in bold for people who don't need the explanations.

Last edited by Bert; 01-16-2003 at 08:18 AM.
 
Old 01-16-2003, 08:28 AM   #2
fsbooks
Member
 
Registered: Jan 2002
Location: Missoula. Montana, USA
Distribution: Slackware (various)
Posts: 464

Rep: Reputation: 52
du reports disk usage not filesize. It uses the block (or fragment) size of the disk which you can find (as root) with tune2fs -l <dev>. If du <file> reports 4 for a 1 byte file, the minimum allocation size for that partition is 4096, or 4k.

The additional information taken by storing the permissions and timestamp does not take up anymore information. It is stored in the inodes, which are pre-allocated at disk format. Each file takes one inode. Again, tune2fs -l <dev> will give you the total number of inodes on a drive and the number still available.

Chris Winne
 
Old 01-16-2003, 08:50 AM   #3
Bert
Senior Member
 
Registered: Jul 2001
Location: 406292E 290755N
Distribution: GNU/Linux Slackware 8.1, Redhat 8.0, LFS 4.0
Posts: 1,004

Original Poster
Rep: Reputation: 46
Thanks Chris, yeah I figured that out soon after that this information is not stored against the file but in the inodes, but how can I see the amount of space that inode takes (which will vary for each file), however I also see that tune2fs -l /dev/hdan gives the inode size - 128 bytes. I can work back from there (and that looks to be about right too ) - thanks!

Although my fragment (and block) size is 1024, the allocation size must be 4096 bytes, yes. I was under the impression that the block size is the allocation size *tsk*.

Thanks
Bert
 
  


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
MRTG - Bits and Bytes Equin Linux - Software 1 10-04-2005 10:29 PM
Can't create files bigger than 0 bytes GameboyHippo Linux - General 1 03-01-2005 08:04 PM
Samba truncating files to 0 bytes KimVette Linux - Networking 6 01-30-2005 06:42 PM
Access permission bits for special files spinifeX Linux - General 1 01-08-2005 02:05 PM
which is faster, bits or bytes? tearinox Linux - General 5 10-15-2004 02:46 AM

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

All times are GMT -5. The time now is 03:55 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