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