1 .\" $FreeBSD: src/sbin/i386/fdisk/fdisk.8,v 1.17.2.11 2002/04/25 16:25:12 trhodes Exp $
2 .\" $DragonFly: src/sbin/i386/fdisk/fdisk.8,v 1.17 2008/09/01 20:13:32 thomas Exp $
9 .Nd PC slice table (MBR) maintenance program
22 In order for the BIOS to boot the kernel,
23 certain conventions must be adhered to.
24 Sector 0 of the disk must contain an MBR, which contain boot code,
27 BIOS slices can be used to break the disk up into several pieces.
29 slices are called partitions under DOS
31 has another meaning under
36 supports 30 MBR slices, s1-s4 will be DOS primary partitions,
37 s5-s30 will be DOS partitions in extended DOS partitions.
38 The BIOS brings in sector 0 and verifies the magic number.
40 0 boot code then searches the slice table to determine which
43 This boot code then brings in the bootstrap from the
45 slice and, if marked bootable, runs it.
47 you can have one or more slices with one
51 program can be used to divide space on the disk into slices and set one
58 serves a similar purpose to the DOS program.
59 The first form is used to
60 display slice information or to interactively edit the slice table.
61 The second is used to write a slice table using a
63 and is designed to be used by other scripts/programs.
66 .Bl -tag -width indent
68 Change the active slice only.
73 Get the boot code from the file
78 The disk image is specified as a normal file instead of as a device,
79 which is useful when building emulated disks for vmware, bochs, etc.\&
81 Reinitialize the boot code contained in sector 0 of the disk.
86 Set CHS fields to wrapped values.
87 Normally the CHS fields for a slice are set to all 1's if they
89 This typically causes BIOSes to properly detect
90 that the disk should be put in Large mode.
91 This option may be needed on very old PCs.
92 .It Fl f Ar configfile
93 Set slice values using the file
97 always modifies existing slices, unless
99 is also given, in which case all existing slices are deleted (marked
113 .Sx CONFIGURATION FILE ,
114 below, for file syntax.
119 is used, you are not asked if you really want to write the slices
120 table (as you are in the interactive mode).
123 Initialize sector 0 of the disk.
130 Initialize the contents of sector 0
133 slice covering the entire disk.
135 Print a summary of all slices on the disk and exit.
136 All other options will be ignored.
138 Test mode; do not write slice values.
139 Generally used with the
141 option to see what would be written to the slice table.
145 Is used for updating (editing) sector 0 of the disk.
155 prints out the slice table that is written to the disk.
157 Operate on a single fdisk entry only.
163 The final disk name can be provided as a
165 disk name only, e.g.\&
167 or as a fully qualified device node under
169 If omitted, the disks
174 are searched in that order, until one is found to respond.
176 When called without options,
178 prints the sector 0 slice table.
181 ******* Working on device /dev/ad0 *******
182 parameters extracted from in-core disklabel are:
183 cylinders=769 heads=15 sectors/track=33 (495 blks/cyl)
185 parameters to be used for BIOS calculations are:
186 cylinders=769 heads=15 sectors/track=33 (495 blks/cyl)
188 Warning: BIOS sector numbering starts with sector 1
189 Information from DOS bootblock is:
190 The data for partition 1 is:
191 sysid 165,(DragonFly/FreeBSD/NetBSD/386BSD)
192 start 495, size 380160 (185 Meg), flag 0
193 beg: cyl 1/ sector 1/ head 0;
194 end: cyl 768/ sector 33/ head 14
195 The data for partition 2 is:
197 start 378180, size 2475 (1 Meg), flag 0
198 beg: cyl 764/ sector 1/ head 0;
199 end: cyl 768/ sector 33/ head 14
200 The data for partition 3 is:
202 The data for partition 4 is:
203 sysid 99,(ISC UNIX, other System V/386, GNU HURD or Mach)
204 start 380656, size 224234 (109 Meg), flag 80
205 beg: cyl 769/ sector 2/ head 0;
206 end: cyl 197/ sector 33/ head 14
209 The disk is divided into three slices that happen to fill the disk.
210 The second slice overlaps the end of the first.
211 (Used for debugging purposes.)
212 .Bl -tag -width "cyl, sector and head"
214 is used to label the slice.
217 magic number 165 decimal (A5 in hex).
218 .It Em start No and Em size
219 fields provide the start address
220 and size of a slice in sectors.
222 specifies that this is the active slice.
223 .It Em cyl , sector No and Em head
224 fields are used to specify the beginning and end addresses of the slice.
226 these numbers are calculated using BIOS's understanding of the disk geometry
227 and saved in the bootblock.
234 flags are used to indicate that the slice data is to be updated.
237 option is also given,
239 will enter a conversational mode.
240 In this mode, no changes will be written to disk unless you explicitly tell
245 will display each slice and ask whether you want to edit it.
248 will step through each field, show you the old value,
249 and ask you for a new one.
250 When you are done with the slice,
252 will display it and ask you whether it is correct.
254 will then proceed to the next entry.
260 fields correct is tricky, so by default,
261 they will be calculated for you;
262 you can specify them if you choose to though.
264 After all the slices are processed,
265 you are given the option to change the
268 Finally, when all the new data for sector 0 has been accumulated,
269 you are asked to confirm whether you really want to rewrite it.
271 The difference between the
278 flag just edits (updates) the fields as they appear on the disk,
284 it will set up the last BIOS slice to use the whole disk for
288 The automatic calculation of starting cylinder etc.\& uses
289 a set of figures that represent what the BIOS thinks the
290 geometry of the drive is.
291 These figures are taken from the in-core disklabel by default,
294 initially gives you an opportunity to change them.
295 This allows you to create a bootblock that can work with drives
296 that use geometry translation under the BIOS.
298 If you hand craft your disk layout,
299 please make sure that the
301 slice starts on a cylinder boundary.
302 A number of decisions made later may assume this.
303 (This might not be necessary later.)
305 Editing an existing slice will most likely result in the loss of
306 all data in that slice.
310 interactively once or twice to see how it works.
311 This is completely safe as long as you answer the last question
313 There are subtleties that
315 detects that are not fully explained in this manual page.
316 .Sh CONFIGURATION FILE
319 option is given, a disk's slice table can be written using values
322 The syntax of this file is very simple;
323 each line is either a comment or a specification, as follows:
329 Lines beginning with a
331 are comments and are ignored.
338 Set the BIOS geometry used in slice calculations.
340 three values specified, with a letter preceding each number:
345 Set the number of cylinders to
350 Set the number of heads to
355 Set the number of sectors/track to
359 These specs can occur in any order, as the leading letter determines
360 which value is which; however, all three must be specified.
362 This line must occur before any lines that specify slice
365 It is an error if the following is not true:
366 .Bd -literal -offset indent
367 1 \(<= number of cylinders
368 1 \(<= number of heads \(<= 256
369 1 \(<= number of sectors/track < 64
372 The number of cylinders should be less than or equal to 1024, but this
373 is not enforced, although a warning will be printed.
378 file system) must lie completely within the
379 first 1024 cylinders, if
383 if this is not true, booting may fail.
384 Non-bootable slices do not have this restriction.
386 Example (all of these are equivalent), for a disk with 1019 cylinders,
387 39 heads, and 63 sectors:
388 .Bd -literal -offset indent
400 Set the slice given by
410 Only those slices explicitly mentioned by these lines are modified;
411 any slice not referenced by a
413 line will not be modified.
414 However, if an invalid slice table is present, or the
416 option is specified, all existing slice entries will be cleared
417 (marked as unused), and these
419 lines will have to be used to
420 explicitly set slice information.
421 If multiple slices need to be
424 lines must be specified; one for each slice.
426 These slice lines must occur after any geometry specification lines,
434 Specifying a slice type of zero is
435 the same as clearing the slice and marking it as unused; however,
436 dummy values (such as
438 must still be specified for
443 Note: the start offset will be rounded upwards to a head boundary if
444 necessary, and the end offset will be rounded downwards to a cylinder
445 boundary if necessary.
447 Example: to clear slice 4 and mark it as unused:
448 .Bd -literal -offset indent
452 Example: to set slice 1 to a
454 slice, starting at sector 1
455 for 2503871 sectors (note: these numbers will be rounded upwards and
456 downwards to correspond to head and cylinder boundaries):
457 .Bd -literal -offset indent
468 Can occur anywhere in the config file, but only
472 line is present, all slices of the disk are made inactive.
474 Example: to make slice 1 the active slice:
475 .Bd -literal -offset indent
480 .Bl -tag -width /boot/mbr -compact
482 The default boot code
485 Due to the use of 32 bit to store the number of sectors in the MBR,
487 can at most use 2^32 - 1 sectors.
488 For the prevalent sector size of 512B this means a maximum of 2TB.
489 Larger disks should be partitioned using
494 manipulates, is used by many different OSs, but the exact requirements seems to differ,
495 it can be a hassle to get multiple OSs to recognize the same MBR.
496 Some OSs will require that slices are located at cylinder boundaries.
504 .Pq primary DOS partitions
508 .Pq slices in extended DOS partitions
512 The default boot code will not necessarily handle all slice types
513 correctly, in particular those introduced since MS-DOS 6.x.
515 The entire program should be made more user-friendly.
519 do not understand the difference between
523 causing difficulty to adjust.
525 You cannot use this command to completely dedicate a disk to
529 command must be used for this.