1 .\" $OpenBSD: fdisk.8,v 1.38 2002/01/04 21:20:56 kjell Exp $
3 .\" Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
5 .\" "Portions Copyright (c) 2002 Apple Computer, Inc. All Rights
6 .\" Reserved. This file contains Original Code and/or Modifications of
7 .\" Original Code as defined in and that are subject to the Apple Public
8 .\" Source License Version 1.2 (the 'License'). You may not use this file
9 .\" except in compliance with the License. Please obtain a copy of the
10 .\" License at http://www.apple.com/publicsource and read it before using
13 .\" The Original Code and all software distributed under the License are
14 .\" distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 .\" EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 .\" INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 .\" FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
18 .\" License for the specific language governing rights and limitations
19 .\" under the License."
21 .\" Copyright (c) 1997 Tobias Weingartner
22 .\" All rights reserved.
24 .\" Redistribution and use in source and binary forms, with or without
25 .\" modification, are permitted provided that the following conditions
27 .\" 1. Redistributions of source code must retain the above copyright
28 .\" notice, this list of conditions and the following disclaimer.
29 .\" 2. Redistributions in binary form must reproduce the above copyright
30 .\" notice, this list of conditions and the following disclaimer in the
31 .\" documentation and/or other materials provided with the distribution.
32 .\" 3. All advertising materials mentioning features or use of this software
33 .\" must display the following acknowledgement:
34 .\" This product includes software developed by Tobias Weingartner.
35 .\" 4. The name of the author may not be used to endorse or promote products
36 .\" derived from this software without specific prior written permission.
38 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
39 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
40 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
41 .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
42 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
43 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
44 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
45 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
46 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
47 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54 .Nd DOS partition maintenance program
66 In order for the BIOS to boot the kernel, certain conventions must be
68 Sector 0 of a bootable hard disk must contain boot code,
69 an MBR partition table, and a magic number (0xAA55).
70 These MBR partitions (also
71 known as BIOS partitions) can be used to break the disk up into several
74 The BIOS loads sector 0 of the boot disk into memory, verifies
75 the magic number, and begins executing the code at the first byte.
76 The normal DOS MBR boot code searches the MBR partition table for an
78 partition (indicated by a
80 in the first column), and if one
81 is found, the boot block from that partition is loaded and executed in
82 place of the original (MBR) boot block.
84 The options are as follows:
87 Initialize the MBR sector.
89 Specify an automatic partitioning style.
91 Edit existing MBR sectors.
93 Specifies an alternate MBR template file.
95 Update MBR code, preserving existing partition table.
97 Do not ask for confirmation before writing.
99 Dump partition table in a format readable by the -r option.
101 Read a partition table from the standard input.
103 Test if the disk is partitioned.
104 .It Xo Fl c Ar cylinders ,
108 Specifies an alternate BIOS geometry for
112 Specify the disk size in blocks.
114 Specify the number of bytes per disk block.
119 program can be used to divide space on the disk into partitions and set
123 program serves a similar purpose to the DOS program.
124 When called with no special flags, it prints the MBR partition
125 table of the specified device, i.e.,
128 Disk: fd0 geometry: 80/2/18 [2880 sectors]
129 Offset: 0 Signature: 0xAA55
131 #: id cyl hd sec - cyl hd sec [ start - size]
132 ----------------------------------------------------------------------
133 *1: A6 0 0 1 - 79 1 18 [ 0 - 2880] OpenBSD
134 2: 00 0 0 0 - 0 0 0 [ 0 - 0] unused
135 3: A7 0 0 2 - 79 1 18 [ 1 - 2879] NEXTSTEP
136 4: 00 0 0 0 - 0 0 0 [ 0 - 0] unused
139 The geometry displayed is a synthetic geometry unless another geometry
140 has been selected using the
150 will read the BIOS geometry from the IOKit registry.
153 the disk is divided into two partitions that happen to fill the disk.
154 The first partition overlaps the third partition.
155 (Used for debugging purposes.)
156 .Bl -tag -width "start/size"
158 Number of partition table entry.
161 denotes the bootable partition.
166 magic number 166 decimal (A6 in hex).
167 If no 166 partition is found, it will use an older
169 partition (with a magic number of 165 or A5 in hex).
171 These fields provide the starting and ending address of the partition
174 These fields provide the starting sector and size in sectors of the
175 partition in linear block addresses.
181 and the start field is
183 The CHS values may need to be in the BIOS's geometry
184 for older systems to be able to boot and use the drive correctly;
185 most modern systems prefer the starting sector and size
186 in preference to the CHS values.
190 flag is used to indicate that the partition data is to be initialized.
193 will completely overwrite the primary MBR and partition table, either
194 using the default MBR template, or the one specified by the
198 In the default template, partition number 1 will be configured as a
200 partition spanning from cylinder 0, head 1, sector 1, and extending
202 Partition number 2 will be configured as a
204 partition spanning the rest of the disk.
205 This mode is designed to initialize an MBR the very first time,
206 or when it has been corrupted beyond repair.
208 You can specify other default partition styles with the
210 flag. The available styles are:
211 .Bl -tag -width "start/size"
213 Creates an 8Mb boot partition (type AB hex)
214 and makes the rest of the disk
215 a Darwin HFS partition (type AF hex).
217 Makes the entire disk one HFS+ partition (type AF hex).
219 Makes the entire disk one DOS partition (type 0C hex).
221 Makes the entire disk one type AC hex partition.
226 flag is used to update the MBR code on a given drive.
227 The MBR code extends from offset 0x000 to the start of the partition table
231 flag, except the existing partition table is preserved. This
232 is useful for writing new MBR code onto an existing drive, and is
233 equivalent to the DOS command
235 Note that this option will overwrite the NT disk signature, if present.
240 flags may not be specified together.
244 is used to modify a partition table using a interactive edit mode of the
247 This mode is designed to allow you to change any partition on the
248 drive you choose, including extended partitions.
249 It is a very powerful mode,
250 but is safe as long as you do not execute the
252 command, or answer in the negative (the default) when
254 asks you about writing out changes.
256 When you first enter this mode, you are presented with a prompt, that looks
259 This prompt has two important pieces of information for you.
261 you if the in-memory copy of the boot block has been modified or not.
262 If it has been modified, the prompt will change to look like:
264 The second piece of information pertains to the number given in the prompt.
265 This number specifies the disk offset of the currently selected boot block
267 This number could be something different that zero when
268 you are editing extended partitions.
269 The list of commands and their explanations are given below.
270 .Bl -tag -width "update"
272 Display a list of commands that
274 understands in the interactive edit mode.
276 Display this manual page.
278 Initialize the currently selected, in-memory copy of the
281 Partition the disk with one of the automatic partition styles.
283 Display the current drive geometry that
287 You are given a chance to edit it if you wish.
289 Edit a given table entry in the memory copy of
290 the current boot block.
291 You may edit either in BIOS geometry mode,
292 or in sector offsets and sizes.
295 identifier of the given partition table entry.
296 This command is particularly useful for reassigning
297 an existing partition to OpenBSD.
299 Make the given partition table entry bootable.
300 Only one entry can be marked bootable.
301 If you wish to boot from an extended
302 partition, you will need to mark the partition table entry for the
303 extended partition as bootable.
305 Update the machine code in the memory copy of the currently selected
307 Note that this option will overwrite the NT disk
308 signature, if present.
310 Select and load into memory the boot block pointed
311 to by the extended partition table entry in the current boot block.
313 Print the currently selected in-memory copy of the boot
314 block and its MBR table to the terminal.
316 Write the in-memory copy of the boot block to disk.
317 You will be asked to confirm this operation.
319 Exit the current level of
321 either returning to the
322 previously selected in-memory copy of a boot block, or exiting the
323 program if there is none.
325 Exit the current level of
327 either returning to the
328 previously selected in-memory copy of a boot block, or exiting the
329 program if there is none.
332 it does write the modified block out.
334 Quit program without saving current changes.
337 The automatic calculation of starting cylinder etc. uses
338 a set of figures that represent what the BIOS thinks is the
339 geometry of the drive.
340 These figures are by default taken from the in-core disklabel, or
343 has passed to the kernel, but
345 gives you an opportunity to change them if there is a need to.
346 This allows the user to create a bootblock that can work with drives
347 that use geometry translation under a potentially different BIOS.
349 If you hand craft your disk layout,
350 please make sure that the
352 partition starts on a cylinder boundary.
353 (This restriction may be changed in the future.)
355 Editing an existing partition is risky, and may cause you to
356 lose all the data in that partition.
358 You should run this program interactively once or twice to see how it works.
359 This is completely safe as long as you answer the
364 .Bl -tag -width /usr/mdec/mbr -compact
374 detects that are not explained in this manual page.
375 As well, chances are that some of the subtleties it should detect are being