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.3 2003/10/12 00:45:24 dillon Exp $
9 .Nd PC slice table maintenance program
23 In order for the BIOS to boot the kernel,
24 certain conventions must be adhered to.
25 Sector 0 of the disk must contain boot code,
28 BIOS slices can be used to break the disk up into several pieces.
29 The BIOS brings in sector 0 and verifies the magic number. The sector
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. The first form is used to
49 display slice information or to interactively edit the slice
50 table. The second is used to write a slice table using a
52 and is designed to be used by other scripts/programs.
56 Change the active slice only. Ignored if
60 Get the boot code from the file
65 The disk image is specified as a normal file instead of as a device,
66 which is useful when building emulated disks for vmware, bochs, etc.
68 Reinitialize the boot code contained in sector 0 of the disk. Ignored
72 .It Fl f Ar configfile
73 Set slice values using the file
77 always modifies existing slices, unless
79 is also given, in which case all existing slices are deleted (marked
80 as "unused") before the
84 can be "-", in which case
87 .Sx CONFIGURATION FILE ,
88 below, for file syntax.
93 is used, you are not asked if you really want to write the slices
94 table (as you are in the interactive mode). Use with caution!
96 Initialize sector 0 of the disk. This implies
102 Initialize the contents of sector 0
105 slice covering the entire disk.
107 Print summary information and exit.
109 Test mode; do not write slice values. Generally used with the
111 option to see what would be written to the slice table. Implies
114 Is used for updating (editing) sector 0 of the disk. Ignored if
122 prints out the slice table that is written to the disk.
124 Operate on a single fdisk entry only. Ignored if
129 The final disk name can be provided as a
131 disk name only, e.g.\&
133 or as a fully qualified device node under
135 If omitted, the disks
139 are searched in that order, until one is found to respond.
141 When called without options,
143 prints the sector 0 slice table.
146 ******* Working on device /dev/ad0 *******
147 parameters extracted from in-core disklabel are:
148 cylinders=769 heads=15 sectors/track=33 (495 blks/cyl)
150 parameters to be used for BIOS calculations are:
151 cylinders=769 heads=15 sectors/track=33 (495 blks/cyl)
153 Warning: BIOS sector numbering starts with sector 1
154 Information from DOS bootblock is:
155 The data for partition 1 is:
156 sysid 165,(FreeBSD/NetBSD/386BSD)
157 start 495, size 380160 (185 Meg), flag 0
158 beg: cyl 1/ sector 1/ head 0;
159 end: cyl 768/ sector 33/ head 14
160 The data for partition 2 is:
162 start 378180, size 2475 (1 Meg), flag 0
163 beg: cyl 764/ sector 1/ head 0;
164 end: cyl 768/ sector 33/ head 14
165 The data for partition 3 is:
167 The data for partition 4 is:
168 sysid 99,(ISC UNIX, other System V/386, GNU HURD or Mach)
169 start 380656, size 224234 (109 Meg), flag 80
170 beg: cyl 769/ sector 2/ head 0;
171 end: cyl 197/ sector 33/ head 14
174 The disk is divided into three slices that happen to fill the disk.
175 The second slice overlaps the end of the first.
176 (Used for debugging purposes.)
177 .Bl -tag -width "cyl, sector and head"
179 is used to label the slice.
182 magic number 165 decimal (A5 in hex).
183 .It Em start No and Em size
184 fields provide the start address
185 and size of a slice in sectors.
187 specifies that this is the active slice.
188 .It Em cyl , sector No and Em head
189 fields are used to specify the beginning and end addresses of the slice.
191 these numbers are calculated using BIOS's understanding of the disk geometry
192 and saved in the bootblock.
199 flags are used to indicate that the slice data is to be updated.
202 option is also given,
204 will enter a conversational mode.
205 In this mode, no changes will be written to disk unless you explicitly tell
210 will display each slice and ask whether you want to edit it.
213 will step through each field, show you the old value,
214 and ask you for a new one.
215 When you are done with the slice,
217 will display it and ask you whether it is correct.
219 will then proceed to the next entry.
225 fields correct is tricky, so by default,
226 they will be calculated for you;
227 you can specify them if you choose to though.
229 After all the slices are processed,
230 you are given the option to change the
233 Finally, when all the new data for sector 0 has been accumulated,
234 you are asked to confirm whether you really want to rewrite it.
236 The difference between the
243 flag just edits (updates) the fields as they appear on the disk,
246 flag is used to "initialize" sector 0;
247 it will set up the last BIOS slice to use the whole disk for
251 The automatic calculation of starting cylinder etc. uses
252 a set of figures that represent what the BIOS thinks the
253 geometry of the drive is.
254 These figures are taken from the in-core disklabel by default,
257 initially gives you an opportunity to change them.
258 This allows you to create a bootblock that can work with drives
259 that use geometry translation under the BIOS.
261 If you hand craft your disk layout,
262 please make sure that the
264 slice starts on a cylinder boundary.
265 A number of decisions made later may assume this.
266 (This might not be necessary later.)
268 Editing an existing slice will most likely result in the loss of
269 all data in that slice.
273 interactively once or twice to see how it works.
274 This is completely safe as long as you answer the last question
275 in the negative. There are subtleties that
277 detects that are not fully explained in this manual page.
278 .Sh CONFIGURATION FILE
281 option is given, a disk's slice table can be written using values
284 The syntax of this file is very simple;
285 each line is either a comment or a specification, as follows:
291 Lines beginning with a "#" are comments and are ignored.
298 Set the BIOS geometry used in slice calculations. There must be
299 three values specified, with a letter preceding each number:
304 Set the number of cylinders to
309 Set the number of heads to
314 Set the number of sectors/track to
318 These specs can occur in any order, as the leading letter determines
319 which value is which; however, all three must be specified.
321 This line must occur before any lines that specify slice
324 It is an error if the following is not true:
325 .Bd -literal -offset indent
326 1 <= number of cylinders
327 1 <= number of heads <= 256
328 1 <= number of sectors/track < 64
331 The number of cylinders should be less than or equal to 1024, but this
332 is not enforced, although a warning will be printed. Note that bootable
334 slices (the "/" filesystem) must lie completely within the
335 first 1024 cylinders; if this is not true, booting may fail.
336 Non-bootable slices do not have this restriction.
338 Example (all of these are equivalent), for a disk with 1019 cylinders,
339 39 heads, and 63 sectors:
340 .Bd -literal -offset indent
352 Set the slice given by
362 Only those slices explicitly mentioned by these lines are modified;
363 any slice not referenced by a "p" line will not be modified.
364 However, if an invalid slice table is present, or the
366 option is specified, all existing slice entries will be cleared
367 (marked as unused), and these "p" lines will have to be used to
368 explicitly set slice information. If multiple slices need to be
369 set, multiple "p" lines must be specified; one for each slice.
371 These slice lines must occur after any geometry specification lines,
378 slices. Specifying a slice type of zero is
379 the same as clearing the slice and marking it as unused; however,
380 dummy values (such as "0") must still be specified for
385 Note: the start offset will be rounded upwards to a head boundary if
386 necessary, and the end offset will be rounded downwards to a cylinder
387 boundary if necessary.
389 Example: to clear slice 4 and mark it as unused:
390 .Bd -literal -offset indent
394 Example: to set slice 1 to a
396 slice, starting at sector 1
397 for 2503871 sectors (note: these numbers will be rounded upwards and
398 downwards to correspond to head and cylinder boundaries):
400 .Bd -literal -offset indent
410 the active slice. Can occur anywhere in the config file, but only
413 Example: to make slice 1 the active slice:
414 .Bd -literal -offset indent
419 .Bl -tag -width /boot/mbr -compact
421 The default boot code
428 The default boot code will not necessarily handle all slice types
429 correctly, in particular those introduced since MS-DOS 6.x.
431 The entire program should be made more user-friendly.
435 do not understand the difference between
439 causing difficulty to adjust.
441 You cannot use this command to completely dedicate a disk to
445 command must be used for this.