See below
________________________________________
From: [email protected] [mailto:[EMAIL PROTECTED]
On Behalf Of Cameron Simpson
Sent: Friday, December 01, 2006 4:02 PM
To: [email protected]
Subject: [LINUX_Newbies] Re: How to check block size in linux
On 01Dec2006 13:08, Loyal Barber <[EMAIL PROTECTED]> wrote:
| > On 30Nov2006 19:17, Loyal Barber <[EMAIL PROTECTED]> wrote:
| > | echo "a" > junk.kil
| > | ls -lk junk.kil
| > |
| > | The size display will be in 1kb blocks. Since the contents of the file
| > | should be much smaller than the block size, the file should take up
one
| > | block.
| >
| > This is an arbitrary 1024 byte "block" count, a figment of "ls"'s
| > imagination. I'm pretty sure it reveals nothing about the actual block
size
| > of the filesystem.
|
| The 1K block size count is not arbitrary but forced by the -k option.
I mean "arbitrary" in that it has nothing to do with the _filesystem_
block size. It's 1024 bytes, and the filesystem setup has no effect it.
| If the block size on the file system was 4096 bytes, the ls command would
| yield 4 for size.
So: in what way does this let you determine the filesystem block size.
If the file system block size were 512 bytes or 1024 bytes or 4096 bytes,
how would ls's output change. If ls's output does not change, it is not
possible to deduce the filesystem block size.
Please explain your reasoning with an example.
| See "man ls" if you need help.
It says nothing about the behaviour you're describing. Tests show your
assertion to be untrue, or that I misunderstand you. Watch:
[/home/cameron]zoob*> dd if=/dev/zero of=foo bs=1 count=4097
4097+0 records in
4097+0 records out
4097 bytes (4.1 kB) copied, 0.0105294 seconds, 389 kB/s
[/home/cameron]zoob*> ls -lk foo
-rw-rw-r-- 1 cameron cameron 5 Dec 2 08:55 foo
[/home/cameron]zoob*> ls -l foo
-rw-rw-r-- 1 cameron cameron 4097 Dec 2 08:55 foo
Here we have ls asserting "5" blocks for "foo". Were blocks 1024 bytes,
then this would be true. But this filesystem uses 4096 byte blocks,
as verified from a "tune2fs -l /dev/hda1" command.
Now, I understand that ls is using 1024 bytes in its computation, and
that naturally says "5" (4 x 1024, plus 1 block for the last byte).
What I do not understand is how you expect to learn the _filesystem_
block size from the output of ls.
--
Cameron Simpson
====================
What I was doing is using known behavior in Linux (or Unix for that matter)
to get the system to tell me the block size. First, I create a file of one
byte (OK, two bytes including the line feed) knowing that the behavior
will be for the file to take up an entire block, even though it is only
two bytes.
I then force the ls command to display the size of the file in 1K or 1024
byte
blocks by using the -k option. That displays the size as 1 or 1K block.
But
what you are telling me is that my trick does not work on your system with
4K
blocks. For my trick to work, I would expect the behavior in the example
you
showed to yield a size of 8 for your 4097 byte file. In other words, since
the file is one byte more than one 4K block, it should have taken up two
blocks
or 8K. However ls shows only 5K which means MY TRICK DOES NOT WORK. Oops.
I should have done more checking, it just seemed like a quick way to me. It
Appears that ls does the equivalent of ceil(size_in_bytes/1024).
Loyal
To unsubscribe from this list, please email [EMAIL PROTECTED] & you will be
removed.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/LINUX_Newbies/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/LINUX_Newbies/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/