1TB USB drive incorrectly reports size

I have a Western Digital 1TB USB drive that came formatted for ntfs/Windows.

I reformatted the drive with systinstall to ufs but it gets the size wrong.

# df -h shows:

Code:
Filesystem   Size    Used     Avail    Capacity  Mounted on
/dev/da0s1   1.9G    635M     1.2G     35%       /media/disk

Yet Dolphin reports the drive size as 931.5 GiB which seems about right given that Sysinstall shows:
Code:
DISK Geometry:  121601 cyls/255 heads/63 sectors = 1953520065 sectors (953867MB)
                                                                               
Offset     Size(ST)    End        Name  PType Desc  Subtype Flags
                                                                               
0          63          62         -     12    unused    0           
63         1953520002  1953520064 da0s1  8    freebsd  165           
1953520065 5103        1953525167 -     12    unused   0

But fdisk looks wrong:
Code:
******* Working on device /dev/da0s1 *******
parameters extracted from in-core disklabel are:
cylinders=121600 heads=255 sectors/track=63 (16065 blks/cyl)

Figures below won't work with BIOS for partitions not in cyl 1
parameters to be used for BIOS calculations are:
cylinders=121600 heads=255 sectors/track=63 (16065 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:
<UNUSED>
The data for partition 2 is:
<UNUSED>
The data for partition 3 is:
<UNUSED>
The data for partition 4 is:
sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD)
    start 0, size 50000 (24 Meg), flag 80 (active)
        beg: cyl 0/ head 0/ sector 1;
        end: cyl 1023/ head 254/ sector 63

Compared to a 500GB spare drive I also have:
Code:
******* Working on device /dev/ad7 *******                                                                                                                   
parameters extracted from in-core disklabel are:                                                                                                             
cylinders=969021 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=969021 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 165 (0xa5),(FreeBSD/NetBSD/386BSD)
    start 63, size 976773105 (476939 Meg), flag 80 (active)
        beg: cyl 0/ head 1/ sector 1;
        end: cyl 1023/ head 15/ sector 63
The data for partition 2 is:
<UNUSED>
The data for partition 3 is:
<UNUSED>
The data for partition 4 is:
<UNUSED>

What's wrong?

...Jeff
 
fdisk(8), or more importantly sysinstall(8) may have limitations (& I am not up to speed on what all those may be). If you are only ever going to use this for FreeBSD as a ufs drive, use gpart(8). Something like:
Code:
# gpart delete da0s1
# gpart destroy da0
# gpart create -s gpt da0
# gpart add [red]-b 64[/red] -t freebsd-ufs da0
# newfs -U -L ufslabelname da0p1
# mount /dev/ufs/ufslabelname /media/disk

NB make sure you get the right device, cos these commands'll wipe stuff out.
Notes: the [red]-b 64[/red] above is to (hopefully) make sure you're aligned to 4k sectors (in case your drive is one of those that has them, but lies about it).
ufs labelnames (the [red]-L ufslabelname[/red]) are quite handy, and can be used instead of raw device names (which can change when you're using external drives).
Another option is to glabel(8) the device (/dev/da0p1 in this case) and then newfs(8) the entry under /dev/label/.
If after you newfs you find that the size is wrong still, you might have to increase the blocksize to something like -b 32768 (I don't recall what the maximum block size is, but I'm pretty sure you can go up to 65536).
 
A cursory glance at those commands seems they are
more complete than the man page for gpart, in this
instance at least. Maybe someone could put them up
in the "guides and howto" section...
 
Looking at the man pages for Gpart it seems it's something special for Apple file systems.

Since FBSD can handle 2TB+ drives, I shouldn't be having this problem. It's got to be staring me in the face. I have seen other people do it.

It must be something to do with the geometry just in comparing the 500GB internal drive and the 1000GB external drive fdisk outputs.
 
dejamuse said:
Looking at the man pages for Gpart it seems it's something special for Apple file systems.

No, but it does have support for Apple Partition Map (I guess to allow manipulation of such).

Since FBSD can handle 2TB+ drives, I shouldn't be having this problem. It's got to be staring me in the face. I have seen other people do it.

It must be something to do with the geometry just in comparing the 500GB internal drive and the 1000GB external drive fdisk outputs.

Well, you can try fdisk(8) from the command line. Again, be careful about device names and such:
Code:
# fdisk -I /dev/da0
# bsdlabel -w /dev/da0s1
# newfs -U -L externaldrive1 /dev/da0s1a
# mount /dev/ufs/externaldrive1 /mnt/disk
 
# fdisk -I /dev/da0

Got this error:

Code:
fdisk: Class not found
fdisk: Failed to write sector zero

What's really puzzling is that FBSD sees the drive as 931.5 GB but thinks it's full at 1.2GB.
 
dejamuse said:
# fdisk -I /dev/da0

Got this error:

fdisk: Class not found
fdisk: Failed to write sector zero

Probably have to disable the safety first:
# sysctl kern.geom.debugflags=16
 
Try the following:

Erase the first 1MB of the disk, destroying any MBR and existing partition information:
# dd if=/dev/zero of=/dev/da0 bs=1m count=1

Load the kernel module for the GEOM MBR class:
# kldload geom_mbr

Write a brand new MBR with a single slice covering the whole disk:
# fdisk -BI /dev/da0


If you are dedicating the disk for FreeBSD use, you don't really need to create an MBR slice. You can actually 'newfs' a raw disk device and avoid any partitioning.

Alternatively, use GPT partitioning as fronclynne suggested. It's not Apple specific, it's the partitioning scheme of the future on PC's and it's a lot cleaner and less mired in legacy than MBR partitioning is.
 
Well, executing this command and then rebuilding the partition in fdisk and label, solved the problem:

# dd if=/dev/zero of=/dev/da0 bs=1m count=1

There were evidently old partitions that didn't get wiped out via sysinstall.

Thanks for the tips!

BTW, I couldn't get # gpart delete da0s1 to work - got an error about the -i option not being specified.
 
dejamuse said:
BTW, I couldn't get # gpart delete da0s1 to work - got an error about the -i option not being specified.

Yes, that should have been # gpart delete -i 1 da0.
 
Back
Top