summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2005-04-30 07:05:32 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2005-04-30 07:05:32 +0000
commit3dbf6df7f07293d9f6f6152fd700eebb10899094 (patch)
tree45c3c1082507a145260b0489e9bcb65d4c935dfd
parentc0d23a2e7195c88d51bb24aad1e15835028e12ed (diff)
make this useable to people busy installing
-rw-r--r--sbin/fdisk/fdisk.8391
1 files changed, 212 insertions, 179 deletions
diff --git a/sbin/fdisk/fdisk.8 b/sbin/fdisk/fdisk.8
index dd7359acabf..b68ea6b0c7f 100644
--- a/sbin/fdisk/fdisk.8
+++ b/sbin/fdisk/fdisk.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: fdisk.8,v 1.45 2005/03/29 19:35:25 otto Exp $
+.\" $OpenBSD: fdisk.8,v 1.46 2005/04/30 07:05:31 deraadt Exp $
.\"
.\" Copyright (c) 1997 Tobias Weingartner
.\" All rights reserved.
@@ -28,7 +28,7 @@
.Os
.Sh NAME
.Nm fdisk
-.Nd DOS partition maintenance program
+.Nd MBR partition maintenance program
.Sh SYNOPSIS
.Nm fdisk
.Op Fl ieu
@@ -38,222 +38,277 @@
.Op Fl s Ar sectors
.Ar device
.Sh DESCRIPTION
-In order for the BIOS to boot the kernel, certain conventions must be
-adhered to.
-Sector 0 of a bootable hard disk must contain boot code,
-an MBR partition table, and a magic number (0xAA55).
-These MBR partitions (also
-known as BIOS partitions) can be used to break the disk up into several
-pieces.
+On the i386 and other architectures, sector 0 of a bootable hard disk
+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.
.Pp
-The BIOS loads sector 0 of the boot disk into memory, verifies
-the magic number, and begins executing the code at the first byte.
-The normal DOS MBR boot code searches the MBR partition table for an
+On the i386, the BIOS loads sector 0 of the boot disk into memory,
+verifies the magic number, and begins executing the MBR bootcode
+at the first byte.
+The MBR bootcode then searches the MBR partition table for an
.Dq active
-partition (indicated by a
+MBR partition (indicated by a
.Ql \&*
in the first column), and if one
-is found, the boot block from that partition is loaded and executed in
+is found, the boot block from that MBR partition is loaded and executed in
place of the original (MBR) boot block.
.Pp
-The options are as follows:
-.Bl -tag -width Ds
-.It Fl i
-Initialize the MBR sector.
-.It Fl e
-Edit existing MBR sectors.
-.It Fl f Ar mbrname
-Specifies an alternate MBR template file.
-.It Fl u
-Update MBR code, preserving existing partition table.
-.It Xo Fl c Ar cylinders ,
-.Fl h Ar heads ,
-.Fl s Ar sectors
-.Xc
-Specifies an alternate BIOS geometry for
-.Nm
-to use.
-.El
+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.
.Pp
-The DOS
+.Sh TYPICAL LAYOUT
+When called with no special flags,
.Nm
-program can be used to divide space on the disk into partitions and set
-one active.
-This
-.Nm
-program serves a similar purpose to the DOS program.
-When called with no special flags, it prints the MBR partition
-table of the specified device, i.e.,
+prints the MBR partition table of the specified device, i.e.,
.Bd -literal
- # fdisk fd0
- Disk: fd0 geometry: 80/2/18 [2880 sectors]
- Offset: 0 Signature: 0xAA55
- Starting Ending
- #: id cyl hd sec - cyl hd sec [ start - size]
- ----------------------------------------------------------------------
- *0: A6 0 0 1 - 79 1 18 [ 0 - 2880] OpenBSD
- 1: 00 0 0 0 - 0 0 0 [ 0 - 0] unused
- 2: A7 0 0 2 - 79 1 18 [ 1 - 2879] NEXTSTEP
- 3: 00 0 0 0 - 0 0 0 [ 0 - 0] unused
+ # 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 - 169 239 63 [ 63: 2570337 ] 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
.Ed
.Pp
-The geometry displayed is the BIOS geometry unless another geometry
-has been selected using the
-.Fl c ,
-.Fl h ,
-and
-.Fl s
-options.
+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:
.Pp
-This disk is divided into two partitions that happen to fill the disk.
-The first partition overlaps the third partition.
-(Used for debugging purposes.)
.Bl -tag -width "start/size"
.It Em "#"
-Number of partition table entry.
-A
+Number identifying each MBR partition table entry.
+There are a total of four slots.
.Dq \&*
-denotes the bootable partition.
+denotes the MBR partition which is declared bootable.
.It Em "id"
-System identifier.
+MBR partition type identifier.
.Ox
reserves the
-magic number 166 decimal (A6 in hex).
-If no 166 partition is found, it will use an older
+magic number hexadecimal A6 (166 decimal).
+If no A6 MBR partition is found,
+.Ox
+can use an older
.Fx
-partition (with a magic number of 165 or A5 in hex).
+MBR partition (with a magic number of hexadecimal A5).
.It Em "cyl/hd/sec"
-These fields provide the starting and ending address of the partition
+These fields provide the starting and ending address of the MBR partition
in BIOS geometry.
.It Em "start/size"
These fields provide the starting sector and size in sectors of the
-partition in linear block addresses.
+MBR partition in linear block addresses.
.El
.Pp
.Em NOTE :
-The sectors field is
+The BIOS geometry sectors field is
.Dq 1 based ,
-and the start field is
+but the start field is
.Dq 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 syncronized or a variety of
+problems develop which are very difficult to diagnose.
.Pp
-The
-.Fl i
-flag is used to indicate that the partition data is to be initialized.
+The OpenBSD MBR partition shown above is subdivided further using the
+functionality provided by
+.Xr disklabel 8 Ns ,
+which provides
+.Ox
+partitions.
+.Bd -literal
+ # using MBR partition 3: type A6 off 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: 2570337 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
+.Ed
+.Pp
+These
+.Ox
+partitions are then mounted as follows using
+.Pa /etc/fstab Ns :
+.Bd -literal
+ /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
+.Ed
+.Pp
+.Sh OPTIONS
+The options are as follows:
+.Bl -tag -width Ds
+.It Xo Fl c Ar cylinders ,
+.Fl h Ar heads ,
+.Fl s Ar sectors
+.Xc
+Specifies an alternate BIOS geometry for
+.Nm
+to use.
+By default, an automatic calculation of disk size will be built
+using heuristics.
+These figures are taken from the in-core disklabel
+(see
+.Xr disklabel 8 Ns ),
+or values that
+.Em /boot
+has passed to the kernel.
+.It Fl e
+Use the interactive edit of
+.Nm
+to modify a MBR partition table.
+The editor permits configuration of the MBR partition, as well as
+extended MBR partitions.
+.It Fl f Ar mbrname
+Specifies an alternate MBR template file.
+The default file is
+.Pa /usr/mdec/mbr .
+.It Fl i
+Requests that the MBR partition data be re-initialized.
In this mode,
.Nm
-will completely overwrite the primary MBR and partition table, either
-using the default MBR template, or the one specified by the
+will completely overwrite the primary MBR bootcode and MBR partition table
+using the default MBR template
+.Pa /usr/mdec/mbr
+(or the one optionally specified by the
.Fl f
-flag.
-In the default template, partition number 3 will be configured as an
+flag).
+In the default template, MBR partition number 3 will be configured as an
.Ox
-partition spanning from cylinder 0, head 1, sector 1, and extending
+MBR partition spanning from cylinder 0, head 1, sector 1, and extending
to the end of the disk.
-This mode is designed to initialize an MBR the very first time,
-or when it has been corrupted beyond repair.
-.Pp
-The
-.Fl u
-flag is used to update the MBR code on a given drive.
-The MBR code extends from offset 0x000 to the start of the partition table
+This mode is designed to initialize the MBR the very first time.
+.It Fl 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
.Fl i
-flag, except the existing partition table is preserved.
-This is useful for writing new MBR code onto an existing drive, and is
+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
.Dq FDISK /MBR .
Note that this option will overwrite the NT disk signature, if present.
+.El
.Pp
+.Sh COMMAND MODE
The
.Fl e
-flag is used to modify a partition table using an
-interactive edit mode of the
-.Nm
-program.
-This mode is designed to allow you to change any partition on the
-drive you choose, including extended partitions.
-It is a very powerful mode,
-but is safe as long as you do not execute the
-.Em write
-command, or answer in the negative (the default) when
+flag causes
.Nm
-asks you about writing out changes.
-.Sh COMMAND MODE
-When you first enter this mode, you are presented with a prompt, that looks
-like so:
-.Em "fdisk: 0>" .
-This prompt has two important pieces of information for you.
-It will tell
-you if the in-memory copy of the boot block has been modified or not.
-If it has been modified, the prompt will change to look like:
-.Em "fdisk:*0>" .
-The second piece of information pertains to the number given in the prompt.
-This number specifies the disk offset of the currently selected boot block
-you are editing.
-This number could be something other than zero when
-you are editing extended partitions.
+to enter an interactive command mode.
+The prompt contains information about the state of the edit
+process.
+.Bd -literal
+ fdisk:*0>
+.Ed
+.Pp
+* means that the in-memory copy of the boot block has been modified, but
+not yet written to disk.
+.Pp
+0 is the disk offset of the currently selected boot block being edited.
+This number could be something other than zero when extended MBR partitions
+are being edited (using the
+.Em select
+subcommand).
+.Pp
The list of commands and their explanations are given below.
-.Bl -tag -width "update"
-.It Em help
+.Bl -tag -width Ds
+.It help
Display a list of commands that
.Nm
understands in the interactive edit mode.
-.It Em manual
+.It manual
Display this manual page.
-.It Em reinit
+.It reinit
Initialize the currently selected, in-memory copy of the
boot block.
-.It Em disk
+.It disk
Display the current drive geometry that
.Nm
-has
-probed.
-You are given a chance to edit it if you wish.
-.It Em edit
+probed using kernel provided information and various heuristics.
+The disk geometry may be changed at this point.
+.It edit Ar #
Edit a given table entry in the memory copy of
the current boot block.
-You may edit either in BIOS geometry mode,
-or in sector offsets and sizes.
-.It Em setpid
-Change the partition
-identifier of the given partition table entry.
-This command is particularly useful for reassigning
-an existing partition to
-.Ox .
-.It Em flag
-Make the given partition table entry bootable.
+Sizes may be adjusted using either in BIOS geometry mode or
+sector offsets and sizes.
+.It flag Ar #
+Make the given MBR partition table entry bootable.
Only one entry can be marked bootable.
-If you wish to boot from an extended
-partition, you will need to mark the partition table entry for the
-extended partition as bootable.
-If an optional value is given, the partition is marked with the given
-value, and other partitions are not touched.
-.It Em update
-Update the machine code and 0xAA55 signature in the memory copy
+.\" If you wish to boot from an extended
+.\" MBR partition, you will need to mark the MBR partition table entry for the
+.\" extended MBR partition as bootable.
+.\" If an optional value is given, the MBR partition is marked with the given
+.\" value, and other MBR partitions are not touched.
+.It 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 the NT disk
signature, if present.
-.It Em swap
-Swap two MBR entries.
-.It Em select
+.It select Ar #
Select and load into memory the boot block pointed
-to by the extended partition table entry in the current boot block.
-.It Em print
+to by the extended MBR partition table entry in the current boot block.
+.It setpid Ar #
+Change the MBR partition
+identifier of the given MBR partition table entry.
+This command is particularly useful for reassigning
+an existing MBR partition to
+.Ox .
+.It swap Ar # Ar #
+Swap two MBR entries.
+.It print
Print the currently selected in-memory copy of the boot
block and its MBR table to the terminal.
-.It Em write
+.It write
Write the in-memory copy of the boot block to disk.
-You will be asked to confirm this operation.
-.It Em exit
+.It exit
Exit the current level of
.Nm fdisk ,
either returning to the
previously selected in-memory copy of a boot block, or exiting the
program if there is none.
-.It Em quit
+.It quit
Exit the current level of
.Nm fdisk ,
either returning to the
@@ -262,48 +317,26 @@ program if there is none.
Unlike
.Em exit
it does write the modified block out.
-.It Em abort
+.It abort
Quit program without saving current changes.
.El
.Sh NOTES
-The automatic calculation of starting cylinder etc. uses
-a set of figures that represent what the BIOS thinks is the
-geometry of the drive.
-These figures are by default taken from the in-core disklabel, or
-values that
-.Em /boot
-has passed to the kernel, but
-.Nm
-gives you an opportunity to change them if there is a need to.
-This allows the user to create a bootblock that can work with drives
-that use geometry translation under a potentially different BIOS.
.Pp
-If you hand craft your disk layout,
-please make sure that the
+Hand crafted disk layouts can be highly error prone;
+ensure that
.Ox
-partition starts on a cylinder boundary.
+MBR partition starts on a cylinder boundary.
(This restriction may be changed in the future.)
-.Pp
-Editing an existing partition is risky, and may cause you to
-lose all the data in that partition.
-.Pp
-You should run this program interactively once or twice to see how it works.
-This is completely safe as long as you answer the
-.Dq write
-questions in the
-negative.
.Sh FILES
.Bl -tag -width /usr/mdec/mbr -compact
.It Pa /usr/mdec/mbr
default MBR template
.El
.Sh SEE ALSO
+.Xr boot_alpha 8 ,
+.Xr boot_amd64 8 ,
+.Xr boot_cats 8 ,
.Xr boot_i386 8 ,
+.Xr boot_macppc 8 ,
+.Xr boot_zaurus 8 ,
.Xr disklabel 8
-.Sh BUGS
-There are subtleties
-.Nm
-detects that are not explained in this manual page.
-As well, chances are that some of the subtleties it should detect are being
-steamrolled.
-Caveat Emptor.