From: Mike Clarke on
I've got a Seagate ST3160023A 160GB disk and an ASRock K7S8XE motherboard,
with the latest (version 2.2) BIOS firmware, running FreeBSD 6.0.

I can't find any precise documentation on the motherboard's ability to
support 48 bit LBA but I assume it does since the FAQ states that WinXP
users have to install SP1 to enable the OS to make use of 48 bit LBA.

On boot up the BIOS reports 65535/16/255 C/H/S (i.e. only 137 GB) but
describes the drive as 160GB with LBA enabled.

FreeBSD fdisk reports 76613/16/255 = 160,041,492,480 bytes

An earlier thread in this group suggested cfdisk-linux, this reports a
slightly different size with 19457/255/63 = 160,041,885,696 bytes. At
312,576,705 sectors this is the closest to the Seagate spec of 312,581,808
sectors.

dmesg reports "ad0: 152627MB <Seagate ST3160023A 8.01> at ata0-master
UDMA100" which doesn't match any of the above.

So far I've only partitioned the first 80GB of the disk in 3 slices but now
I'd like to create the final slice so I can try out FreeBSD 6.1 without
loosing my current 6.0 setup.

Sysinstall reports that the geometry of 76613/16/255 is incorrect and
suggests using 19457/255/63 instead (i.e. the same as cfdisk-linux). I
remember something like this when I first installed 6.0 but can't remember
whether I chose to use the suggested geometry or not (yes I should have
taken thorough notes at the time but it's too late now).

My problem now is what geometry to specify when creating the final slice?

If it turns out that the 137GB geometry reported by the BIOS really is all
it can handle then I expect trying to use 160GB will wrap round and trash
my first slice.

Is there any non destructive test I can do to ascertain if my system really
does support 48 bit LBA?

Assuming 48 bit LBA is supported what geometry should I chose when creating
the final slice to ensure I don't trash the original 3 slices?

Should I just play safe, backup everything and repartition the disk from
scratch with the geometry suggested by sysinstal? I have backups anyway but
I'll take extra ones when I know I'm definitely deleting everything.

--
Mike Clarke
From: Keve Nagy on
Hi Mike,
I have a Slot1 PIII/800 system, and I used a 160GB disk with it before I
lately upgraded to a 250GB one. Both the 160 and 250 disks worked fine
under FreeBSD 5.4, using approximately 160 and 250GB of space, so in my
opinion you should not be limited to use your 160GB disk with your
motherboard.

> On boot up the BIOS reports 65535/16/255 C/H/S (i.e. only 137 GB) but
> describes the drive as 160GB with LBA enabled.

Most motherboards (if not all of them) do that. This is due to an old
BIOS limitation. What matters is if LBA enabled the disk is identified
as 160GB. You just said it is, so BIOS-wise you are fine.

> FreeBSD fdisk reports 76613/16/255 = 160,041,492,480 bytes

Do not trust this! FreeBSD fdisk is not handling this properly. It
should have been updated long ago, but obviously it wasn't.
Usually what dmesg says at boot time about your disk, and what fdisk
syas about it in general is the same, and of course entirely wrong.
As long as you know that these are incorrect values, you can safely
ignore this issue, your disk will still work fine with the proper
geometry, regardless what dmesg and fdisk say.


> An earlier thread in this group suggested cfdisk-linux, this reports a
> slightly different size with 19457/255/63 = 160,041,885,696 bytes. At
> 312,576,705 sectors this is the closest to the Seagate spec of 312,581,808
> sectors.

This is the one you can trust and this is the one you should be using.

Here is what my system says about my 250GB disk under FreeBSD 5.4-STABLE.
dmesg:
da0: 238475MB <SAMSUNG SP2514N/VF100-33> [484521/16/63] at ata0-master \
UDM66

fdisk:
******* 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 7 (0x07),(OS/2 HPFS, NTFS, QNX-2 (16 bit) or Advanced UNIX)
start 63, size 8193087 (4000 Meg), flag 80 (active)
beg: cyl 0/ head 1/ sector 1;
end: cyl 1023/ head 1/ sector 63
The data for partition 2 is:
sysid 6 (0x06),(Primary 'big' DOS (>= 32MB))
start 8193150, size 867510 (423 Meg), flag 0
beg: cyl 1023/ head 255/ sector 63;
end: cyl 1023/ head 11/ sector 63
The data for partition 3 is:
sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD)
start 9060660, size 60548985 (29564 Meg), flag 0
beg: cyl 1023/ head 255/ sector 63;
end: cyl 1023/ head 2/ sector 63
The data for partition 4 is:
sysid 5 (0x05),(Extended DOS)
start 69609645, size 333959220 (163066 Meg), flag 0
beg: cyl 1023/ head 255/ sector 63;
end: cyl 1023/ head 14/ sector 63

So although both dmesg and fdisk identifies it as 484521/16/63, within
the same fdisk output you can read inconsistencies like:

cylinders=484521 heads=16 sectors/track=63 at the beginning AND
beg: cyl 1023/ head 255/ sector 63 later on.

If there are only 16 heads, how could a slice begin at head 255?

See, it is inconsistent with itself. FreeBSD fdisk is not really up to date.


Here is what the linux-fdisk port says:

cfdisk 2.11z

Disk Drive: /dev/ad0
Size: 250059350016 bytes, 250.0 GB
Heads: 255 Sectors per Track: 63 Cylinders: 30401

This is the real LBA geometry that is on my disk, so this one is correct.

> So far I've only partitioned the first 80GB of the disk in 3 slices but now
> I'd like to create the final slice so I can try out FreeBSD 6.1 without
> loosing my current 6.0 setup.

Well, the thing is, if you want you disk to be reliable, you have to
create any additional partition using the same geometry you have used to
create the existing ones. Whatever it is, you should use that geometry.
Now, I believe this would be the one that linux-cfdisk reports, but I
cannot be sure.

In general, using the same partitioning tool to create all your
partitions is a wise thing to do.
You can also use fdisk from FreeBSD sysinstall, and use the G key to
enter the geometry linux-cfdisk reports. This way you can set up your
initial FreeBSd partition using the same geometry you will use later.

Hope this helps!

Regards,
Keve

--
if you need to reply directly:
keve(at)mail(dot)poliod(dot)hu
From: Mike Clarke on
Keve Nagy wrote:

> Hi Mike,
> I have a Slot1 PIII/800 system, and I used a 160GB disk with it before I
> lately upgraded to a 250GB one. Both the 160 and 250 disks worked fine
> under FreeBSD 5.4, using approximately 160 and 250GB of space, so in my
> opinion you should not be limited to use your 160GB disk with your
> motherboard.

[snip]

Thanks for the very useful information, it's helped to give me confidence to
use the full 160 GB and the geometry returned by cfdisk-linux and suggested
by sysinstall

> Well, the thing is, if you want you disk to be reliable, you have to
> create any additional partition using the same geometry you have used to
> create the existing ones. Whatever it is, you should use that geometry.
> Now, I believe this would be the one that linux-cfdisk reports, but I
> cannot be sure.

That's the remaining worry. Due to my own carelessness I don't remember what
geometry I used for the initial install. What's the consequence of it not
being the same as the one I use now, am I likely to trash the existing
slices if it's wrong? If they're totally trashed then I'll know straight
away and restore from backups but is it likely to introduce inconsistencies
that don't show up for a while by which time recovery will be much more
tedious.

> In general, using the same partitioning tool to create all your
> partitions is a wise thing to do.

I'll certainly be doing that, the only other option would be Windows 98
fdisk and that gets totally confused by this size disk,

--
Mike Clarke
From: Keve Nagy on

> That's the remaining worry. Due to my own carelessness I don't remember what
> geometry I used for the initial install.

I had the same problem a while ago. The 1st O/S I installed to the disk
was FreeBSD. So whatever geometry it used, was the one I should use
later. But I didn't know what that geometry was.

Here is what you can do:
Run FreeBSD fdisk from the command line. If you only have this one disk,
you need no parameters. If you have multiple disks, you should give the
disk device name as the parameter.
Like: fdisk /dev/ad0

Read the output of fdisk, but ignore the first two block where it
displays the CHS geometry.
Look for partition "beg:" lines and see the head value! If any of those
is 255, you are almost certainly using the CHS geometry that
cfdisk-linux reports. SO that is the same geometry you are already
having on your disk, and you are safe to use that (and cfdisk-linux) to
create new partitions.
Otherwise your disk is likely using the geometry that fdisk and dmesg
reports. But usually this is not the case. Most of the time, it is what
I described above.

> What's the consequence of it not
> being the same as the one I use now, am I likely to trash the existing
> slices if it's wrong?

No, usually not.
It will work for some time, maybe even forever.
But sooner or later you will have read/write/fsck/etc issues.

Regards,
Keve

--
if you need to reply directly:
keve(at)mail(dot)poliod(dot)hu
From: Mike Clarke on
Keve Nagy wrote:

> I had the same problem a while ago. The 1st O/S I installed to the disk
> was FreeBSD. So whatever geometry it used, was the one I should use
> later. But I didn't know what that geometry was.
>
> Here is what you can do:
> Run FreeBSD fdisk from the command line. If you only have this one disk,
> you need no parameters. If you have multiple disks, you should give the
> disk device name as the parameter.
> Like: fdisk /dev/ad0
>
> Read the output of fdisk, but ignore the first two block where it
> displays the CHS geometry.
> Look for partition "beg:" lines and see the head value! If any of those
> is 255, you are almost certainly using the CHS geometry that
> cfdisk-linux reports. SO that is the same geometry you are already
> having on your disk, and you are safe to use that (and cfdisk-linux) to
> create new partitions.

I can't use cfdisk-linux to create partitions on my system, it always comes
up with "Opened disk read-only - you have no permission to write". Yes I am
running as root.

> Otherwise your disk is likely using the geometry that fdisk and dmesg
> reports. But usually this is not the case. Most of the time, it is what
> I described above.

Looks like I used the correct 255 head geometry considering I've got some
254's and 255's there:

kestrel:/root# fdisk
******* Working on device /dev/ad0 *******
parameters extracted from in-core disklabel are:
cylinders=76613 heads=16 sectors/track=255 (4080 blks/cyl)

Figures below won't work with BIOS for partitions not in cyl 1
parameters to be used for BIOS calculations are:
cylinders=76613 heads=16 sectors/track=255 (4080 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 11 (0x0b),(DOS or Windows 95 with 32 bit FAT)
start 63, size 15631182 (7632 Meg), flag 80 (active)
beg: cyl 0/ head 1/ sector 1;
end: cyl 972/ head 254/ sector 63
The data for partition 2 is:
sysid 15 (0x0f),(Extended DOS (LBA))
start 15631245, size 58605120 (28615 Meg), flag 0
beg: cyl 973/ head 0/ sector 1;
end: cyl 1023/ head 254/ sector 63
The data for partition 3 is:
sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD)
start 74236365, size 81915435 (39997 Meg), flag 0
beg: cyl 1023/ head 255/ sector 63;
end: cyl 1023/ head 254/ sector 63
The data for partition 4 is:
<UNUSED>

But slice 3 (the FreeBSD one) is a bit odd with a reported size of minus 1
sector for a 42 GB partition.

Things look better with cfdisk:

cfdisk 2.11z

Disk Drive: /dev/ad0
Size: 160041885696 bytes, 160.0 GB
Heads: 255 Sectors per Track: 63 Cylinders: 19457

Name Flags Part Type FS Type [Label] Size (MB)
-----------------------------------------------------------------------------------------
ad0p1 Boot Primary Win95 FAT32 8003.20
ad0p5 Logical Win95 FAT32 2155.03
ad0p6 Logical Win95 FAT32 8595.42
ad0p7 Logical Win95 FAT32 19255.39
ad0p3 Primary FreeBSD 41940.71
Primary Free Space 80089.56

.... but not without some inconsistencies:

kestrel:/root# cfdisk-linux -P t
Opened disk read-only - you have no permission to write
Partition Table for /dev/ad0

---Starting--- ----Ending---- Start Number of
# Flags Head Sect Cyl ID Head Sect Cyl Sector Sectors
-- ----- ---- ---- ---- ---- ---- ---- ---- -------- ---------
1 0x80 1 1 0 0x0B 254 63 972 63 15631182
2 0x00 0 1 973 0x0F 254 63 1023 15631245 58605120
3 0x00 254 63 1023 0xA5 254 63 1023 74236365 81915435
4 0x00 0 0 0 0x00 0 0 0 0 0
5 0x00 1 1 973 0x0B 254 63 1023 63 4208967
6 0x00 254 63 1023 0x0B 254 63 1023 63 16787862
7 0x00 254 63 1023 0x0B 254 63 1023 63 37608102

This shows p3 starting and ending at the same sector. The Windows logical
partitions have weird values but I don't think I've ever seen any fdisk
output where logical partition details made any sense to me (on both both
FreeBSD and Debian systems)

But the LBA geometry seems OK:

kestrel:/root# cfdisk-linux -P s
Opened disk read-only - you have no permission to write
Partition Table for /dev/ad0

First Last
# Type Sector Sector Offset Length Filesystem Type (ID) Flags
-- ------- -------- --------- ------ --------- ---------------------- ---------
1 Primary 0 15631244 63 15631245 Win95 FAT32 (0B) Boot
(80)
2 Primary 15631245 74236364 0 58605120 Win95 Ext'd (LBA) (0F) None
(00)
5 Logical 15631245 19840274 63 4209030 Win95 FAT32 (0B) None
(00)
6 Logical 19840275 36628199 63 16787925 Win95 FAT32 (0B) None
(00)
7 Logical 36628200 74236364 63 37608165 Win95 FAT32 (0B) None
(00)
3 Primary 74236365 156151799 0 81915435 FreeBSD (A5) None
(00)
Primary 156151800 312576704 0 156424905 Free Space None
(00)

The slices all fit together without any gaps and add up to the right values.

I initially partitioned the disk with sysinstall when I installed 6.0 and I
suspect some of the geometry might have subsequently been messed up when I
installed Windows and (probably) used Windows FDISK to create the logical
partitions. I see that fdisk says it gets its information from the DOS
bootblock which could account for the oddities.

>> What's the consequence of it not
>> being the same as the one I use now, am I likely to trash the existing
>> slices if it's wrong?
>
> No, usually not.
> It will work for some time, maybe even forever.
> But sooner or later you will have read/write/fsck/etc issues.

I think my best approach might be to go ahead with sysinstall to put 6.1
onto the 4th slice and hope it tidies up the geometry in the process. I'll
make extra backups so I can go back and start from scratch if things still
look dubious afterwards.

--
Mike Clarke