]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sbin/fdisk_pc98/fdisk.8
merge fix for boot-time hang on centos' xen
[FreeBSD/FreeBSD.git] / sbin / fdisk_pc98 / fdisk.8
1 .\" $FreeBSD$
2 .\"
3 .Dd October 4, 1996
4 .Dt FDISK 8
5 .Os
6 .Sh NAME
7 .Nm fdisk
8 .Nd PC partition table maintenance program
9 .Sh SYNOPSIS
10 .Nm
11 .\" !PC98 .Op Fl BIaistu
12 .Op Fl Bastu
13 .Op Fl b Ar bootcode
14 .Op Fl 1234
15 .Op Ar disk
16 .Nm
17 .Fl f Ar configfile
18 .Op Fl itv
19 .Op Ar disk
20 .Sh PROLOGUE
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 boot code,
24 a partition table,
25 and a magic number.
26 BIOS partitions can be used to break the disk up into several pieces.
27 The BIOS brings in sector 0 and verifies the magic number.
28 The sector
29 0 boot code then searches the partition table to determine which
30 partition is marked
31 .Em active .
32 This boot code then brings in the bootstrap from the
33 .Em active
34 partition and, if marked bootable, runs it.
35 Under DOS,
36 you can have one or more partitions with one
37 .Em active .
38 The DOS
39 .Nm
40 utility can be used to divide space on the disk into partitions and set one
41 .Em active .
42 .Sh DESCRIPTION
43 The
44 .Fx
45 .Nm
46 utility serves a similar purpose to the DOS program.
47 The first form is used to
48 display partition information or to interactively edit the partition
49 table.
50 The second is used to write a partition table using a
51 .Ar configfile
52 and is designed to be used by other scripts/programs.
53 .Pp
54 Options are:
55 .Bl -tag -width time
56 .It Fl a
57 Change the active partition only.
58 Ignored if
59 .Fl f
60 is given.
61 .It Fl b Ar bootcode
62 Get the boot code from the file
63 .Ar bootcode .
64 .It Fl B
65 Reinitialize the boot code contained in sector 0 of the disk.
66 Ignored
67 if
68 .Fl f
69 is given.
70 .It Fl f Ar configfile
71 Set partition values using the file
72 .Ar configfile .
73 The
74 .Ar configfile
75 always modifies existing partitions, unless
76 .Fl i
77 is also given, in which case all existing partitions are deleted (marked
78 as "unused") before the
79 .Ar configfile
80 is read.
81 The
82 .Ar configfile
83 can be "-", in which case
84 .Ar stdin
85 is read.
86 See
87 .Sx CONFIGURATION FILE ,
88 below, for file syntax.
89 .Pp
90 .Em WARNING :
91 when
92 .Fl f
93 is used, you are not asked if you really want to write the partition
94 table (as you are in the interactive mode).
95 Use with caution!
96 .\" !PC98
97 .\" .It Fl i
98 .\" Initialize sector 0 of the disk.  This implies
99 .\" .Fl u ,
100 .\" unless
101 .\" .Fl f
102 .\" is given.
103 .\" .It Fl I
104 .\" Initialize the contents of sector 0
105 .\" with one
106 /\" .Fx
107 /\" slice covering the entire disk.
108 .It Fl s
109 Print summary information and exit.
110 .It Fl t
111 Test mode; do not write partition values.
112 Generally used with the
113 .Fl f
114 option to see what would be written to the partition table.
115 Implies
116 .Fl v .
117 .It Fl u
118 Is used for updating (editing) sector 0 of the disk.
119 Ignored if
120 .Fl f
121 is given.
122 .It Fl v
123 Be verbose.
124 When
125 .Fl f
126 is used,
127 .Nm
128 prints out the partition table that is written to the disk.
129 .It Fl 12345678
130 Operate on a single fdisk entry only.
131 Ignored if
132 .Fl f
133 is given.
134 .El
135 .Pp
136 The final disk name can be provided as a
137 .Sq bare
138 disk name only, e.g.\&
139 .Ql da0 ,
140 or as a fully qualified device node under
141 .Pa /dev .
142 If omitted, the disks
143 .Ql wd0 ,
144 .Ql da0 ,
145 and
146 .Ql od0
147 are being searched in that order, until one is
148 being found responding.
149 .Pp
150 When called with no arguments, it prints the sector 0 partition table.
151 An example follows:
152 .Bd -literal
153         ******* Working on device /dev/rda0 *******
154         parameters extracted from in-core disklabel are:
155         cylinders=33075 heads=8 sectors/track=32 (256 blks/cyl)
156
157         parameters to be used for BIOS calculations are:
158         cylinders=33075 heads=8 sectors/track=32 (256 blks/cyl)
159
160         Media sector size is 512
161         Warning: BIOS sector numbering starts with sector 1
162         Information from DOS bootblock is:
163         The data for partition 1 is:
164         sysmid 148,(FreeBSD/NetBSD/386BSD)
165             start 256, size 2490112 (1215 Meg), sid 196
166                 beg: cyl 1/ sector 0/ head 0;
167                 end: cyl 9727/ sector 0/ head 0
168                 system Name FreeBSD(98)
169         The data for partition 2 is:
170         sysmid 148,(FreeBSD/NetBSD/386BSD)
171             start 2490368, size 5505024 (2688 Meg), sid 196
172                 beg: cyl 9728/ sector 0/ head 0;
173                 end: cyl 31231/ sector 0/ head 0
174                 system Name FreeBSD(98)
175         The data for partition 3 is:
176         <UNUSED>
177         The data for partition 4 is:
178         <UNUSED>
179         The data for partition 5 is:
180         <UNUSED>
181         The data for partition 6 is:
182         <UNUSED>
183         The data for partition 7 is:
184         <UNUSED>
185         The data for partition 8 is:
186         <UNUSED>
187         The data for partition 9 is:
188         <UNUSED>
189         The data for partition 10 is:
190         <UNUSED>
191         The data for partition 11 is:
192         <UNUSED>
193         The data for partition 12 is:
194         <UNUSED>
195         The data for partition 13 is:
196         <UNUSED>
197         The data for partition 14 is:
198         <UNUSED>
199         The data for partition 15 is:
200         <UNUSED>
201         The data for partition 16 is:
202         <UNUSED>
203 .Ed
204 .Pp
205 The disk is divided into three partitions that happen to fill the disk.
206 The second partition overlaps the end of the first.
207 (Used for debugging purposes)
208 .Bl -tag -width "cyl, sector and head"
209 .It Em "sysmid"
210 is used to label the partition.
211 .Fx
212 reserves the
213 magic number 148 decimal (94 in hex).
214 .It Em start No and Em size
215 fields provide the start address
216 and size of a partition in sectors.
217 .\" !PC98 .It Em "flag 80"
218 .\" specifies that this is the active partition.
219 .It Em cyl , sector No and Em head
220 fields are used to specify the beginning address
221 and end address for the partition.
222 .It Em "system Name"
223 is the name of the partition.
224 .It Em Note :
225 these numbers are calculated using BIOS's understanding of the disk geometry
226 and saved in the bootblock.
227 .El
228 .Pp
229 The flags
230 .\" .Fl i
231 .\" or
232 .Fl u
233 are used to indicate that the partition data is to be updated, unless the
234 .Fl f
235 option is used.
236 If the
237 .Fl f
238 option is not used, the
239 .Nm
240 utility will enter a conversational mode.
241 This mode is designed not to change any data unless you explicitly tell it to.
242 The
243 .Nm
244 utility selects defaults for its questions to guarantee the above behavior.
245 .Pp
246 It displays each partition
247 and ask if you want to edit it.
248 If you say yes,
249 it will step through each field showing the old value
250 and asking for a new one.
251 When you are done with a partition,
252 .Nm
253 will display it and ask if it is correct.
254 The
255 .Nm
256 utility will then proceed to the next entry.
257 .Pp
258 Getting the
259 .Em cyl , sector ,
260 and
261 .Em head
262 fields correct is tricky.
263 So by default,
264 they will be calculated for you;
265 you can specify them if you choose.
266 .Pp
267 After all the partitions are processed,
268 you are given the option to change the
269 .Em active
270 partition.
271 Finally,
272 when the all the data for the first sector has been accumulated,
273 you are asked if you really want to rewrite sector 0.
274 Only if you answer yes,
275 will the data be written to disk.
276 .Pp
277 The difference between the
278 .Fl u
279 flag and
280 .Fl i
281 flag is that
282 the
283 .Fl u
284 flag just edits the fields as they appear on the disk.
285 While the
286 .Fl i
287 flag is used to "initialize" sector 0;
288 it will setup the last BIOS partition to use the whole disk for
289 .Fx ;
290 and make it active.
291 .Sh NOTES
292 The automatic calculation of starting cylinder etc.\& uses
293 a set of figures that represent what the BIOS thinks is the
294 geometry of the drive.
295 These figures are by default taken from the incore disklabel,
296 but the program initially gives you an opportunity to change them.
297 This allows the user to create a bootblock that can work with drives
298 that use geometry translation under the BIOS.
299 .Pp
300 If you hand craft your disk layout,
301 please make sure that the
302 .Fx
303 partition starts on a cylinder boundary.
304 A number of decisions made later may assume this.
305 (This might not be necessary later.)
306 .Pp
307 Editing an existing partition will most likely cause you to
308 lose all the data in that partition.
309 .Pp
310 You should run this program interactively once or twice to see how it
311 works.
312 This is completely safe as long as you answer the last question
313 in the negative.
314 There are subtleties that the program detects that are
315 not fully explained in this manual page.
316 .Sh CONFIGURATION FILE
317 When the
318 .Fl f
319 option is given, a disk's partition table can be written using values
320 from a
321 .Ar configfile .
322 The syntax of this file is very simple.
323 Each line is either a comment or
324 a specification, and whitespace (except for newlines) are ignored:
325 .Bl -tag -width Ds
326 .It Xo
327 .Ic #
328 .Ar comment ...
329 .Xc
330 Lines beginning with a "#" are comments and are ignored.
331 .It Xo
332 .Ic g
333 .Ar spec1
334 .Ar spec2
335 .Ar spec3
336 .Xc
337 Set the BIOS geometry used in partition calculations.
338 There must be
339 three values specified, with a letter preceding each number:
340 .Bl -tag -width Ds
341 .Sm off
342 .It Cm c Ar num
343 .Sm on
344 Set the number of cylinders to
345 .Ar num .
346 .Sm off
347 .It Cm h Ar num
348 .Sm on
349 Set the number of heads to
350 .Ar num .
351 .Sm off
352 .It Cm s Ar num
353 .Sm on
354 Set the number of sectors/track to
355 .Ar num .
356 .El
357 .Pp
358 These specs can occur in any order, as the leading letter determines
359 which value is which; however, all three must be specified.
360 .Pp
361 This line must occur before any lines that specify partition
362 information.
363 .Pp
364 It is an error if the following is not true:
365 .Bd -literal -offset indent
366 1 <= number of cylinders
367 1 <= number of heads <= 256
368 1 <= number of sectors/track < 64
369 .Ed
370 .Pp
371 The number of cylinders should be less than or equal to 1024, but this
372 is not enforced, although a warning will be output.
373 Note that bootable
374 .Fx
375 partitions (the "/" file system) must lie completely within the
376 first 1024 cylinders; if this is not true, booting may fail.
377 Non-bootable partitions do not have this restriction.
378 .Pp
379 Example (all of these are equivalent), for a disk with 1019 cylinders,
380 39 heads, and 63 sectors:
381 .Bd -literal -offset indent
382 g       c1019   h39     s63
383 g       h39     c1019   s63
384 g       s63     h39     c1019
385 .Ed
386 .It Xo
387 .Ic p
388 .Ar partition
389 .Ar type
390 .Ar start
391 .Ar length
392 .Xc
393 Set the partition given by
394 .Ar partition
395 (1-4) to type
396 .Ar type ,
397 starting at sector
398 .Ar start
399 for
400 .Ar length
401 sectors.
402 .Pp
403 Only those partitions explicitly mentioned by these lines are modified;
404 any partition not referenced by a "p" line will not be modified.
405 However, if an invalid partition table is present, or the
406 .Fl i
407 option is specified, all existing partition entries will be cleared
408 (marked as unused), and these "p" lines will have to be used to
409 explicitly set partition information.
410 If multiple partitions need to be
411 set, multiple "p" lines must be specified; one for each partition.
412 .Pp
413 These partition lines must occur after any geometry specification lines,
414 if one is present.
415 .Pp
416 The
417 .Ar type
418 is 165 for
419 .Fx
420 partitions.
421 Specifying a partition type of zero is
422 the same as clearing the partition and marking it as unused; however,
423 dummy values (such as "0") must still be specified for
424 .Ar start
425 and
426 .Ar length .
427 .Pp
428 Note: the start offset will be rounded upwards to a head boundary if
429 necessary, and the end offset will be rounded downwards to a cylinder
430 boundary if necessary.
431 .Pp
432 Example: to clear partition 4 and mark it as unused:
433 .Bd -literal -offset indent
434 p       4       0       0       0
435 .Ed
436 .Pp
437 Example: to set partition 1 to a
438 .Fx
439 partition, starting at sector 1
440 for 2503871 sectors (note: these numbers will be rounded upwards and
441 downwards to correspond to head and cylinder boundaries):
442 .Bd -literal -offset indent
443 p       1       165     1       2503871
444 .Ed
445 .It Xo
446 .Ic a
447 .Ar partition
448 .Xc
449 Make
450 .Ar partition
451 the active partition.
452 Can occur anywhere in the config file, but only
453 one must be present.
454 .Pp
455 Example: to make partition 1 the active partition:
456 .Bd -literal -offset indent
457 a       1
458 .Ed
459 .El
460 .Sh FILES
461 .Bl -tag -width /boot/mbr -compact
462 .It Pa /boot/mbr
463 The default boot code
464 .El
465 .Sh SEE ALSO
466 .Xr disklabel 8
467 .Sh BUGS
468 The default boot code will not necessarily handle all partition types
469 correctly, in particular those introduced since MS-DOS 6.x.
470 .Pp
471 The entire program should be made more user-friendly.
472 .Pp
473 Throughout this man page, the term
474 .Sq partition
475 is used where it should actually be
476 .Sq slice ,
477 in order to conform with the terms used elsewhere.
478 .Pp
479 You cannot use this command to completely dedicate a disk to
480 .Fx .
481 The
482 .Xr disklabel 8
483 command must be used for this.