1#!/bin/sh 2# 3# $NetBSD: install.md,v 1.3 2001/08/16 19:14:41 tv Exp $ 4# 5# Copyright (c) 1996 The NetBSD Foundation, Inc. 6# All rights reserved. 7# 8# This code is derived from software contributed to The NetBSD Foundation 9# by Jason R. Thorpe. 10# 11# Redistribution and use in source and binary forms, with or without 12# modification, are permitted provided that the following conditions 13# are met: 14# 1. Redistributions of source code must retain the above copyright 15# notice, this list of conditions and the following disclaimer. 16# 2. Redistributions in binary form must reproduce the above copyright 17# notice, this list of conditions and the following disclaimer in the 18# documentation and/or other materials provided with the distribution. 19# 3. All advertising materials mentioning features or use of this software 20# must display the following acknowledgement: 21# This product includes software developed by the NetBSD 22# Foundation, Inc. and its contributors. 23# 4. Neither the name of The NetBSD Foundation nor the names of its 24# contributors may be used to endorse or promote products derived 25# from this software without specific prior written permission. 26# 27# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 28# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 29# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 30# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE 31# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 32# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 33# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 34# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 35# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 36# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 37# POSSIBILITY OF SUCH DAMAGE. 38# 39 40# 41# machine dependent section of installation/upgrade script 42# 43 44# Machine-dependent install sets 45MDSETS="" 46 47md_set_term() { 48 if [ ! -z "$TERM" ]; then 49 return 50 fi 51 echo -n "Specify terminal type [vt100]: " 52 getresp "vt100" 53 TERM="$resp" 54 export TERM 55 # XXX call tset? 56} 57 58__mount_kernfs() { 59 # Make sure kernfs is mounted. 60 if [ ! -d /kern -o ! -e /kern/msgbuf ]; then 61 mkdir /kern > /dev/null 2>&1 62 /sbin/mount_kernfs /kern /kern >/dev/null 2>&1 63 fi 64} 65 66md_makerootwritable() { 67 # Just remount the root device read-write. 68 __mount_kernfs 69 echo "Remounting root read-write..." 70 mount -t ffs -u /kern/rootdev / 71} 72 73md_get_diskdevs() { 74 # return available disk devices 75 __mount_kernfs 76 sed -n -e '/^sd[0-9] /s/ .*//p' \ 77 < /kern/msgbuf | sort -u 78} 79 80md_get_cddevs() { 81 # return available CDROM devices 82 __mount_kernfs 83 sed -n -e '/^cd[0-9] /s/ .*//p' \ 84 < /kern/msgbuf | sort -u 85} 86 87md_get_ifdevs() { 88 # return available network devices 89 __mount_kernfs 90 sed -n -e '/^le[0-9] /s/ .*//p' \ 91 -e '/^ie[0-9] /s/ .*//p' \ 92 < /kern/msgbuf | sort -u 93} 94 95md_get_partition_range() { 96 # return an expression describing the valid partition id's 97 echo '[a-h]' 98} 99 100md_installboot() { 101 # install the boot block on disk $1 102 echo "Installing boot block..." 103 ( cd /usr/mdec ;\ 104 cp -p ./bootsd /mnt/.bootsd ;\ 105 sync ; sleep 1 ; sync ;\ 106 ./installboot -v /mnt/.bootsd bootxx /dev/r${1}a ) 107 echo "done." 108} 109 110md_native_fstype() { 111} 112 113md_native_fsopts() { 114} 115 116md_checkfordisklabel() { 117 # $1 is the disk to check 118 local rval 119 120 disklabel $1 > /dev/null 2> /tmp/checkfordisklabel 121 if grep "no disk label" /tmp/checkfordisklabel; then 122 rval=1 123 elif grep "disk label corrupted" /tmp/checkfordisklabel; then 124 rval=2 125 else 126 rval=0 127 fi 128 129 rm -f /tmp/checkfordisklabel 130 return $rval 131} 132 133md_prep_disklabel() 134{ 135 local _disk 136 137 _disk=$1 138 md_checkfordisklabel $_disk 139 case $? in 140 0) 141 echo -n "Do you wish to edit the disklabel on $_disk? [y]" 142 ;; 143 1) 144 echo "WARNING: Disk $_disk has no label" 145 echo -n "Do you want to create one with the disklabel editor? [y]" 146 ;; 147 2) 148 echo "WARNING: Label on disk $_disk is corrupted" 149 echo -n "Do you want to try and repair the damage using the disklabel editor? [y]" 150 ;; 151 esac 152 153 getresp "y" 154 case "$resp" in 155 y*|Y*) ;; 156 *) return ;; 157 esac 158 159 # display example 160 cat << \__md_prep_disklabel_1 161 162Here is an example of what the partition information will look like once 163you have entered the disklabel editor. Disk partition sizes and offsets 164are in sector (most likely 512 bytes) units. Make sure these size/offset 165pairs are on cylinder boundaries (the number of sector per cylinder is 166given in the `sectors/cylinder' entry, which is not shown here). 167 168Do not change any parameters except the partition layout and the label name. 169It's probably also wisest not to touch the `8 partitions:' line, even 170in case you have defined less than eight partitions. 171 172[Example] 1738 partitions: 174# size offset fstype [fsize bsize cpg] 175 a: 50176 0 4.2BSD 1024 8192 16 # (Cyl. 0 - 111) 176 b: 64512 50176 swap # (Cyl. 112 - 255) 177 c: 640192 0 unknown # (Cyl. 0 - 1428) 178 d: 525504 114688 4.2BSD 1024 8192 16 # (Cyl. 256 - 1428) 179[End of example] 180 181__md_prep_disklabel_1 182 echo -n "Press [Enter] to continue " 183 getresp "" 184 edlabel /dev/r${_disk}c 185} 186 187md_copy_kernel() { 188 echo -n "Copying kernel..." 189 cp -p /netbsd /mnt/netbsd 190 echo "done." 191} 192 193md_welcome_banner() { 194 echo "Welcome to the NetBSD/mvme68k ${VERSION} installation program." 195 cat << \__welcome_banner_1 196 197This program is designed to help you install NetBSD on your system in a simple 198and rational way. You'll be asked several questions, and it would probably be 199useful to have your disk's hardware manual, the installation notes, and a 200calculator handy. 201 202In particular, you will need to know some reasonably detailed information 203about your disk's geometry. The kernel will attempt to display geometry 204information for SCSI disks during boot, if possible. If you did not make it 205note of it before, you may wish to reboot and jot down your disk's geometry 206before proceeding. 207 208As with anything which modifies your hard disk's contents, this program can 209cause SIGNIFICANT data loss, and you are advised to make sure your hard drive 210is backed up before beginning the installation process. 211 212Default answers are displyed in brackets after the questions. You can hit 213Control-C at any time to quit, but if you do so at a prompt, you may have to 214hit return. Also, quitting in the middle of installation may leave your 215system in an inconsistent state. 216__welcome_banner_1 217} 218 219md_not_going_to_install() { 220 cat << \__not_going_to_install_1 221 222OK, then. Enter 'halt' at the prompt to halt the machine. Once the 223machine has halted, power-cycle the system to load new boot code. 224 225__not_going_to_install_1 226} 227 228md_congrats() { 229 cat << \__congratulations_1 230 231CONGRATULATIONS! You have successfully installed NetBSD! To boot the 232installed system, enter halt at the command prompt. Once the system has 233halted, power-cycle the machine in order to load new boot code. Make sure 234you boot from the root disk. 235 236__congratulations_1 237} 238 239md_native_fstype() { 240 # Nothing to do. 241} 242 243md_native_fsopts() { 244 # Nothing to do. 245} 246