# install1.fs disk 'install'
# Simplified, interactive NetBSD installation script.
# D.E. Silvia (dsilvia@net.com)
# (once again hacked on by rgrimes 1993/07/29,
# disabled old disktab.preinstall,
# added questions for what blocking factor to use in the file system,
# added (heads) to clarify what disk tracks means)
# (heavily hacked by cgd)
# (and again by rwgrimes, for bad144 support and some error checking)
# Provides for variable swap and multiple partitions.
# Installs first minimal part of basic NetBSD system.
# Does not appear to work properly IF not using whole disk _AND_ there is
# no DOS partition (kernel bug? Tries to chroot to partition 'd' :-{ )
# Currently, no method for checking to see if the designated disk type is
# already in /etc/disktab. You can edit it out of the file after installation.
echo "Welcome to the NetBSD."
echo "This program is designed to help you put NetBSD on your hard disk,"
echo "in a simple and rational way. You'll be asked several questions,"
echo "and it would probably be useful to have your disk's hardware"
echo "manual, the installation notes, and a calculator handy."
echo "In particular, you will need to know some reasonably detailed"
echo "information about your disk's geometry, because there is currently"
echo "no way this this program can figure that information out."
echo "As with anything which modifies your hard drive's contents, this"
echo "program can cause SIGNIFICANT data loss, and you are advised"
echo "to make sure your hard drive is backed up before beginning the"
echo "installation process."
echo -n "Proceed with installation? [n] "
echo "Cool! Let's get to it..."
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 "Drive types can be ESDI, SCSI, ST506, or IDE."
echo -n "Does it support _automatic_ sector remapping? [y] "
echo "Disk is of type $drivetype"
echo "going to install on $drivename..."
echo -n "Label name (what kind of disk is it, one word please)? "
echo -n "Number of bytes per disk sector? [512] "
if [ "$bytes_per_sect" = "" ]; then
echo -n "Number of disk cylinders? "
echo -n "Number of disk tracks (heads) per disk cylinder? "
echo -n "Number of disk sectors per disk track? "
cylindersize
=`expr $sects_per_track \* $tracks_per_cyl`
disksize
=`expr $cylindersize \* $cyls_per_disk`
echo "Disk has a total of $disksize $bytes_per_sect byte sectors"
echo "For greater efficiency, partitions should begin and end on cylinder"
echo "boundaries. Cylinder size (in $bytes_per_sect byte sectors) on this"
echo "disk is $cylindersize. Choose multiples of this value."
echo -n "Size of NetBSD portion of disk (in $bytes_per_sect byte sized sectors)? "
if [ $partition -lt $disksize ]; then
echo -n "Offset of NetBSD portion of disk (in $bytes_per_sect byte sized sectors) "
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`
echo "There are $whats_left sectors ($cyl_left cylinders) left to allocate"
while [ $root -eq 0 ]; do
echo -n "Root partition size (in $bytes_per_sect byte sized sectors)? "
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`
while [ $swap -eq 0 ]; do
echo "$whats_left sectors remaining in NetBSD portion of disk"
echo -n "Swap partition size (in $bytes_per_sect byte sized sectors)? "
if [ $swap -gt $whats_left ]; then
echo Swap size is greater than remaining free space
echo -n "What blocking factor should be used for the filesystem? [1] "
if [ "$blocking_factor" = "" ]; then
swap_offset
=`expr $root_offset + $root`
part_used
=`expr $part_used + $swap`
fragsize
=`expr $bytes_per_sect \* $blocking_factor`
blocksize
=`expr $bytes_per_sect \* $blocking_factor \* 8`
echo "$name|NetBSD 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 "You will now have to enter information about any other partitions"
echo "to be created in the NetBSD portion of the disk. This process will"
echo "be complete when you've filled up all remaining space in the NetBSD"
echo "portion of the disk."
while [ $part_used -lt $partition ]; do
whats_left
=`expr $partition - $part_used`
while [ $part_size -eq 0 ]; do
echo "$whats_left sectors remaining in NetBSD portion of disk"
echo -n "Next partition size (in $bytes_per_sect byte sized sectors)? "
total
=`expr $part_used + $part_size`
if [ $total -gt $partition ]; then
echo Total is greater than partition size
while [ "$part_name" = "" ]; do
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
#No longer provide a disktab.preinstall on the floppy!
#cat /etc/disktab.preinstall >> /etc/disktab
echo "OK! THIS IS YOUR LAST CHANCE!!!"
echo -n "Are you sure you want this stuff installed on your hard drive? (yes/no) "
while [ "$answer" = "" ]; do
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 -n "I want a yes or no answer... well? "
echo -n "Labelling disk..."
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 "Initializing root filesystem, and mounting..."
newfs
/dev
/r
${drivename}a
$name
mount
-v /dev
/${drivename}a
/mnt
if [ "$ename" != "" ]; then
echo "Initializing $ename filesystem, and mounting..."
newfs
/dev
/r
${drivename}e
$name
mount
-v /dev
/${drivename}e
/mnt
/$ename
if [ "$fname" != "" ]; then
echo "Initializing $fname filesystem, and mounting..."
newfs
/dev
/r
${drivename}f
$name
mount
-v /dev
/${drivename}f
/mnt
/$fname
if [ "$gname" != "" ]; then
echo "Initializing $gname filesystem, and mounting..."
newfs
/dev
/r
${drivename}g
$name
mount
-v /dev
/${drivename}g
/mnt
/$gname
if [ "$hname" != "" ]; then
echo "Initializing $hname filesystem, and mounting..."
newfs
/dev
/r
${drivename}h
$name
mount
-v /dev
/${drivename}h
/mnt
/$hname
echo -n "Verbose installation? [n] "
tar cfp
- `cat /dirlist` |
(cd /mnt
; tar xfp
${tarverbose} - )
echo /dev
/${drivename}a
/ ufs rw
1 1 >etc
/fstab
echo "kernfs /kern kernfs 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
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/usr/contrib/bin:.:
echo "Insert second installation floppy in drive and"
echo -n "enter that drive's number (e.g. 0 or 1): "
mount -o ro /dev/fd\${driveno}a /mnt
echo "The next step: reboot from the kernel copy disk, copy a"
echo "kernel to your hard disk (to partition ${drivename}a), then reboot"
echo "from the hard disk."
echo "Enter 'halt' to halt the machine."
echo "Once the machine has halted, replace the floppy in the disk drive"
echo "with the kernel-copy disk that you originally booted from."
echo "Once you have done that, press any key to reboot."