2 # $NetBSD: upgrade.sh,v 1.8 2003/07/26 17:06:31 salo Exp $
4 # Copyright (c) 1994 Christopher G. Demetriou
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
15 # 3. All advertising materials mentioning features or use of this software
16 # must display the following acknowledgement:
17 # This product includes software developed for the
18 # NetBSD Project. See http://www.NetBSD.org/ for
19 # information about NetBSD.
20 # 4. The name of the author may not be used to endorse or promote products
21 # derived from this software without specific prior written permission.
23 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 # <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
36 # NetBSD upgrade script.
37 # In a perfect world, this would be a nice C program, with a reasonable
46 if [ "X$resp" = "X" ]; then
52 echo $
(eval $
(echo "echo \$$1"))
65 disklabel
$1 2>/dev
/null |
sed -e '/^[ ][ ][ad-p]/!d' |
66 sed -e 's,^[ ]*\([a-p]\):[ ]*[0-9]*[ ]*[0-9]*[ ][ ]*\([a-zA-Z0-9.]*\).*,\1 \2,' |
74 for du
in /dev
/rsd?a
; do
75 dd if=$du of
=/dev
/null bs
=1b count
=1 >/dev
/null
2>&1
77 thisunit
=`echo $du | sed -e 's,/dev/r\(...\)a,\1,g'`
78 driveunits
="$driveunits $thisunit"
82 setvar
$thisunit "$(getparts $thisunit)"
89 if [ ! -e /mnt
/etc
/fstab.ufs
]; then
90 mv /mnt
/etc
/fstab
/mnt
/etc
/fstab.ufs
92 sed "s/ufs/ffs/" /mnt
/etc
/fstab.ufs
>/mnt
/etc
/fstab
95 echo "Welcome to the NetBSD ${VERSION} upgrade program."
97 echo "This program is designed to help you put the new version of NetBSD"
98 echo "on your hard disk, in a simple and rational way. To upgrade, you"
99 echo "must have plenty of free space on all partitions which will be"
100 echo "upgraded. If you have at least 1MB free on your root partition,"
101 echo "and several free on your /usr patition, you should be fine."
103 echo "As with anything which modifies your hard drive's contents, this"
104 echo "program can cause SIGNIFICANT data loss, and you are advised"
105 echo "to make sure your hard drive is backed up before beginning the"
106 echo "upgrade process."
108 echo "Default answers are displayed in brackets after the questions."
109 echo "You can hit Control-C at any time to quit, but if you do so at a"
110 echo "prompt, you may have to hit return. Also, quitting in the middle of"
111 echo "the upgrade may leave your system in an inconsistent (and unusable)"
114 echo -n "Proceed with upgrade? [n] "
118 echo "Cool! Let's get to it..."
122 echo "OK, then. Enter 'halt' at the prompt to halt the"
123 echo "machine. Once the machine has halted, remove the"
124 echo "floppy and press any key to reboot."
129 # find out what units are possible, and query the user.
133 if [ "X${driveunits}" = "X" ]; then
135 echo "No disk devices."
136 echo "This is probably a bug in the install disks."
137 echo "Exiting install program."
142 echo "The following disks are supported by this upgrade procedure:"
143 echo " "${driveunits}
145 echo "If your system was previously completely contained within the"
146 echo "disks listed above (i.e. if your system didn't occupy any space"
147 echo "on disks NOT listed above), this upgrade disk can upgrade your"
148 echo "system. If it cannot, hit Control-C at the prompt."
150 while [ "X${drivename}" = "X" ]; do
151 echo -n "Which disk contains your root partition? "
153 otherdrives
=`echo "${driveunits}" | sed -e s,${resp},,`
154 if [ "X${driveunits}" = "X${otherdrives}" ]; then
156 echo "\"${resp}\" is an invalid drive name. Valid choices"
157 echo "are: "${driveunits}
165 echo "Root partition is on ${drivename}a."
168 echo "If you've still installed 0.9 or earlier on your machine or you"
169 echo "haven't upgraded your pre-1.0 filesystems, then you might want to"
170 echo "upgrade the filesystem to the version introduced with 1.0."
172 echo "Would you like to upgrade your file systems to the new file system"
173 echo -n "format? [y] "
178 echo "You should upgrade your file systems with 'fsck -c 2'"
179 echo "as soon as is feasible, because the new file system"
180 echo "code is better-tested and more performant."
188 if [ $upgradefs = YES
]; then
190 echo "Upgrading the file system on ${drivename}a..."
192 $DONTDOIT fsck
-p -c 2 /dev
/r
${drivename}a
194 echo "FATAL ERROR: FILE SYSTEM UPGRADE FAILED."
195 echo "You should probably reboot the machine, fsck your"
196 echo "disk(s), and try the upgrade procedure again."
203 echo "Mounting root partition on /mnt..."
204 $DONTDOIT mount
/dev
/${drivename}a
/mnt
206 echo "FATAL ERROR: MOUNT FAILED."
207 echo "You should verify that your system is set up as you"
208 echo "described, and re-attempt the upgrade procedure."
213 #<<<<<<<<<<<<<<<<<<<<<<<< update etc/fstab to ffs? >>>>>>>>>>>>>>>>>>>>>>>>
215 echo -n "Converting ufs entries in fstab to ffs..."
216 $DONTDOIT Convert_fstab
219 if [ $upgradefs = YES
]; then
221 echo -n "Copying new fsck binary to your hard disk..."
222 if [ ! -d /mnt
/sbin
]; then
223 $DONTDOIT mkdir
/mnt
/sbin
225 $DONTDOIT cp /sbin
/fsck
/mnt
/sbin
/fsck
227 echo "FATAL ERROR: COPY FAILED."
228 echo "It in unclear why this error would occur. It looks"
229 echo "like you may end up having to upgrade by hand."
236 echo "Re-mounting root partition read-only..."
237 $DONTDOIT mount
-u -o ro
/dev
/${drivename}a
/mnt
239 echo "FATAL ERROR: RE-MOUNT FAILED."
240 echo "It in unclear why this error would occur. It looks"
241 echo "like you may end up having to upgrade by hand."
247 echo "Upgrading the rest of your file systems..."
248 $DONTDOIT chroot
/mnt fsck
-p -c 2
250 echo "FATAL ERROR: FILE SYSTEM UPGRADE(S) FAILED."
251 echo "You should probably reboot the machine, fsck your"
252 echo "file system(s), and try the upgrade procedure"
259 echo "Re-mounting root partition read-write..."
260 $DONTDOIT mount
-u -o rw
/dev
/${drivename}a
/mnt
262 echo "FATAL ERROR: RE-MOUNT FAILED."
263 echo "It in unclear why this error would occur. It looks"
264 echo "like you may end up having to upgrade by hand."
271 echo "Copying bootstrapping binaries and config files to the hard drive..."
272 $DONTDOIT pax
-rwpe sbin
/mount_ffs
/mnt
275 echo "Mounting remaining partitions..."
276 $DONTDOIT chroot
/mnt mount
-at ffs
> /dev
/null
2>&1
281 echo "OK! The preliminary work of setting up your disk is now complete,"
282 echo "and you can now upgrade the actual NetBSD software."
284 echo "Right now, your hard disk is mounted on /mnt. You should consult"
285 echo "the installation notes to determine how to load and install the new"
286 echo "NetBSD distribution sets, and how to clean up after the upgrade"
287 echo "software, when you are done."