Find the answer to your Linux question:
Page 2 of 5 FirstFirst 1 2 3 4 5 LastLast
Results 11 to 20 of 45
Originally Posted by bitzsk so what is the best command to read a file and read all the sectors of the file? is that more command or another? Sorry I ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #11
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,763

    Smile


    Quote Originally Posted by bitzsk View Post
    so what is the best command to read a file and read all the sectors of the file? is that more command or another?
    Sorry I couldn't understand your question. What's your objective?
    If you want to read a file using a command then simply use
    cat filename
    First they ignore you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -----
    FOSS India Award winning ext3fs Undelete tool www.giis.co.in. Online Linux Terminal http://www.webminal.org

  2. #12
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,709
    Quote Originally Posted by bitzsk View Post
    Hi,

    i want to get the exact match between block number and sector number of a file in domU of xen. so i do follows .


    root@feisty:~# ls -l
    total 1
    -rw-r--r-- 1 root root 4 Jun 9 08:16 a

    root@feisty:~# filefrag -v a
    Checking a
    Filesystem type is: ef53
    Filesystem cylinder groups is approximately 122
    Blocksize of file a is 1024
    File size of a is 2 (1 blocks)
    First block: 247208
    Last block: 247208
    a: 1 extent found

    the file has one block and block size is 247208, so the secoter size is 247208 *2 +1 == 78B51 and 247208*2 +2 == 78B52 (block number count begin from 0 , sector number count begin from 1).
    Actually, the file is 1 block in size (start and end block are same. Each block == 2 sectors. So, starting sector is 247208 * 2, and ending sector = starting sector + 1.

    start_sector = 494416 (78B50)
    end_sector = 494417 (78B51)

    I don't know why you offset these by one. Also, you are lucky that there is only 1 extent found. If more, I think you would have to look at the sector data to determine where the next extent is located, following the chain as necessary. In any case, the reason you found no data is the fact that the actual file is shorter than 1 full sector, so since you were off by 1, NDF (No Data Found).
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #13
    Just Joined! bitzsk's Avatar
    Join Date
    Apr 2009
    Location
    Far, Far, Away on the earth
    Posts
    25
    is it block count from 0 and sector number count from 1.

    so:

    1 2 ------>0 block
    3 4 ------>1 block
    5 6 ------>2 block

    and sector_number is : block_number * 2 +1 and block_number * 2 +2

    is it right?

  4. $spacer_open
    $spacer_close
  5. #14
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,709
    Quote Originally Posted by bitzsk View Post
    is it block count from 0 and sector number count from 1.

    so:

    1 2 ------>0 block
    3 4 ------>1 block
    5 6 ------>2 block

    and sector_number is : block_number * 2 +1 and block_number * 2 +2

    is it right?
    I don't think so. Both are offset from 0. Block 0 == sector 0 thru sector 1. Don't add the extra offset. Just multiply the block number by 2 to get the absolute sector number for the start of the file.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  6. #15
    Just Joined! bitzsk's Avatar
    Join Date
    Apr 2009
    Location
    Far, Far, Away on the earth
    Posts
    25
    ref:support.microsoft.com/kb/97819

    Sector counting starts at 1 when referring to the physical disk geometry. The first sector is reference by head 0, cylinder 0, sector 1. When people refer to absolute sectors on a physical volume, however, they typically refer to sector 0 as the first sector. Many applications (for example, Norton Disk Doctor) refer to the first sector as sector 0. Other tools use different conventions.

    Documentation often references sector 0, as it is less ambiguous than using sector 1. Sector 0 is clearly the first sector, even if you disagree with the convention. Sector 1 is the first sector to some people, and the second sector to others.

  7. #16
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,709
    Quote Originally Posted by bitzsk View Post
    ref:support.microsoft.com/kb/97819

    Sector counting starts at 1 when referring to the physical disk geometry. The first sector is reference by head 0, cylinder 0, sector 1. When people refer to absolute sectors on a physical volume, however, they typically refer to sector 0 as the first sector. Many applications (for example, Norton Disk Doctor) refer to the first sector as sector 0. Other tools use different conventions.

    Documentation often references sector 0, as it is less ambiguous than using sector 1. Sector 0 is clearly the first sector, even if you disagree with the convention. Sector 1 is the first sector to some people, and the second sector to others.
    Fair enough. To compute the sector for the start of a file from the OS perspective, we still need to address it from 0, not 1. Am I correct? I've always (successfully) done it that way in the past (pre-sata era). Sector 0 was always the boot sector, but that is still the start of the physical drive.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  8. #17
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,709
    As to why the sectors you are looking for are not showing in the log file, the messages shown are likely for things like the inodes, superblock, etc. Try increasing the length of the tail with the -n line_count option. IE: tail -n 50 /var/log/messages
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  9. #18
    Just Joined! bitzsk's Avatar
    Join Date
    Apr 2009
    Location
    Far, Far, Away on the earth
    Posts
    25
    Yes, you're right!

    Thanks a lot

  10. #19
    Just Joined! bitzsk's Avatar
    Join Date
    Apr 2009
    Location
    Far, Far, Away on the earth
    Posts
    25
    One thing i cant understand is that when i open a file and delete same charactors, then save the file. i guess the block number should not changed, because i not add any thing to the file and the old block should have enough space to save the file to the same block.

    so what i think is add something to a file, it's block will change.

    delete something from a file, it's block will not change.

    but it's not true.

  11. #20
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,709
    The starting block of the file will likely not change, though I am not certain of that. Linux might relocate the file in order to reduce fragmentation. Don't know, never needed to know. In any case, nothing would likely be relocated until upon growing it exceeds the blocks allocated for it. As I said, I don't know if this happens or not, and if it does, when it will do so.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Page 2 of 5 FirstFirst 1 2 3 4 5 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •