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