# Reading drive size: difference between BSD and Linux



## sossego (Apr 26, 2010)

I will have to edit this post a few times for reason that I have three OSes installed on this machine. For those of you reading, please be patient.


```
# uname -a
Linux c-98-211-118-98 2.6.30-bpo.2-686 #1 SMP Fri Dec 11 18:12:58 UTC 2009 i686 GNU/Linux

e# fdisk /dev/hda

The number of cylinders for this disk is set to 30401.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/hda: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00089ad6

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1               1        6079    48829536   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/hda2            6080        6141      498015   82  Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/hda3            6142       17238    89128960   a6  OpenBSD
Partition 3 does not end on cylinder boundary.
/dev/hda4   *       17238       30402   105742041+  a5  FreeBSD
Partition 4 does not end on cylinder boundary.

Command (m for help): q
```


```
# uname -a  
OpenBSD moo.my.domain 4.6 GENERIC#58 i386
# fdisk wd0
Disk: wd0	geometry: 30401/255/63 [488397168 Sectors]
Offset: 0	Signature: 0xAA55
            Starting         Ending         LBA Info:
 #: id      C   H   S -      C   H   S [       start:        size ]
-------------------------------------------------------------------------------
 0: 83      0   1   1 -   6078 254  63 [          63:    97659072 ] Linux files*
 1: 82   6079   0   1 -   6140 254  63 [    97659135:      996030 ] Linux swap  
 2: A6   6141   0   1 -  17237  10  50 [    98655165:   178257920 ] OpenBSD     
*3: A5  17237  10  51 -  30401  80  63 [   276913085:   211484083 ] FreeBSD     
# disklabel -h wd0
# /dev/rwd0c:
type: ESDI
disk: ESDI/IDE disk
label: WDC WD2500JB-00R
flags:
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 255
sectors/cylinder: 16065
cylinders: 30401
total sectors: 488397168 # total bytes: 238475.2M
rpm: 3600
interleave: 1
boundstart: 98655165
boundend: 276913085
drivedata: 0 

16 partitions:
#                size           offset  fstype [fsize bsize  cpg]
  a:          3200.4M         98655165  4.2BSD   2048 16384    1 # /
  b:           768.7M        105209685    swap                   
  c:        238475.2M                0  unused                   
  d:          4102.5M        106784055  4.2BSD   2048 16384    1 # /tmp
  e:          4102.5M        115186050  4.2BSD   2048 16384    1 # /var
  f:         32773.2M        123588045  4.2BSD   2048 16384    1 # /usr
  g:         42092.5M        190707615  4.2BSD   2048 16384    1 # /home
  i:         47685.1M               63  ext2fs                   
  j:           486.3M         97659135 unknown                   
#
```


```
timey# uname -a
FreeBSD timey.time 8.0-RELEASE FreeBSD 8.0-RELEASE #0: Sat Nov 21 15:48:17 UTC 2009     root@almeida.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386
timey# fdisk /dev/ad0
******* Working on device /dev/ad0 *******
parameters extracted from in-core disklabel are:
cylinders=484521 heads=16 sectors/track=63 (1008 blks/cyl)

Figures below won't work with BIOS for partitions not in cyl 1
parameters to be used for BIOS calculations are:
cylinders=484521 heads=16 sectors/track=63 (1008 blks/cyl)

Media sector size is 512
Warning: BIOS sector numbering starts with sector 1
Information from DOS bootblock is:
The data for partition 1 is:
sysid 131 (0x83),(Linux native)
    start 63, size 97659072 (47685 Meg), flag 0
	beg: cyl 0/ head 1/ sector 1;
	end: cyl 1023/ head 0/ sector 63
The data for partition 2 is:
sysid 130 (0x82),(Linux swap or Solaris x86)
    start 97659135, size 996030 (486 Meg), flag 0
	beg: cyl 1023/ head 255/ sector 63;
	end: cyl 1023/ head 2/ sector 63
The data for partition 3 is:
sysid 166 (0xa6),(OpenBSD)
    start 98655165, size 178257920 (87040 Meg), flag 0
	beg: cyl 1023/ head 255/ sector 63;
	end: cyl 1023/ head 5/ sector 50
The data for partition 4 is:
sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD)
    start 276913085, size 211484083 (103263 Meg), flag 80 (active)
	beg: cyl 1023/ head 255/ sector 63;
	end: cyl 1023/ head 15/ sector 63
timey#
```


----------



## sossego (Apr 26, 2010)

Notice that the drive is listed as 250GB in size for the linux fdisk but is listed at ~238GB in size for the BSDs.
Why such a difference in readings?


----------



## fronclynne (Apr 26, 2010)

```
238475.2*1024*1024
250059371315.2
```
&&
[red]250059350016[/red] bytes
yes?
no?
(NB BAC=0.116 or something, sorry)


It's good to SEVEN SIGNIFICANT DIGITS.


----------



## fronclynne (Apr 26, 2010)

Sorry for yelling, I'm angry at math.


----------



## sossego (Apr 26, 2010)

I was wondering if the fdisk on debian uses a base10 instead.


----------



## fronclynne (Apr 26, 2010)

Yes this 
	
	



```
Disk /dev/hda: 250.0 GB, 250059350016 bytes
```
 is giving you the a) marketing number, followed by b) the number of bytes which, if you 
	
	



```
250059350016/1024/1024
238475
```
 err, QED, & all that.

tada.


----------



## sossego (Apr 26, 2010)

Why would they choose it?


----------



## fronclynne (Apr 26, 2010)

If you had to choose between buying a 238G drive and a 250G drive (at the same price), which would you buy?


----------



## sossego (Apr 26, 2010)

The 238GB one. 
No, I'm not being stupid. I'd rather go for the base2.

That was a great reply.


----------



## fronclynne (Apr 26, 2010)

Haha, sorry if I sounded crabby, it's just that it's been gone over so fscking many times on freebsd-questions@ over the last decade (that I've followed).  Once disks started to get into the 10s of gigabytes the differences really started to show: a 350M drive is missing about 16M, but a 350G drive would be missing about 24G and people start to (think they) notice _that_.  But yeah, that 1024-1000 starts to actually _look_ significant when you're putting a whole 'nother three orders of magnitude in there.


----------



## sossego (Apr 26, 2010)

Was it just easier for them?
"Sam?"
'Yeah, Max."
"Whats two times two times two times two times two times two?"
"Don't know. Too many two's in there."
"Hell with it. Let's go for a base ten."
And then they celebrated by getting sloshed.


----------



## SirDice (Apr 26, 2010)

sossego said:
			
		

> Was it just easier for them?


Not really. It's because harddisk manufactures _must_ use the SI standards. These dictate base10 for prefixes.


----------



## aragon (Apr 26, 2010)

Yup, HDDs use SI units because, well, they're not memory.  Some more history/details at wikipedia: http://en.wikipedia.org/wiki/Binary_prefix#Disk_drives


----------

