1 .\" $FreeBSD: src/sbin/i386/fdisk/fdisk.8,v 1.17.2.11 2002/04/25 16:25:12 trhodes Exp $
8 .Nd PC slice table (MBR) maintenance program
21 In order for the BIOS to boot the kernel,
22 certain conventions must be adhered to.
23 Sector 0 of the disk must contain an MBR, which contain boot code,
26 BIOS slices can be used to break the disk up into several pieces.
28 slices are called partitions under DOS
30 has another meaning under
35 supports 30 MBR slices, s1-s4 will be DOS primary partitions,
36 s5-s30 will be DOS partitions in extended DOS partitions.
37 The BIOS brings in sector 0 and verifies the magic number.
39 0 boot code then searches the slice table to determine which
42 This boot code then brings in the bootstrap from the
44 slice and, if marked bootable, runs it.
46 you can have one or more slices with one
50 program can be used to divide space on the disk into slices and set one
57 serves a similar purpose to the DOS program.
58 The first form is used to
59 display slice information or to interactively edit the slice table.
60 The second is used to write a slice table using a
62 and is designed to be used by other scripts/programs.
65 .Bl -tag -width indent
67 Change the active slice only.
72 Get the boot code from the file
77 The disk image is specified as a normal file instead of as a device,
78 which is useful when building emulated disks for vmware, bochs, etc.\&
80 Reinitialize the boot code contained in sector 0 of the disk.
85 Set CHS fields to wrapped values.
86 Normally the CHS fields for a slice are set to all 1's if they
88 This typically causes BIOSes to properly detect
89 that the disk should be put in Large mode.
90 This option may be needed on very old PCs.
92 Use TRIM to erase the device/partition before creating the file system.
93 The underlying device must have the TRIM sysctl enabled.
94 Only devices that support TRIM will have such a sysctl option
95 .Va ( kern.cam.da.X.trim_enabled ) .
101 .It Fl f Ar configfile
102 Set slice values using the file
106 always modifies existing slices, unless
108 is also given, in which case all existing slices are deleted (marked
122 .Sx CONFIGURATION FILE ,
123 below, for file syntax.
128 is used, you are not asked if you really want to write the slices
129 table (as you are in the interactive mode).
132 Initialize sector 0 of the disk.
139 Initialize the contents of sector 0
142 slice covering the entire disk.
144 Print a summary of all slices on the disk and exit.
145 All other options will be ignored.
147 Test mode; do not write slice values.
148 Generally used with the
150 option to see what would be written to the slice table.
154 Is used for updating (editing) sector 0 of the disk.
164 prints out the slice table that is written to the disk.
166 Operate on a single fdisk entry only.
172 The final disk name can be provided as a
174 disk name only, e.g.\&
176 or as a fully qualified device node under
178 If omitted, the disks
183 are searched in that order, until one is found to respond.
185 When called without options,
187 prints the sector 0 slice table.
190 ******* Working on device /dev/ad0 *******
191 parameters extracted from in-core disklabel are:
192 cylinders=769 heads=15 sectors/track=33 (495 blks/cyl)
194 parameters to be used for BIOS calculations are:
195 cylinders=769 heads=15 sectors/track=33 (495 blks/cyl)
197 Warning: BIOS sector numbering starts with sector 1
198 Information from DOS bootblock is:
199 The data for partition 1 is:
200 sysid 108,(DragonFly BSD)
201 start 495, size 380160 (185 Meg), flag 0
202 beg: cyl 1/ sector 1/ head 0;
203 end: cyl 768/ sector 33/ head 14
204 The data for partition 2 is:
206 start 378180, size 2475 (1 Meg), flag 0
207 beg: cyl 764/ sector 1/ head 0;
208 end: cyl 768/ sector 33/ head 14
209 The data for partition 3 is:
211 The data for partition 4 is:
212 sysid 99,(ISC UNIX, other System V/386, GNU HURD or Mach)
213 start 380656, size 224234 (109 Meg), flag 80
214 beg: cyl 769/ sector 2/ head 0;
215 end: cyl 197/ sector 33/ head 14
218 The disk is divided into three slices that happen to fill the disk.
219 The second slice overlaps the end of the first.
220 (Used for debugging purposes.)
221 .Bl -tag -width "cyl, sector and head"
223 is used to label the slice.
225 reserves the magic number 108 decimal (6C in hexadecimal).
226 .It Em start No and Em size
227 fields provide the start address
228 and size of a slice in sectors.
230 specifies that this is the active slice.
231 .It Em cyl , sector No and Em head
232 fields are used to specify the beginning and end addresses of the slice.
234 these numbers are calculated using BIOS's understanding of the disk geometry
235 and saved in the bootblock.
242 flags are used to indicate that the slice data is to be updated.
245 option is also given,
247 will enter a conversational mode.
248 In this mode, no changes will be written to disk unless you explicitly tell
253 will display each slice and ask whether you want to edit it.
256 will step through each field, show you the old value,
257 and ask you for a new one.
258 When you are done with the slice,
260 will display it and ask you whether it is correct.
262 will then proceed to the next entry.
268 fields correct is tricky, so by default,
269 they will be calculated for you;
270 you can specify them if you choose to though.
272 After all the slices are processed,
273 you are given the option to change the
276 Finally, when all the new data for sector 0 has been accumulated,
277 you are asked to confirm whether you really want to rewrite it.
279 The difference between the
286 flag just edits (updates) the fields as they appear on the disk,
292 it will set up the last BIOS slice to use the whole disk for
296 The automatic calculation of starting cylinder etc.\& uses
297 a set of figures that represent what the BIOS thinks the
298 geometry of the drive is.
299 These figures are taken from the in-core disklabel by default,
302 initially gives you an opportunity to change them.
303 This allows you to create a bootblock that can work with drives
304 that use geometry translation under the BIOS.
306 If you hand craft your disk layout,
307 please make sure that the
309 slice starts on a cylinder boundary.
310 A number of decisions made later may assume this.
311 (This might not be necessary later.)
313 Editing an existing slice will most likely result in the loss of
314 all data in that slice.
318 interactively once or twice to see how it works.
319 This is completely safe as long as you answer the last question
321 There are subtleties that
323 detects that are not fully explained in this manual page.
324 .Sh CONFIGURATION FILE
327 option is given, a disk's slice table can be written using values
330 The syntax of this file is very simple;
331 each line is either a comment or a specification, as follows:
337 Lines beginning with a
339 are comments and are ignored.
346 Set the BIOS geometry used in slice calculations.
348 three values specified, with a letter preceding each number:
353 Set the number of cylinders to
358 Set the number of heads to
363 Set the number of sectors/track to
367 These specs can occur in any order, as the leading letter determines
368 which value is which; however, all three must be specified.
370 This line must occur before any lines that specify slice
373 It is an error if the following is not true:
374 .Bd -literal -offset indent
375 1 \(<= number of cylinders
376 1 \(<= number of heads \(<= 256
377 1 \(<= number of sectors/track < 64
380 The number of cylinders should be less than or equal to 1024, but this
381 is not enforced, although a warning will be printed.
386 file system) must lie completely within the
387 first 1024 cylinders, if
391 if this is not true, booting may fail.
392 Non-bootable slices do not have this restriction.
394 Example (all of these are equivalent), for a disk with 1019 cylinders,
395 39 heads, and 63 sectors:
396 .Bd -literal -offset indent
408 Set the slice given by
418 Only those slices explicitly mentioned by these lines are modified;
419 any slice not referenced by a
421 line will not be modified.
422 However, if an invalid slice table is present, or the
424 option is specified, all existing slice entries will be cleared
425 (marked as unused), and these
427 lines will have to be used to
428 explicitly set slice information.
429 If multiple slices need to be
432 lines must be specified; one for each slice.
434 These slice lines must occur after any geometry specification lines,
442 Specifying a slice type of zero is
443 the same as clearing the slice and marking it as unused; however,
444 dummy values (such as
446 must still be specified for
451 Note: the start offset will be rounded upwards to a head boundary if
452 necessary, and the end offset will be rounded downwards to a cylinder
453 boundary if necessary.
455 Example: to clear slice 4 and mark it as unused:
456 .Bd -literal -offset indent
460 Example: to set slice 1 to a
462 slice, starting at sector 1
463 for 2503871 sectors (note: these numbers will be rounded upwards and
464 downwards to correspond to head and cylinder boundaries):
465 .Bd -literal -offset indent
475 Can occur anywhere in the config file, but only
479 line is present, all slices of the disk are made inactive.
481 Example: to make slice 1 the active slice:
482 .Bd -literal -offset indent
487 .Bl -tag -width /boot/mbr -compact
489 The default boot code
492 Due to the use of 32 bit to store the number of sectors in the MBR,
494 can at most use 2^32 - 1 sectors.
495 For the prevalent sector size of 512B this means a maximum of 2TB.
496 Larger disks should be partitioned using
501 manipulates, is used by many different OSs, but the exact requirements seems to differ,
502 it can be a hassle to get multiple OSs to recognize the same MBR.
503 Some OSs will require that slices are located at cylinder boundaries.
512 first appeared in the Mach Operating System.
513 It was subsequently ported to
518 for Mach Operating System was written by
519 .An Robert Baron Aq Mt rvb@cs.cmu.edu .
523 .An Julian Elischer Aq Mt julian@tfs.com .
526 .Pq primary DOS partitions
530 .Pq slices in extended DOS partitions
534 The default boot code will not necessarily handle all slice types
535 correctly, in particular those introduced since MS-DOS 6.x.
537 The entire program should be made more user-friendly.
541 do not understand the difference between
545 causing difficulty to adjust.
547 You cannot use this command to completely dedicate a disk to
551 command must be used for this.