Calculating Hard Drive Capacity
You want to measure precisely the capacity of a hard drive, but you can't seem to get a straight answer because of confusion over measurement values. How much is a megabyte—is it 1 million bytes, or 220 bytes? Which measurement is used for the rated size of your drive?
Use fdisk to get the total disk size in bytes:
# /sbin/fdisk -l /dev/hda
Disk /dev/hda: 20.5 GB, 20576747520 bytes
Then do a little math to get the value in gibibytes, which is a power of 2:
20576747520 / 1,073,741,824 = 19.16 gibibytes
Gigabytes, which are most often used as powers of 10, are easy to figure:
20576747520 / 10 = 20.58 gigabytes
Table 5-1 shows a comparison of binary and decimal multiples.
You want to measure precisely the capacity of a hard drive, but you can't seem to get a straight answer because of confusion over measurement values. How much is a megabyte—is it 1 million bytes, or 220 bytes? Which measurement is used for the rated size of your drive?
Use fdisk to get the total disk size in bytes:
# /sbin/fdisk -l /dev/hda
Disk /dev/hda: 20.5 GB, 20576747520 bytes
Then do a little math to get the value in gibibytes, which is a power of 2:
20576747520 / 1,073,741,824 = 19.16 gibibytes
Gigabytes, which are most often used as powers of 10, are easy to figure:
20576747520 / 10 = 20.58 gigabytes
Table 5-1 shows a comparison of binary and decimal multiples.
0 Comments