1 # $NetBSD: install.md,v 1.20 2006/02/07 16:52:16 chs Exp $
4 # Copyright (c) 1996 The NetBSD Foundation, Inc.
7 # This code is derived from software contributed to The NetBSD Foundation
10 # Redistribution and use in source and binary forms, with or without
11 # modification, are permitted provided that the following conditions
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.
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.
33 # machine dependent section of installation/upgrade script.
36 # Machine-dependent install sets
37 MDSETS="kern xbase xcomp xfont xserver"
39 if [ "$MODE" = upgrade ]; then
40 RELOCATED_FILES_13="${RELOCATED_FILES_13} /usr/sbin/installboot /usr/mdec/installboot"
44 if [ ! -z "$TERM" ]; then
47 echo -n "Specify terminal type [sun]: "
53 md_makerootwritable() {
54 # Was: do_mfs_mount "/tmp" "2048"
55 # /tmp is the mount point
56 # 2048 is the size in DEV_BIZE blocks
58 umount /tmp > /dev/null 2>&1
59 if ! mount_mfs -s 2048 swap /tmp ; then
60 cat << \__mfs_failed_1
62 FATAL ERROR: Can't mount the memory filesystem.
68 # Bleh. Give mount_mfs a chance to DTRT.
73 # return available disk devices
74 dmesg | sed -n -e 's/^\(sd[0-9]\) .*/\1/p' -e 's/^\(x[dy][0-9]\) .*/\1/p' | sort -u
78 # return available CDROM devices
79 dmesg | sed -n -e 's/^\(cd[0-9]\) .*/\1/p' | sort -u
83 # return available network devices
84 dmesg | sed -n -e 's/^\(le[0-9]\) .*/\1/p' -e 's/^\(ie[0-9]\) .*/\1/p' | sort -u
87 md_get_partition_range() {
88 # return range of valid partition letters
94 echo "Installing boot block..."
95 cp -p /usr/mdec/boot /mnt/boot
96 /usr/sbin/installboot -v /dev/r${1}a /usr/mdec/bootxx /boot
105 md_checkfordisklabel() {
106 # $1 is the disk to check
110 cfdl=`disklabel $1 2>&1 > /dev/null | \
111 sed -n -e '/no disk label/{s/.*/ndl/p;q;}; \
112 /disk label corrupted/{s/.*/dlc/p;q;}; \
114 if [ x$cfdl = xndl ]; then
116 elif [ x$cfdl = xdlc ]; then
130 md_checkfordisklabel $_disk
133 echo -n "Do you wish to edit the disklabel on $_disk? [y]"
136 echo "WARNING: Disk $_disk has no label"
137 echo -n "Do you want to create one with the disklabel editor? [y]"
140 echo "WARNING: Label on disk $_disk is corrupted"
141 echo -n "Do you want to try and repair the damage using the disklabel editor? [y]"
152 cat << \__md_prep_disklabel_1
154 Here is an example of what the partition information will look like once
155 you have entered the disklabel editor. Disk partition sizes and offsets
156 are in sector (most likely 512 bytes) units. Make sure these size/offset
157 pairs are on cylinder boundaries (the number of sector per cylinder is
158 given in the `sectors/cylinder' entry, which is not shown here).
160 Do not change any parameters except the partition layout and the label name.
161 It's probably also wisest not to touch the `8 partitions:' line, even
162 in case you have defined less than eight partitions.
166 # size offset fstype [fsize bsize cpg]
167 a: 50176 0 4.2BSD 1024 8192 16 # (Cyl. 0 - 111)
168 b: 64512 50176 swap # (Cyl. 112 - 255)
169 c: 640192 0 unknown # (Cyl. 0 - 1428)
170 d: 525504 114688 4.2BSD 1024 8192 16 # (Cyl. 256 - 1428)
173 __md_prep_disklabel_1
174 echo -n "Press [Enter] to continue "
176 disklabel -W ${_disk}
177 if [ -f /usr/bin/vi ]; then
178 disklabel -e ${_disk}
180 disklabel -i ${_disk}
185 if [ ! -f /mnt/netbsd ]; then
186 echo -n "WARNING: No kernel installed; "
187 if [ -f /netbsd ]; then
188 echo -n "copying miniroot kernel... "
189 cp -p /netbsd /mnt/netbsd
192 echo -n "install a kernel manually."
197 md_welcome_banner() {
199 if [ "$MODE" = "install" ]; then
201 echo "Welcome to the NetBSD/sparc ${VERSION} installation program."
202 cat << \__welcome_banner_1
204 This program is designed to help you put NetBSD on your disk,
205 in a simple and rational way. You'll be asked several questions,
206 and it would probably be useful to have your disk's hardware
207 manual, the installation notes, and a calculator handy.
212 echo "Welcome to the NetBSD/sparc ${VERSION} upgrade program."
213 cat << \__welcome_banner_2
215 This program is designed to help you upgrade your NetBSD system in a
216 simple and rational way.
218 As a reminder, installing the `etc' binary set is NOT recommended.
219 Once the rest of your system has been upgraded, you should manually
220 merge any changes to files in the `etc' set into those files which
221 already exist on your system.
225 cat << \__welcome_banner_3
227 As with anything which modifies your disk's contents, this
228 program can cause SIGNIFICANT data loss, and you are advised
229 to make sure your data is backed up before beginning the
230 installation process.
232 Default answers are displayed in brackets after the questions.
233 You can hit Control-C at any time to quit, but if you do so at a
234 prompt, you may have to hit return. Also, quitting in the middle of
235 installation may leave your system in an inconsistent state.
241 md_not_going_to_install() {
242 cat << \__not_going_to_install_1
244 OK, then. Enter `halt' at the prompt to halt the machine. Once the
245 machine has halted, power-cycle the system to load new boot code.
247 __not_going_to_install_1
252 if [ "$MODE" = "install" ]; then
257 cat << __congratulations_1
259 CONGRATULATIONS! You have successfully $what NetBSD!
260 To boot the installed system, enter halt at the command prompt. Once the
261 system has halted, reset the machine and boot from the disk.
268 test -h $1 && return 1
269 test -f $1 || return 1
271 [ "`dd if=$1 bs=1 skip=1 count=3 2> /dev/null`" = "ELF" ] && return 1
279 for f in $root/usr/lib/lib*.so.[0-9]*.[0-9]* ; do
280 md_lib_is_aout $f || continue
281 mv -f $f $root/emul/aout/usr/lib || return 1
286 md_x_shlib_set_14=" \
305 for f in $md_x_shlib_set_14; do
306 md_lib_is_aout $root/$xlibdir/$f || continue
307 mv -f $root/$xlibdir/$f $root/emul/aout/$xlibdir || return 1
316 root=/mnt # XXX - should be global
318 if [ -d $root/emul/aout/. ]; then
319 echo "Using existing /emul/aout directory"
321 echo "Creating /emul/aout hierachy"
322 mkdir -p $root/usr/aout || return 1
324 if [ ! -d $root/emul ]; then
325 mkdir $root/emul || return 1
328 if [ -h $root/emul/aout ]; then
329 echo "Preserving existing symbolic link from /emul/aout"
330 mv -f $root/emul/aout $root/emul/aout.old || return 1
333 ln -s ../usr/aout $root/emul/aout || return 1
336 # Create /emul/aout/etc and /emul/aout/usr/lib
337 if [ ! -d $root/emul/aout/etc ]; then
338 mkdir $root/emul/aout/etc || return 1
340 if [ ! -d $root/emul/aout/usr/lib ]; then
341 mkdir -p $root/emul/aout/usr/lib || return 1
345 if [ -f $root/etc/ld.so.conf ]; then
346 mv -f $root/etc/ld.so.conf $root/emul/aout/etc || return 1
349 # Finally, move the aout shared libraries from /usr/lib
350 md_mv_usr_lib $root || return 1
352 # If X11 is installed, move the those libraries as well
353 xlibdir="/usr/X11R6/lib"
354 if [ -d $root/$xlibdir/. ]; then
355 mkdir -p $root/emul/aout/$xlibdir || return 1
356 md_mv_x_lib $root $xlibdir || return 1
359 echo "a.out emulation environment setup completed."
365 This release uses the ELF binary object format. Existing (a.out) binaries
366 can still be used on your system after it has been upgraded, provided
367 that the shared libraries needed by those binaries are made available
368 in the filesystem hierarchy rooted at /emul/aout.
370 This upgrade procedure will now establish this hierarchy by moving all
371 shared libraries in a.out format found in /usr/lib to /emul/aout/usr/lib.
372 It will also move the X11 shared libraries in a.out format from previous
373 NetBSD/sparc X11 installation sets, if they are installed.
377 echo "Failed to setup a.out emulation environment"
383 # Flag to notify upgrade.sh of the existence of md_prepare_upgrade()
384 md_upgrade_prep_needed=1