# filesystem-floppy disk /install
# Simplified, interactive *BSD installation script.
# D.E. Silvia (dsilvia@net.com)
# Heavily hacked on by cgd and rwgrimes and miscilanious times
# comments here are brief to save disk space!
echo "Welcome to ${OPSYSTEM}."
echo "This program is designed to help put ${OPSYSTEM} on a hard disk,"
echo "in a simple and rational way. We'll ask you several questions,"
echo "and it would probably be useful to have a disk's hardware"
echo "manual, the installation notes, and a calculator handy."
echo "In particular, we need to know some reasonably detailed"
echo "information about the disk's geometry, because there is currently"
echo "no way we can figure out this information by ourselves."
echo "As with anything which modifies a hard drive's contents, this"
echo "program can cause SIGNIFICANT data loss, and we strongly recommend"
echo "making sure that the hard drive is backed up before going further with"
echo "the installation process."
echo -n "Proceed with installation? [y] "
if [ "$resp" = "" ]; then
echo "Cool! Let's get to it..."
echo "If a mistake is made along the way, don't bail out."
echo "At the end, you have the option to redo the configuration."
echo "If you really must bail out at some point, then type <CTRL>+C,"
echo "and enter \`halt' at the command prompt \`#'."
echo "OK, then enter 'halt' to halt the machine."
echo "Once the machine has halted, remove the floppy,"
echo "and press any key to reboot."
while [ "$verified_install" = "" ]; do # Begin of Big Loop
echo "First, we need to know the drive type. This can be can be one of"
echo "ESDI, SCSI, ST506, or IDE."
echo -n "Drive type? [IDE] "
if [ "$type" = "" ]; then
echo -n "Does it support _automatic_ sector remapping? [y] "
echo "Unknown type. Assuming ST506 with automatic sectoring..."
echo "Disk is of device type $drivetype."
echo "Installing on device /dev/$drivename..."
echo "Now we want to build a data base entry in /etc/disktab describing"
echo "the geometry of the /dev/$drivename disk. The name of the entry"
echo "should be descriptive of the disk's type and model. For example,"
echo "a Maxtor IDE, model 7080 disk might be named \`maxtor7080'."
echo -n "Disk label name (one word, please)? [mfr_model] "
if [ "$name" = "" ]; then
echo -n "Number of bytes per disk sector? [512] "
if [ "$bytes_per_sect" = "" ]; then
echo -n "Total number of disk cylinders? [$DEFCYLN] "
if [ "$cyls_per_disk" = "" ]; then
echo -n "Number of disk heads (i.e., tracks/cylinder)? [$DEFHEAD] "
if [ "$tracks_per_cyl" = "" ]; then
echo -n "Number of disk sectors (i.e., sectors/track)? [$DEFSECT] "
read sects_per_track junk
if [ "$sects_per_track" = "" ]; then
cylindersize
=`expr $sects_per_track \* $tracks_per_cyl`
disksize
=`expr $cylindersize \* $cyls_per_disk`
mb_sect
=`expr 1024 \* 1024 / $bytes_per_sect`
mb_per_disk
=`expr $disksize / $mb_sect`
echo "Disk has a total of $mb_per_disk Mb."
echo "It must be divided into at least two partitions: one for the root"
echo "filesystem and one for swap. In addition, it is a very good idea to"
echo "have at least a third partition for the /usr filesystem."
echo "For greater efficiency, partitions should begin and end on cylinder"
echo "boundaries. If you know the size NN in Megabytes (Mb) of a partition"
echo "you want, then use the following formula to determine the number NC of"
echo " NC = integer { ( NN * $mb_sect ) / $cylindersize }"
echo -n "Total size of the ${OPSYSTEM} portion of the disk (in cylinders)? [${cyls_per_disk}] "
if [ "$partition" = "" ]; then
partition
=`expr $partition \* $cylindersize`
if [ $partition -lt $disksize ]; then
echo -n "Offset from beginning of the disk of first ${OPSYSTEM} partition (in cylinders)? [0] "
if [ "$part_offset" = "" ]; then
part_offset
=`expr $part_offset \* $cylindersize`
if [ "$sect_fwd" = "sf:" ]; then
badspacecyl
=`expr $sects_per_track + 126`
badspacecyl
=`expr $badspacecyl + $cylindersize - 1`
badspacecyl
=`expr $badspacecyl / $cylindersize`
badspacesec
=`expr $badspacecyl \* $cylindersize`
echo -n "Using $badspacesec sectors ($badspacecyl cylinders) for the "
echo "bad144 bad block table"
whats_left
=`expr $partition - $badspacesec`
cyl_left
=`expr $whats_left / $cylindersize`
mb_left
=`expr $whats_left / $mb_sect`
echo "There are $mb_left Mb ($cyl_left cylinders) to allocate."
# set default root partition to 15MB
part_size
=`expr \( 15 \* $mb_sect \) / $cylindersize`
if [ $part_size -gt $cyl_left ]; then
echo "The root partition is usually no larger than about 15 Mb, and sometimes"
echo "as small as 7 or 8 Mb."
while [ $root -eq 0 ]; do
echo -n "Root partition size (in cylinders)? [${part_size}] "
if [ "$root" = "" ]; then
root
=`expr $root \* $cylindersize`
if [ $total -gt $whats_left ]; then
echo Total is greater than remaining free space
part_used
=`expr $root + $badspacesec`
whats_left
=`expr $partition - $part_used`
cyl_left
=`expr $whats_left / $cylindersize`
mb_left
=`expr $whats_left / $mb_sect`
# DO NOT USE DIFFERENT BLOCKING FACTORS FOR EACH PARITION.. IT TRASHES THE
# VM SYSTEM! When that gets fixed this can go back the way it was...
echo "We can build the filesystems with block/fragment sizes of either"
echo " 1) 4k/512, to save disk space at the expense of speed, or"
echo " 2) 8k/1k for speed at the expense of disk space."
echo -n "Which blocking factor should we use for the filesystems? "
echo -n "[$DEFBLOCKING] "
read blocking_factor junk
if [ "$blocking_factor" = "" ]; then
blocking_factor
=$DEFBLOCKING
DEFBLOCKING
=$blocking_factor
fragsize
=`expr $bytes_per_sect \* $blocking_factor`
blocksize
=`expr $bytes_per_sect \* $blocking_factor \* 8`
minswap
=`expr 8 \* $mb_sect`
min_cyl
=`expr $minswap / $cylindersize`
while [ $swap -eq 0 ]; do
echo "$mb_left Mb ($cyl_left cylinders) remaining in ${OPSYSTEM} portion of disk."
echo "Minimum swap space is $min_cyl cylinders."
echo "For running X, if your RAM size is NR Mb, then the recomended swap"
echo "size NS (in cylinders) is:"
echo " NS = integer { ( 2.1 x NR x $mb_sect ) / ${cylindersize} }"
part_size
=`expr \( 21 \* $mb_ram \* $mb_sect \) / 10`
part_size
=`expr $part_size / ${cylindersize}`
# but not swap size more than 10% of disk size...
swap_quot
=`expr $mb_left / $mb_ram`
if [ $swap_quot -lt 10 ]; then
echo -n "Swap partition size (in cylinders)? [${part_size}] "
if [ "$swap_cyl" = "" ]; then
swap
=`expr $swap_cyl \* $cylindersize`
if [ $swap_cyl -gt $cyl_left ]; then
echo "Swap size is greater than remaining free space"
if [ $swap_cyl -lt $min_cyl ]; then
echo "Swap space must be greater than $min_cyl"
swap_offset
=`expr $root_offset + $root`
part_used
=`expr $part_used + $swap`
echo "$name|${OPSYSTEM} installation generated:\\" >>/etc
/disktab
echo " :dt=${type}:ty=winchester:\\" >>/etc
/disktab
echo -n " :nc#${cyls_per_disk}:ns#${sects_per_track}" >>/etc
/disktab
echo ":nt#${tracks_per_cyl}:\\" >>/etc
/disktab
echo " :se#${bytes_per_sect}:${sect_fwd}\\" >>/etc
/disktab
echo -n " :pa#${root}:oa#${root_offset}" >>/etc
/disktab
echo ":ta=4.2BSD:ba#${blocksize}:fa#${fragsize}:\\" >>/etc
/disktab
echo " :pb#${swap}:ob#${swap_offset}:tb=swap:\\" >>/etc
/disktab
echo " :pc#${partition}:oc#${part_offset}:\\" >>/etc
/disktab
ename
="";fname
="";gname
="";hname
=""
echo "Now we enter information about any other partitions and filesystems"
echo "to be created in the ${OPSYSTEM} portion of the disk. This process"
echo "is complete when we've filled up all remaining space in the ${OPSYSTEM}"
echo "portion of the disk."
while [ $part_used -lt $partition ]; do
whats_left
=`expr $partition - $part_used`
cyl_left
=`expr $whats_left / $cylindersize`
mb_left
=`expr $whats_left / $mb_sect`
while [ $part_size -eq 0 ]; do
echo "$mb_left Mb ($cyl_left cylinders) remaining in ${OPSYSTEM} portion of disk."
echo -n "Next partition size (in cylinders)? [${cyl_left}] "
if [ "$part_size" = "" ]; then
part_size
=`expr $part_size \* $cylindersize`
total
=`expr $part_used + $part_size`
if [ $total -gt $partition ]; then
echo Total is greater than partition size
while [ "$part_name" = "" ]; do
echo -n "On which directory should this filesystem be mounted? [usr] "
if [ "$part_name" = "" ]; then
part_name
=`expr "$part_name" : '/*\(.*\)'`
if [ "$ename" = "" ]; then
offset
=`expr $part_offset + $root + $swap`
echo -n " :pe#${part_size}:oe#${offset}" >>/etc
/disktab
echo ":te=4.2BSD:be#${blocksize}:fe#${fragsize}:\\" >>/etc
/disktab
offset
=`expr $offset + $part_size`
elif [ "$fname" = "" ]; then
echo -n " :pf#${part_size}:of#${offset}" >>/etc
/disktab
echo ":tf=4.2BSD:bf#${blocksize}:ff#${fragsize}:\\" >>/etc
/disktab
offset
=`expr $offset + $part_size`
elif [ "$gname" = "" ]; then
echo -n " :pg#${part_size}:og#${offset}" >>/etc
/disktab
echo ":tg=4.2BSD:bg#${blocksize}:fg#${fragsize}:\\" >>/etc
/disktab
offset
=`expr $offset + $part_size`
elif [ "$hname" = "" ]; then
echo -n " :ph#${part_size}:oh#${offset}" >>/etc
/disktab
echo ":th=4.2BSD:bh#${blocksize}:fh#${fragsize}:\\" >>/etc
/disktab
echo " :pd#${disksize}:od#0:" >>/etc
/disktab
echo -n "Verbose installation? [n] "
echo "OK! THIS IS THE LAST CHANCE!!! Data on the hard disk wil be lost."
echo -n "Are you sure you want to install on the hard drive? (yes/no) "
while [ "$answer" = "" ]; do
echo -n "Would you like to change the configuration? [y] "
if [ "$answer" = "" ]; then
echo "OK, then enter 'halt' to halt the machine."
echo "Once the machine has halted, remove the floppy,"
echo "and press any key to reboot."
echo "Please spell out either of \`yes' or \`no'..."
echo -n "Install on the hard disk? (yes/no) "
echo -n "Labelling disk..."
/sbin
/disklabel
-w -r $drivename $name /usr
/mdec
/${drivetype}boot
/usr
/mdec
/boot
${drivetype}
if [ "$sect_fwd" = "sf:" ]; then
echo -n "Initializing bad144 badblock table..."
echo "Scanning disk for bad blocks..."
echo "Initializing root filesystem, and mounting..."
newfs
${rotdelay} /dev
/r
${drivename}a
$name
mount
-v /dev
/${drivename}a
/mnt
if [ "$ename" != "" ]; then
echo "Initializing $ename filesystem, and mounting..."
newfs
${rotdelay} /dev
/r
${drivename}e
$name
mount
-v /dev
/${drivename}e
/mnt
/$ename
if [ "$fname" != "" ]; then
echo "Initializing $fname filesystem, and mounting..."
newfs
${rotdelay} /dev
/r
${drivename}f
$name
mount
-v /dev
/${drivename}f
/mnt
/$fname
if [ "$gname" != "" ]; then
echo "Initializing $gname filesystem, and mounting..."
newfs
${rotdelay} /dev
/r
${drivename}g
$name
mount
-v /dev
/${drivename}g
/mnt
/$gname
if [ "$hname" != "" ]; then
echo "Initializing $hname filesystem, and mounting..."
newfs
${rotdelay} /dev
/r
${drivename}h
$name
mount
-v /dev
/${drivename}h
/mnt
/$hname
echo "Copying to disk..."
cat filelist |
cpio -pdamu${cpioverbose} /mnt
echo "/dev/${drivename}a / ufs rw 1 1" >etc
/fstab
if [ "$ename" != "" ]; then
echo "/dev/${drivename}e /$ename ufs rw 1 2" >>etc
/fstab
if [ "$fname" != "" ]; then
echo "/dev/${drivename}f /$fname ufs rw 1 3" >>etc
/fstab
if [ "$gname" != "" ]; then
echo "/dev/${drivename}g /$gname ufs rw 1 4" >>etc
/fstab
if [ "$hname" != "" ]; then
echo "/dev/${drivename}h /$hname ufs rw 1 5" >>etc
/fstab
cat /etc
/disktab
>etc
/disktab.
install
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/usr/contrib/bin:.:
echo "Insert cpio floppy in a drive and enter"
echo -n "that drive's number (e.g. 0 or 1): [0]"
if [ "\$driveno" = "" ]; then
mount -o ro /dev/fd\${driveno}a /mnt
echo "The next step: reboot from the kernel-copy disk, copy a kernel"
echo "to the hard disk, and finally reboot from the hard disk."
echo "To do this, enter 'halt' now to halt the machine. After it"
echo "announces that it has halted, remove the floppy from the drive"
echo "and insert the kernel-copy disk that was booted before."
echo "Press any key to reboot."
echo "When prompted to insert the file system floppy, this time just"
echo "hit RETURN without changing floppies. If all goes well, you can"
echo "enter the command \`copy' at the prompt to copy the kernel to the"
echo "hard disk. When asked for which partition to copy to, enter to"
echo "\`${drivename}a' (without the quotes)."
echo "Okay, that's all for now. I'm waiting for you to enter \`halt'..."