Date: Thu, 03 Oct 1996 00:35:29 -0700 From: Darryl Okahata <darrylo@hpnmhjw.sr.hp.com> To: hackers@freefall.freebsd.org Cc: "Jordan K. Hubbard" <jkh@freefall.freebsd.org> Subject: configdisk -- initializing disks via shell scripts Message-ID: <199610030735.AA013868129@hpnmhjw.sr.hp.com>
next in thread | raw e-mail | index | archive | help
FYI ...
On freefall, I've placed an alpha-test copy of "configdisk", a
perl4 program that generates Bourne shell scripts that initialize disks
via fdisk, disklabel, and, optionally, newfs. Configdisk is designed to
be used by intermediate- to expert-level users, as it still requires
knowledge of how fdisk(8), disklabel(8), and newfs(8) work. However, it
does help to greatly simplify the task of adding a disk to FreeBSD (I
hope ;-).
This is an alpha-test version. I'd like to get feedback on it
before munging and submitting it as a package. Am I off-base, am I out
of my mind, or am I stuck in California?
Configdisk requires a specially-modified version of fdisk to work,
the sources to which are included in the configdisk tarball:
ftp://freefall.freebsd.org/incoming/configdisk-0.8.tar.gz
A couple of weeks ago, Jordan said that he'd like a little script to go
along with my proposed fdisk changes, and this is the result (but it's
not exactly "little" ;-).
I've appended a copy of the documentation to the end of this
message (note: as yet, no man page exists -- this is all the
documentation that currently exists).
-- Darryl Okahata
Internet: darrylo@sr.hp.com
DISCLAIMER: this message is the author's personal opinion and does not
constitute the support, opinion, or policy of Hewlett-Packard, or of the
little green men that have been following him all day.
===============================================================================
NAME
configdisk -- Generate a shell script that initializes a disk
SYNOPSIS
configdisk [-D] [-I] [-f file] [-S size] disk
DESCRIPTION
The "configdisk" program generates a Bourne shell script that runs
fdisk, disklabel, and newfs to initialize an hard disk. The drive
is specified by "disk", which is a base drive name like "sd1" or
"wd1". This program is designed to simplify the task of adding a
disk to FreeBSD.
This program runs fdisk(8) and disklabel(8) to get the current
drive settings, which can then be edited by the user. After
appropriately editing the settings, a shell script is generated.
This program must be run as root, as this program must be able to
read information from the various disk devices. However, the
access is read-only; no data is actually written to a drive by
this program. To actually change a drive, the generated shell
script must be executed.
Note that the shell script will only go as far as running newfs on
the various FreeBSD partitions, if you specified that this be
done. It will not modify /etc/fstab or mount any filesystems.
Advantages/features are:
1. All the information is obtained and used by one program.
Currently, you have to use fdisk/disklabel separately, and
possibly re-enter the same (geometry/partitioning) information
in both programs.
2. Input values (e.g., geometry) are checked for consistency.
3. A shell script is generated to do the actual work. Because of
this, it's easy to initialize a second (identical) disk to be
the same as the first. It's also easy to modify, or verify
what it does, for debugging/verification purposes.
4. A simple slice editor is included (similar to "fdisk -i").
5. A simple partition editor is included (for editing disklabel
partitions).
6. configdisk is intended for expert- or intermediate-level
users. This program does not have a "novice mode" that asks
questions and produces output; you still have to understand
fdisk(8) and disklabel(8), and know what steps to do.
However, it does simplify/unify the steps needed to
initialize a disk.
7. configdisk will refuse to work with currently-mounted drives,
or drives that don't exist.
8. When setting the disk geometry, questionable code to guess
the geometry for NCR and Adaptec SCSI adapters can be used
(enter "n" or "a" when asked the number of cylinders).
The following options are available:
-D Dedicate the entire disk to FreeBSD. This will cause any
and all existing data on the entire disk to be lost.
This will also make the disk unusable and unshareable
with other operating systems, as the disk slice table
(the "partition table", in MSDOS terminology) will not
be usable by them. Use with caution. Implies -I.
-I Force disk initialization. This causes the MBR and boot
sectors to be initialized. This will cause any and all
existing data on the entire disk to be lost. Use with
caution.
The current default is to not force disk initialization
unless an invalid slice table is found, or unless the
entire drive is dedicated to FreeBSD.
-f script_filename
Set the default script filename to "<script_filename>".
-S disksize
Force the size of the whole disk to be "disksize". Note
that this is the size of the entire disk, including all
slices and partitions. Only needed for those drives
whose size cannot be determined via disklabel(8).
BRIEF TUTORIAL
To create a Bourne shell script that configures an uninitialized
disk, do the following:
1. Determine the base name of the drive that you want to add.
Example: "sd1" or "wd1". The rest of this tutorial will
assume that the base drive name is "sd1".
2. Decide if you want to dedicate the entire disk to FreeBSD.
If you do, run:
configdisk -I -D sd1
If you don't, run:
configdisk -I sd1
If you don't, you also have to determine the correct
boot/BIOS geometry for your disk. Do that now (doing this is
not discussed here, as that is outside the scope of this
document).
3. If you are NOT dedicating the entire disk to FreeBSD, press
"f" to enter the fdisk editor. If you are dedicating the
entire disk to FreeBSD, skip to step #4.
3a. Use the "g" ("set geometry") command to enter the correct
geometry. This must be done before any slices are edited.
3b. Use the "e" ("edit slice") to add a FreeBSD slice and any
other slices that you want.
3c. Press "q" ("quit to previous menu") to return to the main
menu.
4. Press "d" to enter the disklabel editor. [ You can skip to
step #5 if you want to allocate the entire FreeBSD slice as a
single filesystem partition. However, you will have to run
newfs manually to put a filesystem onto the partition. ]
4a. Use the "e" ("edit partition") command to allocate desired
FreeBSD partitions.
4b. Press "q" ("quit to previous menu") to return to the main
menu.
5. Press "w" ("write script") to write out your changes as a
Bourne shell script.
6. Press "q" to exit the program.
7. Examine the Bourne shell script created in step #5. If it
looks good, execute it to initialize and configure the disk.
8. That's it! From here, you'll have to modify /etc/fstab
yourself or run mount(8) manually.
REFERENCE
When started, configdisk displays the drive's status, and prompts
for a command. At this point, you have a choice of these
commands:
F Enter fdisk editor. From here, you can set the disk's
geometry and edit the slice table (the "partition
table", in MSDOS terminology). Note that the disk
geometry must be properly set BEFORE editing the slice
table, as the current disk geometry determines the legal
values for each slice entry.
Editing the slice table is not necessary for dedicated
disks (and is disallowed by configdisk).
D Enter disklabel editor. From here, you can set the
disk's geometry (just like the fdisk editor), and
create/modify FreeBSD partitions.
Before you can enter the disklabel editor, the entire
disk must be dedicated to FreeBSD, or a valid FreeBSD
slice must exist or have been defined in the fdisk
editor.
U ("Use entire disk") Toggle between dedicating the entire
disk to FreeBSD and using the slice table to allocate a
portion of it.
Dedicating the entire disk has the advantage of using
all of the available disk space (no space is wasted due
to geometry restrictions). This will also cause any
and all existing data on the entire disk to be lost.
This will also make the disk unusable and unshareable
with other operating systems, as the disk slice table
(the "partition table", in MSDOS terminology) will not
be usable by them.
Not dedicating the disk has the advantage of
sharing/using the disk with other operating systems.
For example, the disk could be used with both Windows 95
and FreeBSD. However, some disk space can be wasted,
due to geometry restrictions.
Every time this command is used to convert the disk from
a dedicated FreeBSD disk to a non-dedicated one, all
disklabel changes are lost.
I Toggle between initializing the drive and not
initializing it.
WARNING: Initializing a drive will cause all data on the
disk, be it FreeBSD data or Windows 95 files, to be
completely lost.
Initializing a drive forces the rewriting of the MBR and
boot programs. If the disk is not dedicated, the slice
table will be competely rewritten to reflect the state
of the fdisk editor. Normally, only those slices
modified in the fdisk editor are changed in the slice
table; the other slices are left untouched. However, if
a drive is initialized, all slices are set to the state
displayed in the fdisk editor (for non-dedicated disks).
W Write configuration script. This is the command that
actually writes the Bourne shell script that does the
work. Note that, unless this command is chosen, no
script is written.
Q Quit program.
NOTES, NON-FEATURES, AND BUGS
The fdisk and disklabel editors have not yet been documented.
When a non-dedicated disk is specified, slices must definitely end
on cylinder boundaries. However, the slice start requirements are
unclear. Currently, configdisk requires that a slice start begin
on an head boundary. This may be too restrictive.
The built-in geometry calculator may not be correct for all NCR
and Adaptec SCSI controllers.
Is partition 'd' special (like partitions `a-c')? Currently,
configdisk allows you to edit it.
The generated script requires a specially-modified fdisk to work.
The configdisk program is actually a perl script from h*ll. You
need to have perl4 installed as /usr/bin/perl, and you need a
couple of standard perl libraries (which should already be
installed under /usr/share/perl).
Currently, configdisk uses the disk's current settings (slice
table & disklabel) as a starting point. Perhaps "-I" should be
the default, and the current settings be used only if another
option ("-c"?) is specified?
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199610030735.AA013868129>
