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