Loading ...
Sorry, an error occurred while loading the content.
 

Re: [LINUX_Newbies] Re: How to check block size in linux

Expand Messages
  • siva sankar
    ya ....i got now, thank you verymuch siva ... -- Siva BE RHCE [Non-text portions of this message have been removed]
    Message 1 of 10 , Dec 1, 2006
      ya ....i got now,
      thank you verymuch
      siva


      On 12/1/06, Cameron Simpson <cs@...> wrote:
      >
      > On 30Nov2006 13:31, siva sankar <siva.redhat@...<siva.redhat%40yahoo.co.in>>
      > wrote:
      > | I want to know the block size of my ext3 file system,
      > | How can i check this?
      > | Is there any command to check the block size in linux.
      > | or anyoher way to get block size.
      > | Please send details to get all informaion about block size in linux.
      >
      > "man tune2fs" will explain. You want the -l option.
      > --
      > Cameron Simpson <cs@... <cs%40zip.com.au>> DoD#743
      > http://www.cskk.ezoshosting.com/cs/
      >
      > I had a wierd dream with Ken Thompson in it once.
      > - George Politis <george@...<george%40research.canon.com.au>
      > >
      >
      >



      --
      Siva
      BE
      RHCE


      [Non-text portions of this message have been removed]
    • Loyal Barber
      See below ________________________________________ From: LINUX_Newbies@yahoogroups.com [mailto:LINUX_Newbies@yahoogroups.com] On Behalf Of Cameron Simpson
      Message 2 of 10 , Dec 1, 2006
        See below

        ________________________________________
        From: LINUX_Newbies@yahoogroups.com [mailto:LINUX_Newbies@yahoogroups.com]
        On Behalf Of Cameron Simpson
        Sent: Thursday, November 30, 2006 11:46 PM
        To: LINUX_Newbies@yahoogroups.com
        Subject: [LINUX_Newbies] Re: How to check block size in linux

        On 30Nov2006 19:17, Loyal Barber <loyal_barber@...> wrote:
        | I want to know the block size of my ext3 file system,
        | How can i check this?
        | Is there any command to check the block size in linux.
        | or anyoher way to get block size.
        | Please send details to get all informaion about block size in linux.
        | ---------------------------------
        | Poor man's way:
        |
        | 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.
        --
        Cameron Simpson
        =====================
        Cameron,
        The 1K block size count is not arbitrary but forced by the -k option. If
        the
        block size on the file system was 4096 bytes, the ls command would yield 4
        for
        size. See "man ls" if you need help.

        Loyal
      • Cameron Simpson
        ... 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. ... So: in
        Message 3 of 10 , Dec 1, 2006
          On 01Dec2006 13:08, Loyal Barber <loyal_barber@...> wrote:
          | > On 30Nov2006 19:17, Loyal Barber <loyal_barber@...> 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 <cs@...> DoD#743
          http://www.cskk.ezoshosting.com/cs/

          I've always been a big Greenaway fan - I've seen and enjoyed "The Falls" for
          crying out loud. - Peter Alexander Merel <pete@...>
        • Loyal Barber
          See below ________________________________________ From: LINUX_Newbies@yahoogroups.com [mailto:LINUX_Newbies@yahoogroups.com] On Behalf Of Cameron Simpson
          Message 4 of 10 , Dec 1, 2006
            See below

            ________________________________________
            From: LINUX_Newbies@yahoogroups.com [mailto:LINUX_Newbies@yahoogroups.com]
            On Behalf Of Cameron Simpson
            Sent: Friday, December 01, 2006 4:02 PM
            To: LINUX_Newbies@yahoogroups.com
            Subject: [LINUX_Newbies] Re: How to check block size in linux

            On 01Dec2006 13:08, Loyal Barber <loyal_barber@...> wrote:
            | > On 30Nov2006 19:17, Loyal Barber <loyal_barber@...> 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
          • Cameron Simpson
            ... Right. (Though I imagine there will be special purpose filesystems where they don t waste a whole block. But then asking about a block size on such a
            Message 5 of 10 , Dec 1, 2006
              On 01Dec2006 18:26, Loyal Barber <loyal_barber@...> wrote:
              | 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.

              Right. (Though I imagine there will be special purpose filesystems where they
              don't waste a whole block. But then asking about a "block size" on such a
              filesystem may not be so meaningful.)

              [...]
              | Appears that ls does the equivalent of ceil(size_in_bytes/1024).

              Yes.

              BTW, the stat(2) system call contains an st_blocks field, and an
              st_blksize field that _may_ match the filesystem block size (it
              needn't).
              --
              Cameron Simpson <cs@...> DoD#743
              http://www.cskk.ezoshosting.com/cs/

              I put instant coffee in a microwave oven and almost went back in time.
              - Stephen Wright
            Your message has been successfully submitted and would be delivered to recipients shortly.