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.16 2008/09/01 19:27:31 thomas Exp $
9 .Nd PC slice table 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 boot code,
27 BIOS slices can be used to break the disk up into several pieces.
28 The BIOS brings in sector 0 and verifies the magic number.
30 0 boot code then searches the slice table to determine which
33 This boot code then brings in the bootstrap from the
35 slice and, if marked bootable, runs it.
37 you can have one or more slices with one
41 program can be used to divide space on the disk into slices and set one
48 serves a similar purpose to the DOS program.
49 The first form is used to
50 display slice information or to interactively edit the slice table.
51 The second is used to write a slice table using a
53 and is designed to be used by other scripts/programs.
56 .Bl -tag -width indent
58 Change the active slice only.
63 Get the boot code from the file
68 The disk image is specified as a normal file instead of as a device,
69 which is useful when building emulated disks for vmware, bochs, etc.\&
71 Reinitialize the boot code contained in sector 0 of the disk.
76 Set CHS fields to wrapped values.
77 Normally the CHS fields for a partition are set to all 1's if they
79 This typically causes BIOSes to properly detect
80 that the disk should be put in Large mode.
81 This option may be needed on very old PCs.
82 .It Fl f Ar configfile
83 Set slice values using the file
87 always modifies existing slices, unless
89 is also given, in which case all existing slices are deleted (marked
103 .Sx CONFIGURATION FILE ,
104 below, for file syntax.
109 is used, you are not asked if you really want to write the slices
110 table (as you are in the interactive mode).
113 Initialize sector 0 of the disk.
120 Initialize the contents of sector 0
123 slice covering the entire disk.
125 Print a summary of all slices on the disk and exit.
126 All other options will be ignored.
128 Test mode; do not write slice values.
129 Generally used with the
131 option to see what would be written to the slice table.
135 Is used for updating (editing) sector 0 of the disk.
145 prints out the slice table that is written to the disk.
147 Operate on a single fdisk entry only.
153 The final disk name can be provided as a
155 disk name only, e.g.\&
157 or as a fully qualified device node under
159 If omitted, the disks
164 are searched in that order, until one is found to respond.
166 When called without options,
168 prints the sector 0 slice table.
171 ******* Working on device /dev/ad0 *******
172 parameters extracted from in-core disklabel are:
173 cylinders=769 heads=15 sectors/track=33 (495 blks/cyl)
175 parameters to be used for BIOS calculations are:
176 cylinders=769 heads=15 sectors/track=33 (495 blks/cyl)
178 Warning: BIOS sector numbering starts with sector 1
179 Information from DOS bootblock is:
180 The data for partition 1 is:
181 sysid 165,(DragonFly/FreeBSD/NetBSD/386BSD)
182 start 495, size 380160 (185 Meg), flag 0
183 beg: cyl 1/ sector 1/ head 0;
184 end: cyl 768/ sector 33/ head 14
185 The data for partition 2 is:
187 start 378180, size 2475 (1 Meg), flag 0
188 beg: cyl 764/ sector 1/ head 0;
189 end: cyl 768/ sector 33/ head 14
190 The data for partition 3 is:
192 The data for partition 4 is:
193 sysid 99,(ISC UNIX, other System V/386, GNU HURD or Mach)
194 start 380656, size 224234 (109 Meg), flag 80
195 beg: cyl 769/ sector 2/ head 0;
196 end: cyl 197/ sector 33/ head 14
199 The disk is divided into three slices that happen to fill the disk.
200 The second slice overlaps the end of the first.
201 (Used for debugging purposes.)
202 .Bl -tag -width "cyl, sector and head"
204 is used to label the slice.
207 magic number 165 decimal (A5 in hex).
208 .It Em start No and Em size
209 fields provide the start address
210 and size of a slice in sectors.
212 specifies that this is the active slice.
213 .It Em cyl , sector No and Em head
214 fields are used to specify the beginning and end addresses of the slice.
216 these numbers are calculated using BIOS's understanding of the disk geometry
217 and saved in the bootblock.
224 flags are used to indicate that the slice data is to be updated.
227 option is also given,
229 will enter a conversational mode.
230 In this mode, no changes will be written to disk unless you explicitly tell
235 will display each slice and ask whether you want to edit it.
238 will step through each field, show you the old value,
239 and ask you for a new one.
240 When you are done with the slice,
242 will display it and ask you whether it is correct.
244 will then proceed to the next entry.
250 fields correct is tricky, so by default,
251 they will be calculated for you;
252 you can specify them if you choose to though.
254 After all the slices are processed,
255 you are given the option to change the
258 Finally, when all the new data for sector 0 has been accumulated,
259 you are asked to confirm whether you really want to rewrite it.
261 The difference between the
268 flag just edits (updates) the fields as they appear on the disk,
274 it will set up the last BIOS slice to use the whole disk for
278 The automatic calculation of starting cylinder etc.\& uses
279 a set of figures that represent what the BIOS thinks the
280 geometry of the drive is.
281 These figures are taken from the in-core disklabel by default,
284 initially gives you an opportunity to change them.
285 This allows you to create a bootblock that can work with drives
286 that use geometry translation under the BIOS.
288 If you hand craft your disk layout,
289 please make sure that the
291 slice starts on a cylinder boundary.
292 A number of decisions made later may assume this.
293 (This might not be necessary later.)
295 Editing an existing slice will most likely result in the loss of
296 all data in that slice.
300 interactively once or twice to see how it works.
301 This is completely safe as long as you answer the last question
303 There are subtleties that
305 detects that are not fully explained in this manual page.
306 .Sh CONFIGURATION FILE
309 option is given, a disk's slice table can be written using values
312 The syntax of this file is very simple;
313 each line is either a comment or a specification, as follows:
319 Lines beginning with a
321 are comments and are ignored.
328 Set the BIOS geometry used in slice calculations.
330 three values specified, with a letter preceding each number:
335 Set the number of cylinders to
340 Set the number of heads to
345 Set the number of sectors/track to
349 These specs can occur in any order, as the leading letter determines
350 which value is which; however, all three must be specified.
352 This line must occur before any lines that specify slice
355 It is an error if the following is not true:
356 .Bd -literal -offset indent
357 1 \(<= number of cylinders
358 1 \(<= number of heads \(<= 256
359 1 \(<= number of sectors/track < 64
362 The number of cylinders should be less than or equal to 1024, but this
363 is not enforced, although a warning will be printed.
368 file system) must lie completely within the
369 first 1024 cylinders; if this is not true, booting may fail.
370 Non-bootable slices do not have this restriction.
372 Example (all of these are equivalent), for a disk with 1019 cylinders,
373 39 heads, and 63 sectors:
374 .Bd -literal -offset indent
386 Set the slice given by
396 Only those slices explicitly mentioned by these lines are modified;
397 any slice not referenced by a
399 line will not be modified.
400 However, if an invalid slice table is present, or the
402 option is specified, all existing slice entries will be cleared
403 (marked as unused), and these
405 lines will have to be used to
406 explicitly set slice information.
407 If multiple slices need to be
410 lines must be specified; one for each slice.
412 These slice lines must occur after any geometry specification lines,
420 Specifying a slice type of zero is
421 the same as clearing the slice and marking it as unused; however,
422 dummy values (such as
424 must still be specified for
429 Note: the start offset will be rounded upwards to a head boundary if
430 necessary, and the end offset will be rounded downwards to a cylinder
431 boundary if necessary.
433 Example: to clear slice 4 and mark it as unused:
434 .Bd -literal -offset indent
438 Example: to set slice 1 to a
440 slice, starting at sector 1
441 for 2503871 sectors (note: these numbers will be rounded upwards and
442 downwards to correspond to head and cylinder boundaries):
443 .Bd -literal -offset indent
454 Can occur anywhere in the config file, but only
458 line is present, all slices of the disk are made inactive.
460 Example: to make slice 1 the active slice:
461 .Bd -literal -offset indent
466 .Bl -tag -width /boot/mbr -compact
468 The default boot code
471 Due to the use of 32 bit to store the number of sectors in the MBR,
473 can at most use 2^32 - 1 sectors.
474 For the prevalent sector size of 512B this means a maximum of 2TB.
475 Larger disks should be partitioned using
480 manipulates, is used by many different OSs, but the exact requirements seems to differ,
481 it can be a hassle to get multiple OSs to recognize the same MBR.
482 Some OSs will require that slices are located at cylinder boundaries.
489 The default boot code will not necessarily handle all slice types
490 correctly, in particular those introduced since MS-DOS 6.x.
492 The entire program should be made more user-friendly.
496 do not understand the difference between
500 causing difficulty to adjust.
502 You cannot use this command to completely dedicate a disk to
506 command must be used for this.