diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2003-06-27 22:40:41 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2003-06-27 22:40:41 +0000 |
commit | 7ecefe1843fb840c68bf5eae26e082e88b737895 (patch) | |
tree | 1bd9e094863aa7c050e8e02fba7292c9f42eb882 /distrib/miniroot | |
parent | 869db4a9428308456276dd1dba0cce60e664a2aa (diff) |
Improve swap partition handling during install/upgrade.
a) Add all defined swap partitions except the default partition on the
root disk to the installed /etc/fstab.
b) Mount all possible swap partitions just before creating all
devices, giving small memory machines a better chance to successfully
install/upgrade.
Should obviate the need for FAQ 4.3.6.
ok deraadt@ millert@ (slightly earlier version)
Diffstat (limited to 'distrib/miniroot')
-rw-r--r-- | distrib/miniroot/install.sh | 64 | ||||
-rw-r--r-- | distrib/miniroot/install.sub | 20 |
2 files changed, 57 insertions, 27 deletions
diff --git a/distrib/miniroot/install.sh b/distrib/miniroot/install.sh index d2cac86a88e..8cb75b36b71 100644 --- a/distrib/miniroot/install.sh +++ b/distrib/miniroot/install.sh @@ -1,5 +1,5 @@ #!/bin/sh -# $OpenBSD: install.sh,v 1.130 2003/06/02 15:46:09 deraadt Exp $ +# $OpenBSD: install.sh,v 1.131 2003/06/27 22:40:40 krw Exp $ # $NetBSD: install.sh,v 1.5.2.8 1996/08/27 18:15:05 gwr Exp $ # # Copyright (c) 1997-2002 Todd Miller, Theo de Raadt, Ken Westerback @@ -64,10 +64,12 @@ # In a perfect world, this would be a nice C program, with a reasonable # user interface. -# A list of devices holding filesystems and the associated mount points -# is kept in the file named FILESYSTEMS. +# The name of the file holding the list of configured filesystems. FILESYSTEMS=/tmp/filesystems +# The name of the file holding the list of non-default configured swap devices. +SWAPLIST=/tmp/swaplist + # install.sub needs to know the MODE MODE=install @@ -91,7 +93,10 @@ if [ ! -f /etc/fstab ]; then if isin $ROOTDISK $_DKDEVS; then resp=$ROOTDISK rm -f /tmp/fstab - rm -f $FILESYSTEMS + # Make sure empty files exist so we don't have to + # keep checking for their existance before grep'ing. + cat /dev/null >$FILESYSTEMS + cat /dev/null >$SWAPLIST else ask_which "disk" "do you wish to initialize?" "$_DKDEVS" [ "$resp" = "done" ] && break @@ -103,24 +108,24 @@ if [ ! -f /etc/fstab ]; then # and labeling additional disks. This is machine-dependent since # some platforms may not be able to provide this functionality. # /tmp/fstab.$DISK is created here with 'disklabel -f'. - rm -f /tmp/fstab.$DISK + rm -f /tmp/*.$DISK md_prep_disklabel $DISK - # Get the list of BSD partitions and store sizes - # XXX - It would be nice to just pipe the output of sed to a - # 'while read _pp _ps' loop, but our 'sh' runs the last - # element of a pipeline in a subshell and the required side - # effects to _partitions, etc. would be lost. + # Get the lists of BSD and swap partitions. unset _partitions _psizes _mount_points _i=0 - for _p in $(disklabel ${DISK} 2>&1 | sed -ne '/^ *\([a-p]\): *\([0-9][0-9]*\).*BSD.*/s//\1\2/p'); do - # All characters after the initial [a-p] are the partition size - _ps=${_p#?} - # Removing the partition size leaves us with the partition name - _pp=${DISK}${_p%${_ps}} + disklabel $DISK 2>&1 | sed -ne '/^ *[a-p]: /p' >/tmp/disklabel.$DISK + while read _dev _size _offset _type _rest; do + _pp=${DISK}${_dev%:} + _ps=$_size if [[ $_pp == $ROOTDEV ]]; then - echo "$ROOTDEV /" > $FILESYSTEMS + echo "$ROOTDEV /" >$FILESYSTEMS + continue + elif [[ $_type == swap ]]; then + echo "$_pp" >>$SWAPLIST + continue + elif [[ $_type != *BSD ]]; then continue fi @@ -132,7 +137,7 @@ if [ ! -f /etc/fstab ]; then while read _pp _mp _rest; do [[ $_pp == "/dev/${_partitions[$_i]}" ]] || continue # Ignore mount points that have already been specified. - [[ -f $FILESYSTEMS && -n $(grep " $_mp\$" $FILESYSTEMS) ]] && break + [[ -n $(grep " $_mp\$" $FILESYSTEMS) ]] && break isin $_mp ${_mount_points[*]} && break # Ignore '/' for any partition but ROOTDEV. Check just # in case ROOTDEV isn't first partition processed. @@ -142,21 +147,25 @@ if [ ! -f /etc/fstab ]; then done < /tmp/fstab.$DISK fi : $(( _i += 1 )) - done + done < /tmp/disklabel.$DISK if [[ $DISK == $ROOTDISK ]]; then # Ensure that ROOTDEV was configured. - if [[ -f $FILESYSTEMS && -n $(grep "^$ROOTDEV /$" $FILESYSTEMS) ]]; then + if [[ -n $(grep "^$ROOTDEV /$" $FILESYSTEMS) ]]; then echo "The root filesystem will be mounted on $ROOTDEV." else echo "ERROR: Unable to mount the root filesystem on $ROOTDEV." DISK= fi - # Ensure that ${ROOTDISK}b was configured as swap space. - if [[ -n $(disklabel $ROOTDISK 2>&1 | sed -ne '/^ *\(b\):.*swap/s//\1/p') ]]; then - echo "${ROOTDISK}b will be used for swap space." + # Ensure that $SWAPDEV was configured as swap space. + if [[ -n $(grep "^$SWAPDEV" $SWAPLIST) ]]; then + echo "$SWAPDEV will be used for swap space." + # But we really don't want it in the installed + # /etc/fstab. + grep -v "^$SWAPDEV" $SWAPLIST > $SWAPLIST.tmp + mv $SWAPLIST.tmp $SWAPLIST else - echo "ERROR: Unable to use ${ROOTDISK}b for swap space." + echo "ERROR: Unable to use $SWAPDEV for swap space." DISK= fi [[ -n $DISK ]] || echo "You must reconfigure $ROOTDISK." @@ -213,7 +222,7 @@ if [ ! -f /etc/fstab ]; then _i=0 for _pp in ${_partitions[*]}; do _mp=${_mount_points[$_i]} - [ "$_mp" ] && echo "$_pp $_mp" >> $FILESYSTEMS + [ "$_mp" ] && echo "$_pp $_mp" >>$FILESYSTEMS : $(( _i += 1 )) done done @@ -246,7 +255,7 @@ __EOT _partitions[$_i]=$_pp _mount_points[$_i]=$_mp : $(( _i += 1 )) - done < $FILESYSTEMS + done <$FILESYSTEMS # Write fstab entries to /tmp/fstab in mount point alphabetic # order to enforce a rational mount order. @@ -304,6 +313,11 @@ __EOT done done >> /tmp/fstab + # Append all non-default swap devices to fstab. + while read _dev; do + echo "/dev/$_dev none swap sw 0 0" >>/tmp/fstab + done < $SWAPLIST + munge_fstab fi diff --git a/distrib/miniroot/install.sub b/distrib/miniroot/install.sub index 03edb12f610..b0651168838 100644 --- a/distrib/miniroot/install.sub +++ b/distrib/miniroot/install.sub @@ -1,4 +1,4 @@ -# $OpenBSD: install.sub,v 1.306 2003/06/23 00:38:57 krw Exp $ +# $OpenBSD: install.sub,v 1.307 2003/06/27 22:40:40 krw Exp $ # $NetBSD: install.sub,v 1.5.2.8 1996/09/02 23:25:02 pk Exp $ # # Copyright (c) 1997-2003 Todd Miller, Theo de Raadt, Ken Westerback @@ -457,12 +457,14 @@ fi ROOTDISK= ROOTDEV= + SWAPDEV= ask_which "disk" "is the root disk?" "$DKDEVS" "$_defdsk" [ "$resp" = "done" ] && exit ROOTDISK=$resp ROOTDEV=${ROOTDISK}a + SWAPDEV=${ROOTDISK}b } # Create an entry in the hosts file. If an entry with the @@ -1688,10 +1690,24 @@ set_machdep_apertureallowed() { } finish_up() { - local _dev + local _dev _mp _fstype _rest set_timezone + # Mount all known swap partitions. This gives systems with little + # memory a better chance at running 'MAKEDEV all'. + if [[ -x /mnt/sbin/swapctl ]]; then + /mnt/sbin/swapctl -a /dev/$SWAPDEV >/dev/null 2>&1 + # Can't do chmod && swapctl -A because devices are not yet + # created on install'ed systems. On upgrade'ed system there + # is a small chance the device does not exist on the ramdisk + # and will thus not get mounted. + while read _dev _mp _fstype _rest; do + [[ $_fstype == swap ]] && \ + /mnt/sbin/swapctl -a $_dev >/dev/null 2>&1 + done </mnt/etc/fstab + fi + echo -n "Making all device nodes..." cd /mnt/dev sh MAKEDEV all |