Calculate usable bytes on a disk partition?
How do you calculate the number of usable bytes on a disk partition? When I do an fdisk -l I get this:
Disk /dev/md0: 192.0 GB, 192069500928 bytes 2 heads, 4 sectors/track, 46891968 cylinders Units = cylinders of 8 * 512 = 4096 bytes Device Boot Start End Blocks Id System /dev/md0p1 1 23445984 93783935+ 83 Linux /dev/md0p2 23445985 46891968 93783936 83 Linux The number of usable bytes for /dev/md0 is clearly displayed as 192069500928 bytes. Also calculating the number of bytes form the number of cylinders seems to be valid as well (192069500928 = 46891968 * 4096). My test program is happy when trying to access all 192069500928 bytes. When I try to do the same calculation on /dev/md0p2 I get (46891968-23445985)*4096 = 96034746368 bytes. Even though this value seems reasonable, it doesn't seem like all 96034746368 bytes are usable since my test program gets errors when trying to access all 96034746368 bytes. Does anyone know how to calculate the number "usable" bytes on a disk partition? |
not sure if this is what you are looking for but
df -h will show statistics about what file systems are mounted, how much is used and how much is free etc... eg Code:
hopper@hopper-desktop:~$ df -h |
The hair to be split is:
Do you want the useable bytes on the partition or the useable bytes in the filesystem that is on the partition? Keep in mind that data gets stored in blocks, and a 1 byte file will take more space than you might have assumed. |
Further to this, depending on the filesystem, you may (or not) have reserved blocks, and you will certainly have metadata that is stored in the filesystem.
dumpe2fs will give you some idea of the type of things you need to account for in ext2/3/4. |
No I am not referring to a filesystem. I want to know the usable bytes on a raw block device partition.
|
Quote:
For partition sda3: Code:
dd if=/dev/zero of=/dev/sda3 Or--read the partition into a file: Code:
dd if=/dev/sda3 of=/<path>/sda3.img In the latter case, you obviously will need a lot of space somewhere to write the image file. |
Should work - I might be inclined to test the math on a "real" device though ...
|
I prefer using "fdisk -lu". This will show the results in 512 byte blocks. This eliminates rounding errors.
|
All times are GMT -5. The time now is 09:22 AM. |