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 165,(DragonFly/FreeBSD/NetBSD/386BSD)
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.
226 magic number 165 decimal (A5 in hex).
227 .It Em start No and Em size
228 fields provide the start address
229 and size of a slice in sectors.
231 specifies that this is the active slice.
232 .It Em cyl , sector No and Em head
233 fields are used to specify the beginning and end addresses of the slice.
235 these numbers are calculated using BIOS's understanding of the disk geometry
236 and saved in the bootblock.
243 flags are used to indicate that the slice data is to be updated.
246 option is also given,
248 will enter a conversational mode.
249 In this mode, no changes will be written to disk unless you explicitly tell
254 will display each slice and ask whether you want to edit it.
257 will step through each field, show you the old value,
258 and ask you for a new one.
259 When you are done with the slice,
261 will display it and ask you whether it is correct.
263 will then proceed to the next entry.
269 fields correct is tricky, so by default,
270 they will be calculated for you;
271 you can specify them if you choose to though.
273 After all the slices are processed,
274 you are given the option to change the
277 Finally, when all the new data for sector 0 has been accumulated,
278 you are asked to confirm whether you really want to rewrite it.
280 The difference between the
287 flag just edits (updates) the fields as they appear on the disk,
293 it will set up the last BIOS slice to use the whole disk for
297 The automatic calculation of starting cylinder etc.\& uses
298 a set of figures that represent what the BIOS thinks the
299 geometry of the drive is.
300 These figures are taken from the in-core disklabel by default,
303 initially gives you an opportunity to change them.
304 This allows you to create a bootblock that can work with drives
305 that use geometry translation under the BIOS.
307 If you hand craft your disk layout,
308 please make sure that the
310 slice starts on a cylinder boundary.
311 A number of decisions made later may assume this.
312 (This might not be necessary later.)
314 Editing an existing slice will most likely result in the loss of
315 all data in that slice.
319 interactively once or twice to see how it works.
320 This is completely safe as long as you answer the last question
322 There are subtleties that
324 detects that are not fully explained in this manual page.
325 .Sh CONFIGURATION FILE
328 option is given, a disk's slice table can be written using values
331 The syntax of this file is very simple;
332 each line is either a comment or a specification, as follows:
338 Lines beginning with a
340 are comments and are ignored.
347 Set the BIOS geometry used in slice calculations.
349 three values specified, with a letter preceding each number:
354 Set the number of cylinders to
359 Set the number of heads to
364 Set the number of sectors/track to
368 These specs can occur in any order, as the leading letter determines
369 which value is which; however, all three must be specified.
371 This line must occur before any lines that specify slice
374 It is an error if the following is not true:
375 .Bd -literal -offset indent
376 1 \(<= number of cylinders
377 1 \(<= number of heads \(<= 256
378 1 \(<= number of sectors/track < 64
381 The number of cylinders should be less than or equal to 1024, but this
382 is not enforced, although a warning will be printed.
387 file system) must lie completely within the
388 first 1024 cylinders, if
392 if this is not true, booting may fail.
393 Non-bootable slices do not have this restriction.
395 Example (all of these are equivalent), for a disk with 1019 cylinders,
396 39 heads, and 63 sectors:
397 .Bd -literal -offset indent
409 Set the slice given by
419 Only those slices explicitly mentioned by these lines are modified;
420 any slice not referenced by a
422 line will not be modified.
423 However, if an invalid slice table is present, or the
425 option is specified, all existing slice entries will be cleared
426 (marked as unused), and these
428 lines will have to be used to
429 explicitly set slice information.
430 If multiple slices need to be
433 lines must be specified; one for each slice.
435 These slice lines must occur after any geometry specification lines,
443 Specifying a slice type of zero is
444 the same as clearing the slice and marking it as unused; however,
445 dummy values (such as
447 must still be specified for
452 Note: the start offset will be rounded upwards to a head boundary if
453 necessary, and the end offset will be rounded downwards to a cylinder
454 boundary if necessary.
456 Example: to clear slice 4 and mark it as unused:
457 .Bd -literal -offset indent
461 Example: to set slice 1 to a
463 slice, starting at sector 1
464 for 2503871 sectors (note: these numbers will be rounded upwards and
465 downwards to correspond to head and cylinder boundaries):
466 .Bd -literal -offset indent
476 Can occur anywhere in the config file, but only
480 line is present, all slices of the disk are made inactive.
482 Example: to make slice 1 the active slice:
483 .Bd -literal -offset indent
488 .Bl -tag -width /boot/mbr -compact
490 The default boot code
493 Due to the use of 32 bit to store the number of sectors in the MBR,
495 can at most use 2^32 - 1 sectors.
496 For the prevalent sector size of 512B this means a maximum of 2TB.
497 Larger disks should be partitioned using
502 manipulates, is used by many different OSs, but the exact requirements seems to differ,
503 it can be a hassle to get multiple OSs to recognize the same MBR.
504 Some OSs will require that slices are located at cylinder boundaries.
513 first appeared in the Mach Operating System.
514 It was subsequently ported to
519 for Mach Operating System was written by
520 .An Robert Baron Aq Mt rvb@cs.cmu.edu .
524 .An Julian Elischer Aq Mt julian@tfs.com .
527 .Pq primary DOS partitions
531 .Pq slices in extended DOS partitions
535 The default boot code will not necessarily handle all slice types
536 correctly, in particular those introduced since MS-DOS 6.x.
538 The entire program should be made more user-friendly.
542 do not understand the difference between
546 causing difficulty to adjust.
548 You cannot use this command to completely dedicate a disk to
552 command must be used for this.