fdisk [-afiuvBFS] [-0 | -1 | -2 | -3]
[-t disktab] [-T disktype] [-E number] [-b cylinders/heads/sectors] [-s id/start/size[/bootmenu]] [-c bootcode] [-r|w file] [device]
Used to divide space on a disk into partitions and set one active. There can be at most 4 partitions defined in sector 0, one of which can be an extended partition which can be split into any number of sub-partitions.
NetBSD does not use the partitioning done by
fdisk, instead it uses a
NetBSD disklabel saved in sector 1 of the NetBSD partition.
The standard MBR boot code will only boot the `active' partition. How- ever NetBSD contains two alternate boot programs which allow the user to interactively select which of the partitions to boot. The `mbr_ext' code will boot NetBSD from an extended partition but will not work on old sys- tems that do not support LBA reads.
At the start
fdisk will determine whether the disk sector 0
is valid as a boot sector. (This is determined by checking the magic
number.) If not,
fdisk will initialise the boot code as well as the par-
tition table. During this, all four partitions will be marked empty.
-u are used to indicate that the partition data is to
be updated. The
fdisk program will enter an interactive conversational
mode. This mode is designed not to change any data unless you explicitly
tell it to;
fdisk selects defaults for its questions to guarantee that
fdisk will calculate the correct cylinder, head, and sector values for
any partition you edit. If you specify
-v you will be asked whether you
want to specify them
When all the data for the first sector has been accumulated,
fdisk will ask if you really want to write the new partition table. Only
if you reply affirmatively to this question will
fdisk write anything to the disk.
Disk: /dev/rwd0d NetBSD disklabel disk geometry: cylinders: 16383, heads: 16, sectors/track: 63 (1008 sectors/cylinder) total sectors: 40032696 BIOS disk geometry: cylinders: 1023, heads: 255, sectors/track: 63 (16065 sectors/cylinder) total sectors: 40032696 Partition table: 0: NetBSD (sysid 169) bootmenu: net 1.5. start 4209030, size 8289540 (4048 MB, Cyls 262-778), Active 1: Primary DOS with 32 bit FAT (sysid 11) bootmenu: win98 start 63, size 4208967 (2055 MB, Cyls 0-262) 2: NetBSD (sysid 169) bootmenu: current start 32515560, size 7517136 (3670 MB, Cyls 2024-2491/234/40) 3: Ext. partition - LBA (sysid 15) start 12498570, size 20016990 (9774 MB, Cyls 778-2024) Extended partition table: E0: NetBSD (sysid 169) bootmenu: test start 12498633, size 12305727 (6009 MB, Cyls 778-1544) E1: Primary DOS with 32 bit FAT (sysid 11) start 24804423, size 4096512 (2000 MB, Cyls 1544-1799) E2: Primary DOS with 32 bit FAT (sysid 11) start 28900998, size 3614562 (1765 MB, Cyls 1799-2024) Bootselector enabled, infinite timeout.This example disk is divided into four partitions the last of which is an extended partition. The sub-partitions of the extended partition are also shown. In this case there is no free space in either the disk or in the extended partition.
The various fields in each partition entry are: ptn_number: id_name (sysid id_number) bootmenu: bootmenu start start, size size (MB MB, Cyls first-next) [, Active]
ptn_number is the number of the partition. id_name is the name of the filesystem type or operating system that uses this partition.
is the number that identifies the partition type. 169 decimal
is used for NetBSD partitions, 15 decimal to create an extended
partition and 0 to mark a partition as unused. Use
list the known partition types.
bootmenu is the menu prompt output by the interactive boot code for this partition. This line is omitted if the prompt is not defined.
start, size are the start address and size of the partition in sectors.
MB is the size of the partition in megabytes.
are the bounds of this partition displayed as cylin-
der/head/sector. If the partition starts (or ends) on a cylin-
der boundary the head and sector values are omitted. If
not specified the start of extended partitions and the first
partition on the disk are rounded down to include the mandatory
red tape in the preceding track.
Active is output if this is the active partition.
-v flag is given two additional lines are output for each parti-
beg: cylinder cylinder, head head, sector sector
end: cylinder cylinder, head head, sector sector
cylinder, head, sector
are the beginning or ending address of a partition.
Note: these numbers are read from the bootblock, so are the
values calculated by a previous run of
This program is only available (and useful) on systems with PC-platform-
style MBR partitioning. On NetBSD this includes the following ports:
amd64, arc, bebox, cobalt, hpcarm, hpcmips, hpcsh, i386, macppc, mvmeppc,
netwinder, ofppc, playstation2, and prep.
Traditionally the partition boundaries should be on cylinder boundaries using the BIOS geometry, all of the first track should be reserved for use by the BIOS. Although the BIOS geometry is typically different from the geometry reported by the drive, neither will match the actual physi- cal geometry for modern disks (the actual geometry will vary across the disk). Keeping the partition boundaries on cylinder boundaries makes partitioning a driver easier as only relatively small numbers need be entered.
The automatic calculation of the starting cylinder and other parameters
uses a set of figures that represent what the BIOS thinks is the geometry
of the drive. The default values should be correct for the system on
fdisk is run, however if you move the disk to a different system
the BIOS of that system might use a different geometry translation.
If you run the equivalent of
fdisk on a different operating system then
the bootmenu strings associated with extended partitions may be lost.
Editing an existing partition is risky, and may cause you to lose all the data in that partition.
You should run this program interactively once or twice to see how it
works. This is completely safe as long as you answer the last question
in the negative. You can also specify
-w file to write the output to a
file and later specify
-r file to read back the updated information.
This can be done without having write access to the disk volume.
/usr/mdec/mbrDefault location of i386 bootcode
/usr/mdec/mbr_bootselDefault location of i386 bootselect code
/usr/mdec/mbr_extDefault location of i386 bootselect for extended partitions
WARNING The word `partition' is used to mean both an MBR partition and a NetBSD partition, sometimes in the same sentence.
There are subtleties that the program detects that are not explained in this manual page.