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