Is fdisk broken?
brde at optusnet.com.au
Fri Mar 22 16:51:27 UTC 2013
On Fri, 22 Mar 2013 mla_strick at att.net wrote:
> I recently bought a 4 TB usb disk drive and discovered that it reported
> a sector size of 4096 bytes instead of the traditional 512 bytes. This
> is apparently necessary because there may be a 32 bit sector number field
> somewhere in the usb mass storage protocols. It turns out that disk
> drive manufacturers have been producing disks with large sector sizes
> for some years now. The feature goes by the name "Advanced Format" and
> other things. Look it up in Wikipedia.
> FreeBSD seems to use the sector size information when interpreting MBR
> partition offsets and sizes. Unfortunately, when I try to use fdisk to
> print out the partition table on my new disk drive, fdisk just says
> "fdisk: could not detect sector size".
It has the following gratuitous breakage at 2K for its probe of the
#define MAX_SEC_SIZE 2048 /* maximum section size that is supported */
#define MIN_SEC_SIZE 512 /* the sector size to start sensing at */
I used 64K for the probe maximum limit when I fixed fsck_msdosfs
(fsck_msdosfs doesn't has a probe and only supports sector sizes of
512 in -current).
Most file systems in FreeBSD have gratuitous limits on the size in their
probe for there superblock, but the limit is mostly larger than 4K.
Most of them don't need to know the sector size and don't have a probe,
but they read a fixed size that is larger than their superblock size,
so they fail if this size is smaller than the the sector size.
> Otherwise the MBR partition
> table seems to work correctly and newfs seems to have done the right
> thing. (It made the file system fragment size a multiple of the sector
> size and I am not getting any weird error messages out of the disk
> driver.) It would be nice if fdisk also worked. I do have to share
> the disk with other operating systems that might not understand other
> partition table schemes.
> Is may analysis of what is going on essentially correct?
> Can fdisk be made happy again? (At least for a few more years?)
Changing the above should fix fdisk for FreeBSD. A sector size of
4K gives a limit of 16TB for the partition table data structure,
which is enough for a few more years with single disks. After that,
double the sector size to 8K to work for another year or two.
However, to share the disk you need all the other operating systems and
BIOS to agree that _this_ partition table scheme (with units of 4K
sectors) is what the partition table records.
More information about the freebsd-questions