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