Home | History | Annotate | Line # | Download | only in miniroot
install.md revision 1.2
      1 #	$NetBSD: install.md,v 1.2 2006/06/25 00:15:19 tsutsui Exp $
      2 #
      3 #
      4 # Copyright (c) 1996 The NetBSD Foundation, Inc.
      5 # All rights reserved.
      6 #
      7 # This code is derived from software contributed to The NetBSD Foundation
      8 # by Jason R. Thorpe.
      9 #
     10 # Redistribution and use in source and binary forms, with or without
     11 # modification, are permitted provided that the following conditions
     12 # are met:
     13 # 1. Redistributions of source code must retain the above copyright
     14 #    notice, this list of conditions and the following disclaimer.
     15 # 2. Redistributions in binary form must reproduce the above copyright
     16 #    notice, this list of conditions and the following disclaimer in the
     17 #    documentation and/or other materials provided with the distribution.
     18 # 3. All advertising materials mentioning features or use of this software
     19 #    must display the following acknowledgement:
     20 #        This product includes software developed by the NetBSD
     21 #        Foundation, Inc. and its contributors.
     22 # 4. Neither the name of The NetBSD Foundation nor the names of its
     23 #    contributors may be used to endorse or promote products derived
     24 #    from this software without specific prior written permission.
     25 #
     26 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29 # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36 # POSSIBILITY OF SUCH DAMAGE.
     37 #
     38 
     39 #
     40 # machine dependent section of installation/upgrade script.
     41 #
     42 
     43 # Machine-dependent install sets
     44 # MDSETS="xbin xman xinc xcon" XXX
     45 MDSETS=""
     46 
     47 md_set_term() {
     48 	if [ ! -z "$TERM" ]; then
     49 		return
     50 	fi
     51 	echo -n "Specify terminal type [sun]: "
     52 	getresp "sun"
     53 	TERM="$resp"
     54 	export TERM
     55 }
     56 
     57 __mount_kernfs() {
     58 	# Make sure kernfs is mounted.
     59 	if [ ! -d /kern -o ! -e /kern/msgbuf ]; then
     60 		mkdir /kern > /dev/null 2>&1
     61 		/sbin/mount_kernfs /kern /kern
     62 	fi
     63 }
     64 
     65 md_makerootwritable() {
     66 	# Just remount the root device read-write.
     67 	if [ ! -e /tmp/root_writable ]; then
     68 		echo "Remounting root read-write..."
     69 		__mount_kernfs
     70 		mount -u /kern/rootdev /
     71 		swapctl -a /kern/rootdev
     72 		cp /dev/null /tmp/root_writable
     73 	fi
     74 }
     75 
     76 md_get_diskdevs() {
     77 	# return available disk devices
     78 	__mount_kernfs
     79 	sed -n -e '/^sd[0-9] /s/ .*//p' \
     80 	       -e '/^xd[0-9] /s/ .*//p' \
     81 	       -e '/^xy[0-9] /s/ .*//p' \
     82 		< /kern/msgbuf | sort -u
     83 }
     84 
     85 md_get_cddevs() {
     86 	# return available CDROM devices
     87 	__mount_kernfs
     88 	sed -n -e '/^cd[0-9] /s/ .*//p' \
     89 		< /kern/msgbuf | sort -u
     90 }
     91 
     92 md_get_ifdevs() {
     93 	# return available network devices
     94 	__mount_kernfs
     95 	sed -n -e '/^ie[0-9] /s/ .*//p' \
     96 	       -e '/^le[0-9] /s/ .*//p' \
     97 		< /kern/msgbuf | sort -u
     98 }
     99 
    100 md_get_partition_range() {
    101 	# return an expression describing the valid partition id's
    102 	echo '[a-h]'
    103 }
    104 
    105 md_installboot() {
    106 	# install the boot block on disk $1
    107 	echo "Installing boot block..."
    108 	( cd /usr/mdec ;\
    109 	cp -p ./ufsboot /mnt/ufsboot ;\
    110 	sync ; sleep 1 ; sync ;\
    111 	/usr/sbin/installboot -v /dev/r${1}a bootxx ufsboot )
    112 	echo "done."
    113 }
    114 
    115 md_native_fstype() {
    116 }
    117 
    118 md_native_fsopts() {
    119 }
    120 
    121 md_prep_disklabel() {
    122 	# $1 is the root disk
    123 	echo -n "Do you wish to edit the disklabel on ${1}? [y]"
    124 	getresp "y"
    125 	case "$resp" in
    126 	y*|Y*) ;;
    127 	*)	return ;;
    128 	esac
    129 
    130 	# display example
    131 	cat << \__md_prep_disklabel_1
    132 Here is an example of what the partition information will look like once
    133 you have entered the disklabel editor. Disk partition sizes and offsets
    134 are in sector (most likely 512 bytes) units. Make sure all partitions
    135 start on a cylinder boundary (c/t/s == XXX/0/0).
    136 
    137 [Example]
    138 partition      start         (c/t/s)      nblks         (c/t/s)  type
    139 
    140  a (root)          0       (0/00/00)      31392     (109/00/00)  4.2BSD
    141  b (swap)      31392     (109/00/00)      73440     (255/00/00)  swap
    142  c (disk)          0       (0/00/00)    1070496    (3717/00/00)  unused
    143  d (user)     104832     (364/00/00)      30528     (106/00/00)  4.2BSD
    144  e (user)     135360     (470/00/00)      40896     (142/00/00)  4.2BSD
    145  f (user)     176256     (612/00/00)      92160     (320/00/00)  4.2BSD
    146  g (user)     268416     (932/00/00)     802080    (2785/00/00)  4.2BSD
    147 
    148 [End of example]
    149 
    150 Hit the <return> key when you have read this...
    151 
    152 __md_prep_disklabel_1
    153 	getresp ""
    154 	edlabel /dev/r${1}c
    155 }
    156 
    157 md_copy_kernel() {
    158 	if [ ! -f /mnt/netbsd ]; then
    159 		set -- `sysctl -n hw.model`
    160 		echo -n "No kernel set extracted. Copying $1 miniroot kernel..."
    161 		cp -p /netbsd.$1 /mnt/netbsd
    162 		echo "done."
    163 	fi
    164 }
    165 
    166 md_welcome_banner() {
    167 	if [ "$MODE" = "install" ]; then
    168 		echo ""
    169 		echo "Welcome to the NetBSD/sun3 ${VERSION} installation program."
    170 		cat << \__welcome_banner_1
    171 
    172 This program is designed to help you put NetBSD on your disk,
    173 in a simple and rational way.  You'll be asked several questions,
    174 and it would probably be useful to have your disk's hardware
    175 manual, the installation notes, and a calculator handy.
    176 __welcome_banner_1
    177 
    178 	else
    179 		echo ""
    180 		echo "Welcome to the NetBSD/sun3 ${VERSION} upgrade program."
    181 		cat << \__welcome_banner_2
    182 
    183 This program is designed to help you upgrade your NetBSD system in a
    184 simple and rational way.
    185 
    186 As a reminder, installing the `etc' binary set is NOT recommended.
    187 Once the rest of your system has been upgraded, you should manually
    188 merge any changes to files in the `etc' set into those files which
    189 already exist on your system.
    190 __welcome_banner_2
    191 	fi
    192 
    193 cat << \__welcome_banner_3
    194 
    195 As with anything which modifies your disk's contents, this
    196 program can cause SIGNIFICANT data loss, and you are advised
    197 to make sure your data is backed up before beginning the
    198 installation process.
    199 
    200 Default answers are displayed in brackets after the questions.
    201 You can hit Control-C at any time to quit, but if you do so at a
    202 prompt, you may have to hit return.  Also, quitting in the middle of
    203 installation may leave your system in an inconsistent state.
    204 
    205 __welcome_banner_3
    206 }
    207 
    208 md_not_going_to_install() {
    209 	cat << \__not_going_to_install_1
    210 
    211 OK, then.  Enter `halt' at the prompt to halt the machine.  Once the
    212 machine has halted, power-cycle the system to load new boot code.
    213 
    214 __not_going_to_install_1
    215 }
    216 
    217 md_congrats() {
    218 	local what;
    219 	if [ "$MODE" = "install" ]; then
    220 		what="installed";
    221 	else
    222 		what="upgraded";
    223 	fi
    224 	cat << __congratulations_1
    225 
    226 CONGRATULATIONS!  You have successfully $what NetBSD!
    227 To boot the installed system, enter halt at the command prompt. Once the
    228 system has halted, reset the machine and boot from the disk.
    229 
    230 __congratulations_1
    231 }
    232