2 # $NetBSD: upgrade.sh,v 1.2 2002/05/07 14:47:45 lukem Exp $
4 # Copyright (c) 1997 Perry E. Metzger
5 # Copyright (c) 1994 Christopher G. Demetriou
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions
11 # 1. Redistributions of source code must retain the above copyright
12 # notice, this list of conditions and the following disclaimer.
13 # 2. Redistributions in binary form must reproduce the above copyright
14 # notice, this list of conditions and the following disclaimer in the
15 # documentation and/or other materials provided with the distribution.
16 # 3. All advertising materials mentioning features or use of this software
17 # must display the following acknowledgement:
18 # This product includes software developed for the
19 # NetBSD Project. See http://www.NetBSD.org/ for
20 # information about NetBSD.
21 # 4. The name of the author may not be used to endorse or promote products
22 # derived from this software without specific prior written permission.
24 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
25 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 # <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
37 # NetBSD upgrade script.
38 # In a perfect world, this would be a nice C program, with a reasonable
41 DT
=/etc
/disktab
# /etc/disktab
42 FSTABDIR
=/mnt
/etc
# /mnt/etc
46 FSTAB
=${FSTABDIR}/fstab
50 if [ "X$resp" = "X" ]; then
55 echo "Welcome to the original NetBSD/alpha upgrade program."
57 echo "This version of the program has been largely replaced by the new
58 echo "sysinst utility. Both programs are on this installation media
set.
59 echo -n "Type the return key to continue..."
61 echo "This program is designed to help you put the new version of NetBSD"
62 echo "on your hard disk, in a simple and rational way. To upgrade, you"
63 echo "must have plenty of free space on all partitions which will be"
64 echo "upgraded. If you have at least 1MB free on your root partition,"
65 echo "and several free on your /usr patition, you should be fine."
67 echo "As with anything which modifies your hard drive's contents, this"
68 echo "program can cause SIGNIFICANT data loss, and you are advised"
69 echo "to make sure your hard drive is backed up before beginning the"
70 echo "upgrade process."
72 echo "Default answers are displyed in brackets after the questions."
73 echo "You can hit Control-C at any time to quit, but if you do so at a"
74 echo "prompt, you may have to hit return. Also, quitting in the middle of"
75 echo "the upgrade may leave your system in an inconsistent (and unusable)"
78 echo -n "Proceed with upgrade? [n] "
82 echo "Cool! Let's get to it..."
86 echo "OK, then. Enter 'halt' at the prompt to halt the"
87 echo "machine. Once the machine has halted, remove the"
88 echo "floppy and press any key to reboot."
93 # find out what units are possible, and query the user.
94 driveunits
=`echo /dev/[sw]d?a | sed -e 's,/dev/\(...\)a,\1,g'`
95 if [ "X${driveunits}" = "X" ]; then
97 echo "No disk devices."
98 echo "This is probably a bug in the install disks."
99 echo "Exiting install program."
104 echo "The following disks are supported by this upgrade procedure:"
105 echo " "${driveunits}
106 echo "If your system was previously completely contained within the"
107 echo "disks listed above (i.e. if your system didn't occupy any space"
108 echo "on disks NOT listed above), this upgrade disk can upgrade your"
109 echo "system. If it cannot, hit Control-C at the prompt."
111 while [ "X${drivename}" = "X" ]; do
112 echo -n "Which disk contains your root partition? "
114 otherdrives
=`echo "${driveunits}" | sed -e s,${resp},,`
115 if [ "X${driveunits}" = "X${otherdrives}" ]; then
117 echo "\"${resp}\" is an invalid drive name. Valid choices"
118 echo "are: "${driveunits}
126 echo "Root partition is on ${drivename}a."
129 echo "If (and only if!) you are upgrading from NetBSD 0.9 or below,"
130 echo "you should upgrade to the new file system format. Do not answer"
131 echo "yes if you are upgrading from NetBSD 1.0 or above."
132 echo "Would you like to upgrade your file systems to the new file system"
133 echo -n "format? [y] "
138 echo "If you are upgrading from NetBSD 0.9 or below,"
139 echo "you should upgrade your file systems with 'fsck -c 2'"
140 echo "as soon as is feasible, because the new file system"
141 echo "code is better-tested and more performant."
151 if [ $upgradefs = YES
]; then
153 echo "your file systems will be upgraded while they are checked"
156 echo "checking the file system on ${drivename}a..."
158 fsck
-f -p $upgrargs /dev
/r
${drivename}a
160 echo "FATAL ERROR: FILE SYSTEM UPGRADE FAILED."
161 echo "You should probably reboot the machine, fsck your"
162 echo "disk(s), and try the upgrade procedure again."
167 echo "Mounting root partition on /mnt..."
168 mount
/dev
/${drivename}a
/mnt
170 echo "FATAL ERROR: MOUNT FAILED."
171 echo "You should verify that your system is set up as you"
172 echo "described, and re-attempt the upgrade procedure."
178 echo -n "Copying new fsck binary to your hard disk..."
179 if [ ! -d /mnt
/sbin
]; then
182 cp /sbin
/fsck
/mnt
/sbin
/fsck
184 echo "FATAL ERROR: COPY FAILED."
185 echo "It in unclear why this error would occur. It looks"
186 echo "like you may end up having to upgrade by hand."
192 echo "Re-mounting root partition read-only..."
193 mount
-u -o ro
/dev
/${drivename}a
/mnt
195 echo "FATAL ERROR: RE-MOUNT FAILED."
196 echo "It in unclear why this error would occur. It looks"
197 echo "like you may end up having to upgrade by hand."
203 echo "checking the rest of your file systems..."
204 chroot
/mnt fsck
-f -p $upgrargs
206 echo "FATAL ERROR: FILE SYSTEM UPGRADE(S) FAILED."
207 echo "You should probably reboot the machine, fsck your"
208 echo "file system(s), and try the upgrade procedure"
215 echo "Re-mounting root partition read-write..."
216 mount
-u -o rw
/dev
/${drivename}a
/mnt
218 echo "FATAL ERROR: RE-MOUNT FAILED."
219 echo "It in unclear why this error would occur. It looks"
220 echo "like you may end up having to upgrade by hand."
226 echo "Updating boot blocks on ${drivename}..."
227 # shouldn't be needed, but...
228 $DONTDOIT rm -f /mnt
/boot
229 $DONTDOIT cp /usr
/mdec
/boot
/mnt
/boot
230 $DONTDOIT /usr
/sbin
/installboot
/dev
/r
${drivename}c
/usr
/mdec
/bootxx_ffs
232 echo "FATAL ERROR: UPDATE OF DISK LABEL FAILED."
233 echo "It in unclear why this error would occur. It looks"
234 echo "like you may end up having to upgrade by hand."
240 echo "Copying bootstrapping binaries and config files to the hard drive..."
241 $DONTDOIT cp /mnt
/.profile
/mnt
/.profile.bak
242 $DONTDOIT pax
-s '#^\./etc/.*##' -Xrwpe .
/mnt
243 $DONTDOIT mv /mnt
/etc
/rc
/mnt
/etc
/rc.bak
244 $DONTDOIT cp /tmp
/.hdprofile
/mnt
/.profile
247 echo "Mounting remaining partitions..."
248 chroot
/mnt mount
-at ffs
> /dev
/null
2>&1
253 echo "OK! The preliminary work of setting up your disk is now complete,"
254 echo "and you can now upgrade the actual NetBSD software."
256 echo "Right now, your hard disk is mounted on /mnt. You should consult"
257 echo "the installation notes to determine how to load and install the new"
258 echo "NetBSD distribution sets, and how to clean up after the upgrade"
259 echo "software, when you are done."