How many 4096 byte blocks on disk?


Results 1 to 3 of 3

Thread: How many 4096 byte blocks on disk?

  1. #1
    Join Date
    Nov 2002
    Location
    in my house.
    Posts
    114

    How many 4096 byte blocks on disk?

    Hi, I want to find out how many 4096 byte blocks there are on my disk. I used df -B 4096 and it gave me a number but I'm not sure it's correct as I can use dd to read past what should be the final block.

    So I do df -B 4096 and it reports this result:
    Code:
    Filesystem           4K-blocks      Used Available Use% Mounted on
    /dev/sda1             15618840  13190294   1635137  89% /

    But when I use dd to go past that block, it doesn't report an error or anything. The command I'm using is
    Code:
    dd if=/dev/sda1 bs=4096 count=1 skip=15618841
    How can I know that I'm really reading the very last block on the drive?

    Thanks!!
    -Glitch

    "The Linux philosophy is 'Laugh in the face of danger'. Oops. Wrong One. 'Do it yourself'. Yes, that's it." - Linus Torvalds

    Registered linux user # 296563

  2. #2
    Join Date
    Jun 2004
    Location
    Newcastle upon Tyne
    Posts
    2,978
    I think if sda1 has some overhead, like the filing indexing system etc, occupying the front end and the actual file storage is shorter than the length of sda1.

    Here is my own example. My sda1 occupies from block 1 to 15400th block (1 block=1 cylinder=8225280 byte).
    Code:
    saikee@saikee-desktop:~$ sudo fdisk -l /dev/sda
    [sudo] password for saikee: 
    
    Disk /dev/sda: 128.0 GB, 128035676160 bytes
    255 heads, 63 sectors/track, 15566 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0xde00600d
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1   *           1       15400   123700468+  83  Linux
    /dev/sda2           15401       15566     1333364+   5  Extended
    /dev/sda5           15401       15566     1333363+  82  Linux swap / Solaris
    However if I do a df I get
    Code:
    saikee@saikee-desktop:~$ df -B 8225280
    Filesystem         8.3MB-blocks      Used Available Use% Mounted on
    /dev/sda1                15159      3449     10940  24% /
    none                       381         1       381   1% /dev
    none                       382         1       381   1% /dev/shm
    none                       382         1       382   1% /var/run
    none                       382         0       382   0% /var/lock
    none                       382         0       382   0% /lib/init/rw
    /dev/sdb58               43453     13157     28088  32% /media/7f5e7b46-3579-415f-83f5-8b2e79a6c9c7
    /dev/sdb58               43453     13157     28088  32% /mnt/sdb58
    /dev/sdb3                59844     41042     15763  73% /mnt/sdb3
    The file storage length of my sda1 is only 15159 blocks. This suggests the overhead section of the partition is 241 block long or 15% of the partition space.

    When I using dd to display the contents of sda1 it complaints if the number of block exceeds the physical limit.
    Code:
    saikee@saikee-desktop:~$ sudo dd if=/dev/sda1 bs=8225280 count=1 skip=15400
    dd: `/dev/sda1': cannot skip: Invalid argument
    0+0 records in
    0+0 records out
    0 bytes (0 B) copied, 6.3942e-05 s, 0.0 kB/s
    However I get one block displayed by dd if I skip 15399 blocks indicating the physical limit of the partition.

    Thus the maximum block size you see in df does not corresponds to the end of the partition.
    Linux user started Jun 2004 - No. 361921
    Using a Linux live CD to clone XP
    To install Linux and keep Windows MBR untouched
    Adding extra Linux & Doing it in a lazy way
    A Grub menu booting 100+ systems & A "Howto" to install and boot 145 systems
    Just cloning tips Just booting tips A collection of booting tips

    Judge asked Linux "You are being charged murdering Windoze by stabbing its heart with a weapon, what was it?" Replied Linux "A Live CD"

  3. #3
    Join Date
    Nov 2002
    Location
    in my house.
    Posts
    114
    This is exactly what I wanted to know. Thank you very much!!
    -Glitch

    "The Linux philosophy is 'Laugh in the face of danger'. Oops. Wrong One. 'Do it yourself'. Yes, that's it." - Linus Torvalds

    Registered linux user # 296563

Posting Permissions

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