Home | History | Annotate | Line # | Download | only in miniroot
install.md revision 1.7
      1 #	$NetBSD: install.md,v 1.7 2020/12/05 18:52:06 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 #
     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
     38 MDSETS="kern-GENERIC kern-GENERIC3X xbase xcomp xetc xfont xserver"
     39 
     40 md_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 md_makerootwritable() {
     51 	# Just remount the root device read-write.
     52 	if [ ! -e /tmp/root_writable ]; then
     53 		echo "Remounting root read-write..."
     54 		mi_mount_kernfs
     55 		mount -u /kern/rootdev /
     56 		swapctl -a /kern/rootdev
     57 		cp /dev/null /tmp/root_writable
     58 	fi
     59 }
     60 
     61 md_get_diskdevs() {
     62 	# return available disk devices
     63 	mi_mount_kernfs
     64 	mi_filter_msgbuf | sed -ne '/^[xs]d[0-9] /s/ .*//p' \
     65 	       -e '/^xy[0-9] /s/ .*//p'
     66 }
     67 
     68 md_get_cddevs() {
     69 	# return available CDROM devices
     70 	mi_mount_kernfs
     71 	mi_filter_msgbuf | sed -ne '/^cd[0-9] /s/ .*//p'
     72 }
     73 
     74 md_get_ifdevs() {
     75 	# return available network devices
     76 	mi_mount_kernfs
     77 	mi_filter_msgbuf | sed -ne '/^[il]e[0-9] /s/ .*//p'
     78 }
     79 
     80 md_get_partition_range() {
     81 	# return an expression describing the valid partition id's
     82 	echo '[a-h]'
     83 }
     84 
     85 md_installboot() {
     86 	# install the boot block on disk $1
     87 	echo "Installing boot block..."
     88 	( cd /usr/mdec ;\
     89 	cp -p ./ufsboot /mnt/ufsboot ;\
     90 	sync ; sleep 1 ; sync ;\
     91 	/usr/sbin/installboot -v /dev/r${1}a bootxx ufsboot )
     92 	echo "done."
     93 }
     94 
     95 md_native_fstype() {
     96 }
     97 
     98 md_native_fsopts() {
     99 }
    100 
    101 md_prep_disklabel() {
    102 	# $1 is the root disk
    103 	echo -n "Do you wish to edit the disklabel on ${1}? [y]"
    104 	getresp "y"
    105 	case "$resp" in
    106 	y*|Y*) ;;
    107 	*)	return ;;
    108 	esac
    109 
    110 	# display example
    111 	cat << \__md_prep_disklabel_1
    112 Here is an example of what the partition information will look like once
    113 you have entered the disklabel editor. Disk partition sizes and offsets
    114 are in sector (most likely 512 bytes) units. Make sure all partitions
    115 start on a cylinder boundary (c/t/s == XXX/0/0).
    116 
    117 [Example]
    118 partition      start         (c/t/s)      nblks         (c/t/s)  type
    119 
    120  a (root)          0       (0/00/00)      31392     (109/00/00)  4.2BSD
    121  b (swap)      31392     (109/00/00)      73440     (255/00/00)  swap
    122  c (disk)          0       (0/00/00)    1070496    (3717/00/00)  unused
    123  d (user)     104832     (364/00/00)      30528     (106/00/00)  4.2BSD
    124  e (user)     135360     (470/00/00)      40896     (142/00/00)  4.2BSD
    125  f (user)     176256     (612/00/00)      92160     (320/00/00)  4.2BSD
    126  g (user)     268416     (932/00/00)     802080    (2785/00/00)  4.2BSD
    127 
    128 [End of example]
    129 
    130 Hit the <return> key when you have read this...
    131 
    132 __md_prep_disklabel_1
    133 	getresp ""
    134 	edlabel /dev/r${1}c
    135 }
    136 
    137 md_copy_kernel() {
    138 	if [ ! -f /mnt/netbsd ]; then
    139 		set -- $(sysctl -n hw.model)
    140 		echo -n "No kernel set extracted. Copying $1 miniroot kernel..."
    141 		cp -p /netbsd.$1 /mnt/netbsd
    142 		echo "done."
    143 	fi
    144 }
    145 
    146 md_welcome_banner() {
    147 	if [ "$MODE" = "install" ]; then
    148 		echo ""
    149 		echo "Welcome to the NetBSD/${MACHINE} ${RELEASE} installation program."
    150 		cat << \__welcome_banner_1
    151 
    152 This program is designed to help you put NetBSD on your disk,
    153 in a simple and rational way.  You'll be asked several questions,
    154 and it would probably be useful to have your disk's hardware
    155 manual, the installation notes, and a calculator handy.
    156 __welcome_banner_1
    157 
    158 	else
    159 		echo ""
    160 		echo "Welcome to the NetBSD/${MACHINE} ${RELEASE} upgrade program."
    161 		cat << \__welcome_banner_2
    162 
    163 This program is designed to help you upgrade your NetBSD system in a
    164 simple and rational way.
    165 
    166 As a reminder, installing the 'etc' binary set is NOT recommended.
    167 Once the rest of your system has been upgraded, you should manually
    168 merge any changes to files in the 'etc' set into those files which
    169 already exist on your system.
    170 __welcome_banner_2
    171 	fi
    172 
    173 cat << \__welcome_banner_3
    174 
    175 As with anything which modifies your disk's contents, this
    176 program can cause SIGNIFICANT data loss, and you are advised
    177 to make sure your data is backed up before beginning the
    178 installation process.
    179 
    180 Default answers are displayed in brackets after the questions.
    181 You can hit Control-C at any time to quit, but if you do so at a
    182 prompt, you may have to hit return.  Also, quitting in the middle of
    183 installation may leave your system in an inconsistent state.
    184 
    185 __welcome_banner_3
    186 }
    187 
    188 md_not_going_to_install() {
    189 	cat << \__not_going_to_install_1
    190 
    191 OK, then.  Enter 'halt' at the prompt to halt the machine.  Once the
    192 machine has halted, power-cycle the system to load new boot code.
    193 
    194 __not_going_to_install_1
    195 }
    196 
    197 md_congrats() {
    198 	local what;
    199 	if [ "$MODE" = "install" ]; then
    200 		what="installed";
    201 	else
    202 		what="upgraded";
    203 	fi
    204 	cat << __congratulations_1
    205 
    206 CONGRATULATIONS!  You have successfully $what NetBSD!
    207 To boot the installed system, enter halt at the command prompt. Once the
    208 system has halted, reset the machine and boot from the disk.
    209 
    210 __congratulations_1
    211 }
    212