FDISK(8) BSD System Manager's Manual FDISK(8)
fdisk - MBR partition maintenance programme
fdisk [-ieu] [-c cylinders -h heads -s sectors] [-f mbrfile] device
On the i386 and other architectures, sector 0 of a bootable hard disc must contain MBR bootcode, the MBR partition table containing 4 slots, and a specific magic number (0xAA55). The 4 slots in the MBR partition table allow a disk drive to be sub-divided up into chunks known as MBR partitions. On the i386, the BIOS loads sector 0 of the boot disk into memory, veri- fies the magic number, and begins executing the MBR bootcode at the first byte. The MBR bootcode then searches the MBR partition table for an "active" MBR partition (indicated by a '*' in the first column), and if one is found, the boot block from that MBR partition is loaded and exe- cuted in place of the original (MBR) boot block. Some other architectures (like the zaurus), consider sector 0 of the disk to contain the MBR partition table, but do not use the MBR bootcode at all.
When called with no special flags, fdisk prints the MBR partition table of the specified device, i.e., # fdisk wd0 Disk: wd0 geometry: 5168/240/63 [78140160 Sectors] Offset: 0 Signature: 0xAA55 Starting Ending LBA Info: #: id C H S - C H S [ start: size ] ------------------------------------------------------------------------ 0: 04 0 1 1 - 170 0 63 [ 63: 2570462 ] DOS FAT-16 1: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused 2: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused *3: A6 170 1 1 - 5167 239 63 [ 2570463: 75569697 ] OpenBSD It should be noted that the partition table shown above is invalid and a bad idea in general. This 78140160 sector (38154MB) disk drive is divided into two MBR partitions that span the whole disk. The first MBR partition is a 1225MB FAT-16 DOS partition (in this case containing a Phoenix BIOS Laptop Suspend-to-Disk file), the second is a 36GB OpenBSD MBR partition using the remainder of the disk. The fields of the output are thus: # Number identifying each MBR partition table entry. There are a total of four slots. '*' denotes the MBR partition which is declared bootable. id MBR partition type identifier. MirOS reserves the magic number hexadecimal 27 (39 decimal). If no MBR partition of type 27 is found, MirOS can use an older OpenBSD, NetBSD or FreeBSD MBR partition (with type 0xA6, 0xA9 and 0xA5, respec- tively). C/H/S These fields provide the starting and ending address of the MBR partition in BIOS geometry. start/size These fields provide the starting sector and size in sectors of the MBR partition in linear block addresses. NOTE: The BIOS geometry sectors field is "1 based", but the start field is "0 based". The CHS values will need to be in the BIOS's geometry for the system to be able to boot and use the drive correctly. These values must be kept correctly synchronized or a variety of problems develop which are very difficult to diagnose. The OpenBSD MBR partition shown above is subdivided further using the functionality provided by disklabel(8), which provides MirOS slices. # Inside MBR partition 3: type A6 start 2570463 size 75569697 # /dev/rwd0c: type: ESDI disk: ESDI/IDE disk label: HITACHI_DK13FA-4 flags: bytes/sector: 512 sectors/track: 63 tracks/cylinder: 16 sectors/cylinder: 1008 cylinders: 16383 total sectors: 78140160 rpm: 3600 interleave: 1 trackskew: 0 cylinderskew: 0 headswitch: 0 # microseconds track-to-track seek: 0 # microseconds drivedata: 0 16 partitions: # size offset fstype [fsize bsize cpg] a: 1740753 2570463 4.2BSD 2048 16384 328 # Cyl 2550*- 4276 b: 819504 4311216 swap # Cyl 4277 - 5089 c: 78140160 0 unused 0 0 # Cyl 0 - 77519 d: 2097648 5130720 4.2BSD 2048 16384 328 # Cyl 5090 - 7170 e: 614880 7228368 4.2BSD 2048 16384 328 # Cyl 7171 - 7780 g: 2097648 7843248 4.2BSD 2048 16384 328 # Cyl 7781 - 9861 h: 921312 9940896 4.2BSD 2048 16384 328 # Cyl 9862 - 10775 i: 2570462 63 MSDOS # Cyl 0*- 2549 j: 3355632 10862208 4.2BSD 2048 16384 328 # Cyl 10776 - 14104 k: 2097648 14217840 4.2BSD 2048 16384 328 # Cyl 14105 - 16185 l: 2097648 16315488 4.2BSD 2048 16384 328 # Cyl 16186 - 18266 m: 59727024 18413136 4.2BSD 2048 16384 328 # Cyl 18267 - 77519 These MirOS filesystems are then mounted as follows using /etc/fstab: /dev/wd0a / ffs rw,softdep 1 1 /dev/wd0m /home ffs rw,softdep,nodev,nosuid 1 2 /dev/wd0d /tmp ffs rw,softdep,nodev,nosuid 1 2 /dev/wd0g /usr ffs rw,softdep,nodev 1 2 /dev/wd0h /usr/X11R6 ffs rw,softdep,nodev 1 2 /dev/wd0j /usr/local ffs rw,softdep,nodev 1 2 /dev/wd0k /usr/obj ffs rw,softdep,nodev,nosuid 1 2 /dev/wd0l /usr/src ffs rw,softdep,nodev,nosuid 1 2 /dev/wd0e /var ffs rw,softdep,nodev,nosuid 1 2
The options are as follows: -c cylinders, -h heads, -s sectors Specifies an alternate BIOS geometry for fdisk to use. By de- fault, an automatic calculation of disk size will be built using heuristics. These figures are taken from the in-core disklabel (see disklabel(8)), or values that /boot has passed to the ker- nel. -e Use the interactive edit of fdisk to modify a MBR partition table. The editor permits configuration of the MBR partition, as well as extended MBR partitions. -f mbrfile Specifies an alternate MBR template file. The default file is /usr/mdec/mbr. -i Requests that the MBR partition data be re-initialized. In this mode, fdisk will completely overwrite the primary MBR bootcode and MBR partition table using the default MBR template /usr/mdec/mbr (or the one optionally specified by the -f flag). In the default template, MBR partition number 3 will be config- ured as an MirOS MBR partition spanning from cylinder 0, head 1, sector 1, and extending to the end of the disk. This mode is designed to initialize the MBR the very first time. -u Update MBR bootcode, preserving existing MBR partition table. The MBR bootcode extends from offset 0x000 to the start of the MBR partition table at offset 0x1BE. It is similar to the -i flag, except the existing MBR partition table is preserved. This is useful for writing new MBR bootcode onto an existing drive, and is equivalent to the DOS command "FDISK /MBR". Note that this op- tion will overwrite the NT disk signature, if present. If you would like to preserve the NT disk signature, you can use the umin command in the interactive command mode. Just be damn sure you use a boot code which supports this.
The -e flag causes fdisk to enter an interactive command mode. The prompt contains information about the state of the edit process. fdisk:*0> '*' means that the in-memory copy of the boot block has been modified, but not yet written to disk. 0 is the disk offset of the currently selected boot block being edited. This number could be something other than zero when extended MBR parti- tions are being edited (using the select subcommand). The list of commands and their explanations are given below. help Display a list of commands that fdisk understands in the interac- tive edit mode. manual Display this manual page. reinit Initialize the currently selected, in-memory copy of the boot block. disk Display the current drive geometry that fdisk probed using kernel provided information and various heuristics. The disk geometry may be changed at this point. edit # Edit a given table entry in the memory copy of the current boot block. Sizes may be adjusted using either in BIOS geometry mode or sector offsets and sizes. fdef # Make the given partition table entry bootable. This does only work with the MirOS boot blocks. This is not the same as the flag command, which If an optional value is given, the partition is marked with the given value, and other partitions are not touched. Attention: This command should only be used by people who know what they are doing. This command can destroy third par- ty bootblocks. To disable the functionality after it has been en- abled, use the number 9 as parameter. is commonly used to mark the default entry, too. flag # Make the given MBR partition table entry bootable. Only one entry can be marked bootable. If no default entry has been selected with fdef, or an older, for example from MirOS #7, or non-MirOS bootblock is used, this entry will be the default booted entry as well. update Update the machine MBR bootcode and 0xAA55 signature in the memory copy of the currently selected boot block. Note that this option will overwrite an NT disk signature, if present. This op- tion will also revert the fdef choice to unset, if you use recent MirOS boot code. umin This option performs basically the same operation as the update command, but leaving the last part of the machine boot code, which contains the Microsoft NT disk signature and, shortly be- fore, the fdef flag, untouched. If you do not use recent MirOS boot code which supports this, your hard disc will be left un- bootable because this option cuts off the end of the machine code, possibly containing instructions. select # Select and load into memory the boot block pointed to by the ex- tended MBR partition table entry in the current boot block. setpid # Change the MBR partition identifier of the given MBR partition table entry. This command is particularly useful for reassigning an existing MBR partition to MirOS. swap # # Swap two MBR entries. print [unit] Print the currently selected in-memory copy of the boot block and its MBR table to the terminal. If unit is specified as 'b', 'k', 'm', or 'g', the MBR is printed in units of bytes, kibibytes, me- bibytes, or gibibytes. Otherwise the number of sectors is print- ed. write Write the in-memory copy of the boot block to disk. exit Exit the current level of fdisk, either returning to the previ- ously selected in-memory copy of a boot block, or exiting the program if there is none. quit Exit the current level of fdisk, either returning to the previ- ously selected in-memory copy of a boot block, or exiting the program if there is none. Unlike exit it does write the modified block out. abort Quit program without saving current changes.
/usr/mdec/mbrmgr default MBR template
fstab(5), boot_i386(8), disklabel(8)
Hand crafted disk layouts are highly error prone. MBR partitions should start on a cylinder boundary (head 0, sector 1), except when starting on track 0, (these should begin at head 1, sector 1). MBR partitions should also end at cylinder boundaries. MirOS BSD #10-current January 3, 2002 3
Generated on 2017-04-03 16:26:17 by $MirOS: src/scripts/roff2htm,v 1.88 2017/01/29 00:51:06 tg Exp $
These manual pages and other documentation are copyrighted by their respective writers;
their source is available at our CVSweb,
AnonCVS, and other mirrors. The rest is Copyright © 2002–2017 The MirOS Project, Germany.
This product includes material provided by mirabilos.
This manual page’s HTML representation is supposed to be valid XHTML/1.1; if not, please send a bug report — diffs preferred.