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