2005-07-13 15:04:56 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2005-08-12 13:08:23 +02:00
|
|
|
# setup 4.1 - install a MINIX distribution
|
|
|
|
#
|
|
|
|
# Changes:
|
|
|
|
# Aug 2005 robustness checks and beautifications (Jorrit N. Herder)
|
2005-09-08 18:04:34 +02:00
|
|
|
# Jul 2005 extended with autopart and networking (Ben Gras)
|
2005-08-12 13:08:23 +02:00
|
|
|
# Dec 20, 1994 created (Kees J. Bot)
|
|
|
|
#
|
2005-07-13 15:04:56 +02:00
|
|
|
|
2005-08-05 18:49:38 +02:00
|
|
|
LOCALRC=/usr/etc/rc.local
|
2005-08-24 09:26:48 +02:00
|
|
|
MYLOCALRC=/mnt/etc/rc.local
|
2014-09-03 18:36:11 +02:00
|
|
|
ROOTMB=128
|
2005-09-08 11:29:17 +02:00
|
|
|
ROOTSECTS="`expr $ROOTMB '*' 1024 '*' 2`"
|
2012-02-07 16:14:27 +01:00
|
|
|
BOOTXXSECTS=32
|
2013-11-05 15:43:44 +01:00
|
|
|
USRKB="`du -sxk /usr | awk '{ print $1 }'`"
|
2005-09-09 14:22:19 +02:00
|
|
|
TOTALMB="`expr 3 + $USRKB / 1024 + $ROOTMB`"
|
2013-11-05 15:43:44 +01:00
|
|
|
ROOTFILES="`find -x / | wc -l`"
|
|
|
|
USRFILES="`find -x /usr | wc -l`"
|
|
|
|
|
|
|
|
# /usr/install isn't copied onto the new system; compensate
|
|
|
|
INSTALLDIR=/usr/install
|
|
|
|
if [ -d $INSTALLDIR ]
|
2013-11-18 11:25:30 +01:00
|
|
|
then USRFILES=$(($USRFILES - `find -x $INSTALLDIR | wc -l`))
|
|
|
|
USRKB=$(($USRKB - `du -sxk $INSTALLDIR | awk '{ print $1 }'`))
|
2013-11-05 15:43:44 +01:00
|
|
|
fi
|
2005-08-05 18:49:38 +02:00
|
|
|
|
2011-12-22 17:54:36 +01:00
|
|
|
if [ -z "$FSTYPE" ]
|
|
|
|
then FSTYPE=mfs
|
|
|
|
fi
|
|
|
|
|
2012-01-30 14:21:41 +01:00
|
|
|
PATH=/bin:/sbin:/usr/bin:/usr/sbin
|
2005-07-13 15:04:56 +02:00
|
|
|
export PATH
|
|
|
|
|
2005-08-12 13:08:23 +02:00
|
|
|
|
2005-07-13 15:04:56 +02:00
|
|
|
usage()
|
|
|
|
{
|
|
|
|
cat >&2 <<'EOF'
|
|
|
|
Usage: setup # Install a skeleton system on the hard disk.
|
|
|
|
setup /usr # Install the rest of the system (binaries or sources).
|
|
|
|
|
|
|
|
# To install from other things then floppies:
|
|
|
|
|
2010-10-02 20:24:53 +02:00
|
|
|
fetch -q -o - http://... | setup /usr # Read from a web site.
|
|
|
|
fetch -q -o - ftp://... | setup /usr # Read from an FTP site.
|
2005-07-13 15:04:56 +02:00
|
|
|
mtools copy c0d0p0:... - | setup /usr # Read from the C: drive.
|
|
|
|
dosread c0d0p0 ... | setup /usr # Likewise if no mtools.
|
|
|
|
EOF
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2005-08-12 13:08:23 +02:00
|
|
|
warn()
|
|
|
|
{
|
|
|
|
echo -e "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b ! $1"
|
|
|
|
}
|
|
|
|
|
2012-02-14 20:17:58 +01:00
|
|
|
check_mbr()
|
|
|
|
{
|
|
|
|
# check for potential problems with old mbr.
|
|
|
|
disk=`echo -n "/dev/$primary" | sed 's/p[0-3]//'`
|
|
|
|
minix_primaries=`echo -n "" | fdisk "$disk" | grep "MINIX" | wc -l`
|
|
|
|
if [ "$minix_primaries" -gt 1 ]
|
|
|
|
then
|
|
|
|
# old mbr + bootxx will not work with several partitions of
|
|
|
|
# the same type.
|
|
|
|
dd if=/usr/mdec/mbr of=temp_mbr_netbsd bs=1 count=440 2>/dev/null
|
|
|
|
dd if="$disk" bs=1 count=440 2>/dev/null | cmp - temp_mbr_netbsd >/dev/null
|
|
|
|
if [ "$?" -ne 0 ]
|
|
|
|
then
|
|
|
|
echo ""
|
|
|
|
echo "Warning: you have MBR which doesn't support multiple MINIX 3 partitions!"
|
|
|
|
echo "You will be able to boot from the first one only!"
|
|
|
|
echo -n "Do you want to install new MBR into $disk? [Y] "
|
|
|
|
read ok
|
|
|
|
if [ "$ok" = Y -o "$ok" = y -o "$ok" = "" ]
|
|
|
|
then
|
|
|
|
installboot_nbsd -m "$disk" /usr/mdec/mbr >/dev/null
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
rm temp_mbr_netbsd
|
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2005-07-13 15:04:56 +02:00
|
|
|
# No options.
|
|
|
|
while getopts '' opt; do usage; done
|
|
|
|
shift `expr $OPTIND - 1`
|
|
|
|
|
2005-07-13 16:59:43 +02:00
|
|
|
if [ "$USER" != root ]
|
2005-07-26 15:14:59 +02:00
|
|
|
then echo "Please run setup as root."
|
2005-07-13 16:59:43 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
2005-07-13 15:04:56 +02:00
|
|
|
|
|
|
|
# Find out what we are running from.
|
|
|
|
exec 9<&0 </etc/mtab # Mounted file table.
|
|
|
|
read thisroot rest # Current root (/dev/ram or /dev/fd?)
|
|
|
|
read fdusr rest # USR (/dev/fd? or /dev/fd?p2)
|
|
|
|
exec 0<&9 9<&-
|
|
|
|
|
|
|
|
# What do we know about ROOT?
|
|
|
|
case $thisroot:$fdusr in
|
|
|
|
/dev/ram:/dev/fd0p2) fdroot=/dev/fd0 # Combined ROOT+USR in drive 0
|
|
|
|
;;
|
|
|
|
/dev/ram:/dev/fd1p2) fdroot=/dev/fd1 # Combined ROOT+USR in drive 1
|
|
|
|
;;
|
|
|
|
/dev/ram:/dev/fd*) fdroot=unknown # ROOT is some other floppy
|
|
|
|
;;
|
|
|
|
/dev/fd*:/dev/fd*) fdroot=$thisroot # ROOT is mounted directly
|
|
|
|
;;
|
|
|
|
*) fdroot=$thisroot # ?
|
|
|
|
esac
|
|
|
|
|
2005-08-11 15:12:55 +02:00
|
|
|
echo -n "
|
2005-09-10 22:33:11 +02:00
|
|
|
Welcome to the MINIX 3 setup script. This script will guide you in setting up
|
2005-08-12 13:08:23 +02:00
|
|
|
MINIX on your machine. Please consult the manual for detailed instructions.
|
2005-07-13 15:04:56 +02:00
|
|
|
|
2005-08-09 13:16:15 +02:00
|
|
|
Note 1: If the screen blanks, hit CTRL+F3 to select \"software scrolling\".
|
2005-08-12 13:08:23 +02:00
|
|
|
Note 2: If things go wrong then hit CTRL+C to abort and start over.
|
2005-08-11 15:12:55 +02:00
|
|
|
Note 3: Default answers, like [y], can simply be chosen by hitting ENTER.
|
2005-08-08 16:28:32 +02:00
|
|
|
Note 4: If you see a colon (:) then you should hit ENTER to continue.
|
2005-07-13 15:04:56 +02:00
|
|
|
:"
|
|
|
|
read ret
|
|
|
|
|
2005-08-12 13:08:23 +02:00
|
|
|
# begin Step 1
|
2005-08-11 15:12:55 +02:00
|
|
|
echo ""
|
|
|
|
echo " --- Step 1: Select keyboard type --------------------------------------"
|
|
|
|
echo ""
|
2005-07-13 15:04:56 +02:00
|
|
|
|
2005-08-12 13:08:23 +02:00
|
|
|
echo "What type of keyboard do you have? You can choose one of:"
|
|
|
|
echo ""
|
|
|
|
ls -C /usr/lib/keymaps | sed -e 's/\.map//g' -e 's/^/ /'
|
|
|
|
echo ""
|
|
|
|
step1=""
|
|
|
|
while [ "$step1" != ok ]
|
|
|
|
do
|
|
|
|
echo -n "Keyboard type? [us-std] "; read keymap
|
|
|
|
test -n "$keymap" || keymap=us-std
|
|
|
|
if loadkeys "/usr/lib/keymaps/$keymap.map" 2>/dev/null
|
|
|
|
then step1=ok
|
|
|
|
else warn "invalid keyboard"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
# end Step 1
|
|
|
|
|
|
|
|
# begin Step 2
|
2009-09-03 11:38:27 +02:00
|
|
|
#step2=""
|
|
|
|
#while [ "$step2" != ok ]
|
2007-01-22 16:47:40 +01:00
|
|
|
#do
|
|
|
|
# echo ""
|
2009-09-03 11:38:27 +02:00
|
|
|
# echo " --- Step 2: Select minimal or full distribution -----------------------"
|
2007-01-22 16:47:40 +01:00
|
|
|
# echo ""
|
|
|
|
# echo "You can install MINIX as (M)inimal or (F)ull. (M)inimal"
|
|
|
|
# echo "includes only the binary system and basic system sources."
|
|
|
|
# echo "(F)ull also includes commands sources."
|
|
|
|
# echo ""
|
|
|
|
# echo "Please select:"
|
|
|
|
# echo " (M)inimal install (only basic sources) ($NOSRCMB MB required)"
|
|
|
|
# echo " (F)ull install (full install) ($TOTALMB MB required)"
|
|
|
|
# echo " "
|
|
|
|
# echo -n "Basic (M)inimal or (F)ull install? [F] "
|
|
|
|
# read conf
|
|
|
|
# case "$conf" in
|
2009-09-03 11:38:27 +02:00
|
|
|
# "") step2="ok"; nobigsource="" ;;
|
|
|
|
# [Ff]*) step2="ok"; nobigsource="" ;;
|
|
|
|
# [Mm]*) step2="ok"; nobigsource="1"; TOTALMB=$NOSRCMB; USRFILES=$NOSRCUSRFILES ;;
|
2007-01-22 16:47:40 +01:00
|
|
|
# esac
|
|
|
|
#done
|
2009-09-03 11:38:27 +02:00
|
|
|
# end Step 2
|
2005-09-12 17:22:49 +02:00
|
|
|
|
2007-01-22 16:47:40 +01:00
|
|
|
echo ""
|
2009-09-03 11:38:27 +02:00
|
|
|
echo " --- Step 2: Selecting full distribution -------------------------------"
|
2007-01-22 16:47:40 +01:00
|
|
|
echo ""
|
|
|
|
nobigsource=""
|
|
|
|
|
2009-09-03 11:38:27 +02:00
|
|
|
# begin Step 3
|
|
|
|
step3=""
|
|
|
|
while [ "$step3" != ok ]
|
2005-09-12 17:22:49 +02:00
|
|
|
do
|
|
|
|
echo ""
|
2009-09-03 11:38:27 +02:00
|
|
|
echo " --- Step 3: Create or select a partition for MINIX 3 -------------------"
|
2005-08-31 18:40:41 +02:00
|
|
|
echo ""
|
2005-08-11 15:12:55 +02:00
|
|
|
|
2005-08-12 13:08:23 +02:00
|
|
|
echo "Now you need to create a MINIX 3 partition on your hard disk."
|
2005-08-31 18:29:56 +02:00
|
|
|
echo "You can also select one that's already there."
|
|
|
|
echo " "
|
2005-09-08 18:04:34 +02:00
|
|
|
echo "If you have an existing installation, reinstalling will let you"
|
2005-08-31 18:29:56 +02:00
|
|
|
echo "keep your current partitioning and subpartitioning, and overwrite"
|
2005-09-09 14:22:19 +02:00
|
|
|
echo "everything except your s1 subpartition (/home). If you want to"
|
2005-09-08 18:04:34 +02:00
|
|
|
echo "reinstall, select your existing minix partition."
|
2005-08-31 18:29:56 +02:00
|
|
|
echo " "
|
2005-08-12 13:08:23 +02:00
|
|
|
echo "Unless you are an expert, you are advised to use the automated"
|
|
|
|
echo "step-by-step help in setting up."
|
|
|
|
echo ""
|
|
|
|
ok=""
|
|
|
|
while [ "$ok" = "" ]
|
|
|
|
do
|
2005-09-08 18:04:34 +02:00
|
|
|
echo -n "Press ENTER for automatic mode, or type 'expert': "
|
2005-08-31 18:40:41 +02:00
|
|
|
read mode
|
|
|
|
if [ -z "$mode" ]; then auto="1"; ok="yes"; fi
|
|
|
|
if [ "$mode" = expert ]; then auto=""; ok="yes"; fi
|
|
|
|
if [ "$ok" != yes ]; then warn "try again"; fi
|
2005-08-12 13:08:23 +02:00
|
|
|
done
|
2005-07-13 16:59:43 +02:00
|
|
|
|
2005-08-31 18:40:41 +02:00
|
|
|
primary=
|
2005-07-13 16:59:43 +02:00
|
|
|
|
2005-08-31 18:40:41 +02:00
|
|
|
if [ -z "$auto" ]
|
|
|
|
then
|
|
|
|
# Expert mode
|
|
|
|
echo -n "
|
2005-09-09 14:22:19 +02:00
|
|
|
MINIX needs one primary partition of $TOTALMB MB for a full install,
|
|
|
|
plus what you want for /home.
|
2005-07-13 15:04:56 +02:00
|
|
|
|
2005-08-09 13:16:15 +02:00
|
|
|
If there is no free space on your disk then you have to choose an option:
|
|
|
|
(1) Delete one or more partitions
|
|
|
|
(2) Allocate an existing partition to MINIX 3
|
|
|
|
(3) Exit setup and shrink a partition using a different OS
|
2005-07-13 15:04:56 +02:00
|
|
|
|
|
|
|
To make this partition you will be put in the editor \"part\". Follow the
|
|
|
|
advice under the '!' key to make a new partition of type MINIX. Do not
|
|
|
|
touch an existing partition unless you know precisely what you are doing!
|
|
|
|
Please note the name of the partition (e.g. c0d0p1, c0d1p3, c1d1p0) you
|
2005-08-08 16:28:32 +02:00
|
|
|
make. (See the devices section in usage(8) on MINIX device names.)
|
2005-07-13 15:04:56 +02:00
|
|
|
:"
|
2005-08-31 18:40:41 +02:00
|
|
|
read ret
|
2005-08-31 18:29:56 +02:00
|
|
|
|
|
|
|
while [ -z "$primary" ]
|
|
|
|
do
|
2005-08-31 18:40:41 +02:00
|
|
|
part || exit
|
|
|
|
|
2005-08-31 18:29:56 +02:00
|
|
|
echo -n "
|
2005-08-31 18:40:41 +02:00
|
|
|
Please finish the name of the primary partition you have created:
|
|
|
|
(Just type ENTER if you want to rerun \"part\") /dev/"
|
2005-08-31 18:29:56 +02:00
|
|
|
read primary
|
|
|
|
done
|
|
|
|
echo ""
|
2005-08-31 18:40:41 +02:00
|
|
|
echo "This is the point of no return. You have selected to install MINIX"
|
2005-08-31 18:29:56 +02:00
|
|
|
echo "on partition /dev/$primary. Please confirm that you want to use this"
|
2005-08-31 18:40:41 +02:00
|
|
|
echo "selection to install MINIX."
|
2005-08-31 18:29:56 +02:00
|
|
|
echo ""
|
|
|
|
confirmation=""
|
2007-02-23 11:21:55 +01:00
|
|
|
|
|
|
|
if [ ! -b "/dev/$primary" ]
|
|
|
|
then echo "/dev/$primary is not a block device."
|
|
|
|
fi
|
|
|
|
|
2005-08-31 18:29:56 +02:00
|
|
|
while [ -z "$confirmation" -o "$confirmation" != yes -a "$confirmation" != no ]
|
|
|
|
do
|
|
|
|
echo -n "Are you sure you want to continue? Please enter 'yes' or 'no': "
|
|
|
|
read confirmation
|
2009-09-03 11:38:27 +02:00
|
|
|
if [ "$confirmation" = yes ]; then step3=ok; fi
|
2005-08-31 18:29:56 +02:00
|
|
|
done
|
2005-08-31 18:40:41 +02:00
|
|
|
biosdrivename="Actual BIOS device name unknown, due to expert mode."
|
|
|
|
else
|
|
|
|
if [ "$auto" = "1" ]
|
|
|
|
then
|
|
|
|
# Automatic mode
|
|
|
|
PF="/tmp/pf"
|
2005-09-09 14:22:19 +02:00
|
|
|
if autopart -m$TOTALMB -f$PF
|
2005-08-31 18:40:41 +02:00
|
|
|
then if [ -s "$PF" ]
|
|
|
|
then
|
2005-08-31 18:46:24 +02:00
|
|
|
set `cat $PF`
|
|
|
|
bd="$1"
|
|
|
|
bdn="$2"
|
2005-08-31 18:40:41 +02:00
|
|
|
biosdrivename="Probably, the right command is \"boot $bdn\"."
|
|
|
|
if [ -b "/dev/$bd" ]
|
|
|
|
then primary="$bd"
|
|
|
|
else echo "Funny device $bd from autopart."
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Didn't find output from autopart."
|
|
|
|
fi
|
|
|
|
else echo "Autopart tool failed. Trying again."
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Reset at retries and timeouts in case autopart left
|
|
|
|
# them messy.
|
|
|
|
atnormalize
|
|
|
|
|
2009-09-03 11:38:27 +02:00
|
|
|
if [ -n "$primary" ]; then step3=ok; fi
|
2005-08-31 18:40:41 +02:00
|
|
|
fi
|
2005-08-31 18:29:56 +02:00
|
|
|
fi
|
2005-09-10 22:33:11 +02:00
|
|
|
|
|
|
|
if [ ! -b "/dev/$primary" ]
|
2009-09-03 11:38:27 +02:00
|
|
|
then echo Doing step 3 again.
|
|
|
|
step3=""
|
2005-09-13 11:52:15 +02:00
|
|
|
else
|
|
|
|
devsize="`devsize /dev/$primary`"
|
|
|
|
|
|
|
|
if [ "$devsize" -lt 1 ]
|
|
|
|
then echo "/dev/$primary is a 0-sized device."
|
2009-09-03 11:38:27 +02:00
|
|
|
step3=""
|
2005-09-13 11:52:15 +02:00
|
|
|
fi
|
2005-09-10 22:33:11 +02:00
|
|
|
fi
|
2009-09-03 11:38:27 +02:00
|
|
|
done # while step3 != ok
|
|
|
|
# end Step 3
|
2005-07-13 15:04:56 +02:00
|
|
|
|
2005-09-08 18:04:34 +02:00
|
|
|
root=${primary}s0
|
|
|
|
home=${primary}s1
|
|
|
|
usr=${primary}s2
|
|
|
|
umount /dev/$root 2>/dev/null && echo "Unmounted $root for you."
|
|
|
|
umount /dev/$home 2>/dev/null && echo "Unmounted $home for you."
|
|
|
|
umount /dev/$usr 2>/dev/null && echo "Unmounted $usr for you."
|
|
|
|
|
2005-09-09 14:22:19 +02:00
|
|
|
devsizemb="`expr $devsize / 1024 / 2`"
|
2005-09-11 22:23:46 +02:00
|
|
|
maxhome="`expr $devsizemb - $TOTALMB - 1`"
|
2005-09-09 14:22:19 +02:00
|
|
|
|
2005-09-13 11:52:15 +02:00
|
|
|
if [ "$devsizemb" -lt "$TOTALMB" ]
|
2005-09-09 14:22:19 +02:00
|
|
|
then echo "The selected partition ($devsizemb MB) is too small."
|
|
|
|
echo "You'll need $TOTALMB MB at least."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2005-09-13 11:52:15 +02:00
|
|
|
if [ "$maxhome" -lt 1 ]
|
2005-09-11 22:23:46 +02:00
|
|
|
then echo "Note: you can't have /home with that size partition."
|
|
|
|
maxhome=0
|
|
|
|
fi
|
|
|
|
|
2005-09-08 18:04:34 +02:00
|
|
|
TMPMP=/m
|
|
|
|
mkdir $TMPMP >/dev/null 2>&1
|
|
|
|
|
|
|
|
confirm=""
|
|
|
|
|
|
|
|
while [ "$confirm" = "" ]
|
|
|
|
do
|
2005-09-09 14:22:19 +02:00
|
|
|
auto=""
|
2005-09-08 18:04:34 +02:00
|
|
|
echo ""
|
2009-09-03 11:38:27 +02:00
|
|
|
echo " --- Step 4: Reinstall choice ------------------------------------------"
|
2005-09-11 22:23:46 +02:00
|
|
|
if mount -r /dev/$home $TMPMP >/dev/null 2>&1
|
2005-09-08 18:04:34 +02:00
|
|
|
then umount /dev/$home >/dev/null 2>&1
|
|
|
|
echo ""
|
2005-09-09 14:22:19 +02:00
|
|
|
echo "You have selected an existing MINIX 3 partition."
|
|
|
|
echo "Type F for full installation (to overwrite entire partition)"
|
|
|
|
echo "Type R for a reinstallation (existing /home will not be affected)"
|
2012-02-14 20:17:58 +01:00
|
|
|
echo "Type B to reinstall/upgrade bootloader (no data affected)"
|
2005-09-08 18:04:34 +02:00
|
|
|
echo ""
|
2012-02-14 20:17:58 +01:00
|
|
|
echo -n "(F)ull, (R)einstall or (B)ootloader install? [R] "
|
2005-09-09 14:22:19 +02:00
|
|
|
read conf
|
|
|
|
case "$conf" in
|
|
|
|
"") confirm="ok"; auto="r"; ;;
|
|
|
|
[Rr]*) confirm="ok"; auto="r"; ;;
|
|
|
|
[Ff]*) confirm="ok"; auto="" ;;
|
2012-02-14 20:17:58 +01:00
|
|
|
[Bb]*) confirm="ok"; bootreinstall="ok" ;;
|
2005-09-09 14:22:19 +02:00
|
|
|
esac
|
|
|
|
|
2005-09-12 15:25:40 +02:00
|
|
|
else echo ""
|
|
|
|
echo "No old /home found. Doing full install."
|
|
|
|
echo ""
|
|
|
|
confirm="ok";
|
2005-09-08 18:04:34 +02:00
|
|
|
fi
|
2005-09-09 14:22:19 +02:00
|
|
|
|
2005-09-08 18:04:34 +02:00
|
|
|
done
|
2005-08-31 18:48:46 +02:00
|
|
|
|
2012-02-14 20:17:58 +01:00
|
|
|
if [ "$bootreinstall" = "ok" ]
|
|
|
|
then
|
|
|
|
echo ""
|
|
|
|
echo " --- Step 5: Reinstall bootloader ----------------------------------"
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
echo "WARNING: This procedure uses your current /usr to store your /."
|
|
|
|
echo "Once the procedure starts, it has to finish"
|
|
|
|
echo "to restore your / partition. Please make sure it is not interrupted."
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
echo -n "It's recommended to run fsck before you continue, run? [Y/n] "
|
|
|
|
read ok
|
|
|
|
if [ "$ok" = "y" -o "$ok" = "Y" -o "$ok" = "" ]
|
|
|
|
then
|
2014-09-05 10:01:18 +02:00
|
|
|
fsck -t mfs -T mfs:-a "/dev/$root" >/dev/null
|
|
|
|
fsck -t mfs -T mfs:-a "/dev/$usr" >/dev/null
|
2012-02-14 20:17:58 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# If there is no ELF stuff and not enough space after repartitioning,
|
|
|
|
# user will fall into trouble. So at first copy new stuff.
|
|
|
|
mount "/dev/$root" /mnt >/dev/null || exit
|
|
|
|
|
|
|
|
# grep, stat, etc in chroot
|
|
|
|
mount "/dev/$usr" /mnt/usr >/dev/null || exit
|
|
|
|
|
|
|
|
cp -pf /bin/update_bootcfg /mnt/bin/ && \
|
|
|
|
cp -pf /etc/boot.cfg.default /mnt/etc/ && \
|
2014-09-05 10:01:18 +02:00
|
|
|
cp -pf /usr/mdec/boot_monitor /mnt/ || exit
|
2012-02-14 20:17:58 +01:00
|
|
|
|
|
|
|
if [ ! -d /mnt/boot/minix_default -o ! -r /mnt/boot/minix_default/kernel ]
|
|
|
|
then
|
|
|
|
if [ -r /mnt/boot.cfg ]
|
|
|
|
then
|
|
|
|
echo ""
|
|
|
|
echo "There is no /boot/minix_default/, but /boot.cfg exists."
|
|
|
|
echo -n "Do you want to copy minix_default from CD? [Y/n] "
|
|
|
|
else
|
|
|
|
echo ""
|
|
|
|
echo -n "There is no /boot/minix_default/, do you want to copy it from CD? [Y/n] "
|
|
|
|
fi
|
|
|
|
read ok
|
|
|
|
if [ "$ok" = "y" -o "$ok" = "Y" -o "$ok" = "" ]
|
|
|
|
then
|
|
|
|
if [ -e /mnt/boot/minix_default ]
|
|
|
|
then
|
|
|
|
echo "Old /boot/minix_default moved to /boot/minix_default_old"
|
|
|
|
mv /mnt/boot/minix_default /mnt/boot/minix_default_old
|
|
|
|
fi
|
|
|
|
|
|
|
|
cp -rfp /boot/minix_default /mnt/boot/ || exit
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo " * Updating /boot.cfg"
|
|
|
|
|
|
|
|
chroot /mnt update_bootcfg
|
|
|
|
|
2012-10-16 19:04:40 +02:00
|
|
|
sync
|
|
|
|
|
|
|
|
# Get sizes and space availability while the file systems are still
|
|
|
|
# mounted. Otherwise we have to mount them again just for this.
|
2013-08-19 20:34:15 +02:00
|
|
|
required_root_space=`df -kP /dev/$root | awk '{print $3}' | tail -n 1`
|
|
|
|
free_root_space=`df -kP /dev/$root | awk '{print $4}' | tail -n 1`
|
|
|
|
free_usr_space=`df -kP /dev/$usr | awk '{print $4}' | tail -n 1`
|
2012-10-16 19:04:40 +02:00
|
|
|
|
2012-02-14 20:17:58 +01:00
|
|
|
umount /mnt/usr && umount /mnt || exit
|
|
|
|
|
|
|
|
# Check if enough space for new boot
|
2014-09-05 10:01:18 +02:00
|
|
|
bootspace=$((`devsize /dev/$primary`-`devsize /dev/$root`-`devsize /dev/$home`-`devsize /dev/$usr`)) >/dev/null
|
2012-02-14 20:17:58 +01:00
|
|
|
if [ $bootspace -lt $BOOTXXSECTS ]
|
|
|
|
then
|
|
|
|
echo ""
|
|
|
|
echo "Root partition size will be reduced by up to 16Kb to fit new bootloader."
|
|
|
|
echo "This is not a problem."
|
|
|
|
|
|
|
|
# round 16 => 20
|
2012-10-16 19:04:40 +02:00
|
|
|
if [ "$free_root_space" -le 20 ]
|
2012-02-14 20:17:58 +01:00
|
|
|
then
|
|
|
|
echo ""
|
|
|
|
echo "Not enough space on /dev/$root, you need at least 20Kb to use new bootloader!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
ROOTSECTS=`expr \`devsize /dev/$root\` - $BOOTXXSECTS + $bootspace`
|
|
|
|
|
2012-10-16 19:04:40 +02:00
|
|
|
if [ "$required_root_space" -gt "$free_usr_space" ]
|
2012-02-14 20:17:58 +01:00
|
|
|
then
|
|
|
|
echo ""
|
|
|
|
echo "You don't have enough free space on /dev/$usr to backup /dev/$root!"
|
2012-10-16 19:04:40 +02:00
|
|
|
echo "${free_usr_space}Kb available, ${required_root_space} required."
|
2012-02-14 20:17:58 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir /mnt/root && mkdir /mnt/usr || exit
|
|
|
|
|
|
|
|
echo "Re-mounting your current / and /usr"
|
|
|
|
|
|
|
|
mount "/dev/$root" /mnt/root || exit
|
|
|
|
mount "/dev/$usr" /mnt/usr || exit
|
|
|
|
|
|
|
|
mkdir /mnt/usr/tmp/root_backup || exit
|
|
|
|
|
|
|
|
echo " * Copying / contents"
|
|
|
|
|
|
|
|
cp -rfp /mnt/root/* /mnt/usr/tmp/root_backup
|
|
|
|
if [ $? -ne 0 ]
|
|
|
|
then
|
|
|
|
echo ""
|
|
|
|
echo "Failed to backup root partition, aborting!"
|
|
|
|
rm -rf /mnt/usr/tmp/root_backup
|
|
|
|
# umount shouldn't fail here, but if it will, next
|
|
|
|
# "rm -rf" will serve for user's pleasure.
|
|
|
|
umount /mnt/root >/dev/null || exit
|
|
|
|
umount /mnt/usr >/dev/null || exit
|
|
|
|
rm -rf /mnt/root /mnt/usr
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo " * Copying done"
|
|
|
|
|
|
|
|
umount /mnt/root
|
|
|
|
umount /mnt/usr
|
|
|
|
|
|
|
|
add_subpart=""
|
|
|
|
minix_subparts=`echo -n "" | fdisk /dev/$primary | grep "MINIX" | wc -l`
|
|
|
|
if [ "$minix_subparts" -gt 3 ]
|
|
|
|
then
|
|
|
|
echo ""
|
|
|
|
echo "You have additional subpartition except /, /usr and /home."
|
|
|
|
echo "Partition type will be set to MINIX (81), you can change it later using part."
|
|
|
|
echo -n "Do you want to continue? [Y/n] "
|
|
|
|
read ok
|
|
|
|
[ "$ok" = "n" -o "$ok" = "N" ] && exit
|
|
|
|
add_subpart="81:exist"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo " * Repartitioning"
|
|
|
|
|
|
|
|
partition /dev/$primary $BOOTXXSECTS 81:${ROOTSECTS}* 81:exist 81:exist $add_subpart || exit
|
|
|
|
|
|
|
|
echo " * mkfs on new /"
|
|
|
|
|
|
|
|
mkfs.mfs "/dev/$root" || exit
|
|
|
|
|
|
|
|
if [ $? -ne 0 ]
|
|
|
|
then
|
|
|
|
echo "Failed to repartition /dev/$primary"
|
|
|
|
rmdir /mnt/root
|
|
|
|
rmdir /mnt/usr
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
mount "/dev/$usr" /mnt/usr || exit
|
|
|
|
mount "/dev/$root" /mnt/root || exit
|
|
|
|
|
|
|
|
echo " * Filling new / filesystem"
|
|
|
|
|
|
|
|
mv /mnt/usr/tmp/root_backup/* /mnt/root/ || exit
|
|
|
|
if [ $? -ne 0 ]
|
|
|
|
then
|
|
|
|
echo "Failed to copy old root data! It is in /tmp/root_backup/"
|
|
|
|
fi
|
|
|
|
|
|
|
|
rmdir /mnt/usr/tmp/root_backup/
|
|
|
|
|
|
|
|
umount /mnt/root
|
|
|
|
umount /mnt/usr
|
|
|
|
fi
|
|
|
|
|
|
|
|
check_mbr
|
|
|
|
installboot_nbsd -f /dev/$primary /usr/mdec/bootxx_minixfs3 >/dev/null || exit 1
|
|
|
|
|
|
|
|
if [ $? -ne 0 ]
|
|
|
|
then
|
|
|
|
echo "Warning: failed to remove /tmp/root_backup!"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "New boot installed successfully! You can reboot now."
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2005-09-15 15:22:59 +02:00
|
|
|
rmdir $TMPMP
|
2005-09-15 15:22:45 +02:00
|
|
|
|
2005-09-09 14:22:19 +02:00
|
|
|
nohome="0"
|
|
|
|
|
2005-09-13 15:27:35 +02:00
|
|
|
homesize=""
|
2005-08-31 18:29:56 +02:00
|
|
|
if [ ! "$auto" = r ]
|
2005-09-13 15:39:42 +02:00
|
|
|
then
|
2005-09-12 15:25:40 +02:00
|
|
|
echo ""
|
2009-09-03 11:38:27 +02:00
|
|
|
echo " --- Step 5: Select the size of /home ----------------------------------"
|
2005-08-31 18:29:56 +02:00
|
|
|
while [ -z "$homesize" ]
|
|
|
|
do
|
2005-09-08 18:04:34 +02:00
|
|
|
|
2005-09-13 15:41:33 +02:00
|
|
|
# 20% of what is left over after / and /usr
|
2005-09-11 22:00:56 +02:00
|
|
|
# are taken.
|
2005-09-11 22:23:46 +02:00
|
|
|
defmb="`expr $maxhome / 5`"
|
2005-09-13 11:52:15 +02:00
|
|
|
if [ "$defmb" -gt "$maxhome" ]
|
2005-09-09 14:22:19 +02:00
|
|
|
then
|
|
|
|
defmb=$maxhome
|
|
|
|
fi
|
2005-09-08 18:04:34 +02:00
|
|
|
|
2005-08-31 18:29:56 +02:00
|
|
|
echo ""
|
2005-09-09 14:22:19 +02:00
|
|
|
echo "MINIX will take up $TOTALMB MB, without /home."
|
|
|
|
echo -n "How big do you want your /home to be in MB (0-$maxhome) ? [$defmb] "
|
2005-08-31 18:48:46 +02:00
|
|
|
read homesize
|
|
|
|
if [ "$homesize" = "" ] ; then homesize=$defmb; fi
|
2005-09-09 14:22:19 +02:00
|
|
|
if [ "$homesize" -lt 1 ]
|
|
|
|
then nohome=1
|
2005-09-13 15:27:35 +02:00
|
|
|
echo "Ok, not making a /home."
|
2005-09-09 14:22:19 +02:00
|
|
|
homesize=0
|
|
|
|
else
|
2005-09-13 15:27:35 +02:00
|
|
|
if [ "$homesize" -gt "$maxhome" ]
|
2005-09-09 14:22:19 +02:00
|
|
|
then echo "That won't fit!"
|
2005-09-13 15:41:33 +02:00
|
|
|
homesize=""
|
2005-09-09 14:22:19 +02:00
|
|
|
else
|
2005-09-26 13:34:57 +02:00
|
|
|
echo ""
|
2005-09-09 14:22:19 +02:00
|
|
|
echo -n "$homesize MB Ok? [Y] "
|
|
|
|
read ok
|
|
|
|
[ "$ok" = Y -o "$ok" = y -o "$ok" = "" ] || homesize=""
|
|
|
|
fi
|
|
|
|
fi
|
2005-08-31 18:29:56 +02:00
|
|
|
echo ""
|
|
|
|
done
|
|
|
|
# Homesize in sectors
|
|
|
|
homemb="$homesize MB"
|
2005-08-31 18:55:34 +02:00
|
|
|
homesize="`expr $homesize '*' 1024 '*' 2`"
|
2005-08-31 18:29:56 +02:00
|
|
|
else
|
2010-06-02 19:07:10 +02:00
|
|
|
# Root size same as our default? If not, warn and keep old root size
|
|
|
|
ROOTSECTSDEFAULT=$ROOTSECTS
|
|
|
|
ROOTSECTS="`devsize /dev/$root`"
|
|
|
|
ROOTMB="`expr $ROOTSECTS / 2048`"
|
|
|
|
if [ $ROOTSECTS -ne $ROOTSECTSDEFAULT ]
|
|
|
|
then
|
2012-02-07 16:14:27 +01:00
|
|
|
# Check if we
|
2010-06-02 19:07:10 +02:00
|
|
|
echo "Root partition size `expr $ROOTSECTS / 2`kb differs from default `expr $ROOTSECTSDEFAULT / 2`kb."
|
|
|
|
echo "This is not a problem, but you may want to do a fresh install at some point to"
|
|
|
|
echo "be able to benefit from the new default."
|
|
|
|
fi
|
|
|
|
|
2012-02-07 16:14:27 +01:00
|
|
|
# Check if enough space for new boot (even if old used)
|
2014-09-05 10:01:18 +02:00
|
|
|
bootspace=$((`devsize /dev/$primary`-`devsize /dev/$root`-`devsize /dev/$home`-`devsize /dev/$usr`)) >/dev/null
|
2012-02-07 16:14:27 +01:00
|
|
|
if [ $bootspace -lt $BOOTXXSECTS ]
|
|
|
|
then
|
|
|
|
echo "Root partition size will be reduced by up to 16Kb to fit new bootloader."
|
|
|
|
echo "This is not a problem."
|
|
|
|
ROOTSECTS=`expr $ROOTSECTS - $BOOTXXSECTS + $bootspace`
|
|
|
|
fi
|
|
|
|
|
2010-06-02 19:07:10 +02:00
|
|
|
# Recompute totals based on root size
|
|
|
|
TOTALMB="`expr 3 + $USRKB / 1024 + $ROOTMB`"
|
|
|
|
maxhome="`expr $devsizemb - $TOTALMB - 1`"
|
|
|
|
|
2005-09-13 15:45:22 +02:00
|
|
|
homepart="`devsize /dev/$home`"
|
|
|
|
homesize="`expr $homepart / 2 / 1024`"
|
2005-09-13 15:39:42 +02:00
|
|
|
if [ "$homesize" -gt "$maxhome" ]
|
|
|
|
then
|
|
|
|
echo "Sorry, but your /home is too big ($homesize MB) to leave enough"
|
|
|
|
echo "space on the rest of the partition ($devsizemb MB) for your"
|
|
|
|
echo "selected installation size ($TOTALMB MB)."
|
|
|
|
exit 1
|
|
|
|
fi
|
2005-08-31 18:29:56 +02:00
|
|
|
# Homesize unchanged (reinstall)
|
|
|
|
homesize=exist
|
|
|
|
homemb="current size"
|
|
|
|
fi
|
2005-08-12 13:08:23 +02:00
|
|
|
|
2009-12-02 16:33:14 +01:00
|
|
|
minblocksize=1
|
|
|
|
maxblocksize=64
|
2005-08-10 17:14:14 +02:00
|
|
|
blockdefault=4
|
2005-08-09 13:16:15 +02:00
|
|
|
|
2005-08-31 18:29:56 +02:00
|
|
|
if [ ! "$auto" = "r" ]
|
|
|
|
then
|
|
|
|
echo ""
|
2009-09-03 11:38:27 +02:00
|
|
|
echo " --- Step 6: Select a block size ---------------------------------------"
|
2005-08-31 18:29:56 +02:00
|
|
|
echo ""
|
|
|
|
|
2009-12-02 16:33:14 +01:00
|
|
|
echo "The default file system block size is $blockdefault kB."
|
2005-08-31 18:29:56 +02:00
|
|
|
echo ""
|
|
|
|
|
|
|
|
while [ -z "$blocksize" ]
|
|
|
|
do
|
|
|
|
echo -n "Block size in kilobytes? [$blockdefault] "; read blocksize
|
|
|
|
test -z "$blocksize" && blocksize=$blockdefault
|
2009-12-02 16:33:14 +01:00
|
|
|
if [ "$blocksize" -lt $minblocksize -o "$blocksize" -gt $maxblocksize ]
|
2005-08-31 18:29:56 +02:00
|
|
|
then
|
2009-12-02 16:33:14 +01:00
|
|
|
warn "At least $minblocksize kB and at most $maxblocksize kB please."
|
2005-08-31 18:29:56 +02:00
|
|
|
blocksize=""
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
else
|
|
|
|
blocksize=$blockdefault
|
|
|
|
fi
|
2005-07-22 20:30:40 +02:00
|
|
|
|
2012-02-07 16:14:27 +01:00
|
|
|
blocksizebytes="`expr $blocksize '*' 1024`"
|
|
|
|
|
|
|
|
bootsectors=$BOOTXXSECTS
|
2012-01-30 14:21:41 +01:00
|
|
|
|
2012-02-14 20:17:58 +01:00
|
|
|
check_mbr
|
2012-01-30 14:21:41 +01:00
|
|
|
|
2005-08-11 15:12:55 +02:00
|
|
|
echo "
|
2005-09-10 22:33:11 +02:00
|
|
|
You have selected to (re)install MINIX 3 in the partition /dev/$primary.
|
2005-08-12 13:42:57 +02:00
|
|
|
The following subpartitions are now being created on /dev/$primary:
|
2005-07-13 15:04:56 +02:00
|
|
|
|
2005-09-08 11:29:17 +02:00
|
|
|
Root subpartition: /dev/$root $ROOTMB MB
|
2005-08-31 18:29:56 +02:00
|
|
|
/home subpartition: /dev/$home $homemb
|
2005-07-13 15:04:56 +02:00
|
|
|
/usr subpartition: /dev/$usr rest of $primary
|
2005-08-11 15:12:55 +02:00
|
|
|
"
|
2005-07-13 15:04:56 +02:00
|
|
|
# Secondary master bootstrap.
|
2012-01-30 14:21:41 +01:00
|
|
|
# New boot doesn't require mbr on pN (bootxx will be there)
|
|
|
|
# When necessarily mbr is installed on dN by partition.
|
2005-07-13 15:04:56 +02:00
|
|
|
# Partition the primary.
|
2012-01-30 14:21:41 +01:00
|
|
|
partition /dev/$primary $bootsectors 81:${ROOTSECTS}* 81:$homesize 81:0+ > /dev/null || exit
|
2005-08-31 18:29:56 +02:00
|
|
|
|
2005-09-09 11:14:44 +02:00
|
|
|
echo "Creating /dev/$root for / .."
|
2010-08-05 14:35:00 +02:00
|
|
|
mkfs.mfs /dev/$root || exit
|
2005-08-12 13:42:57 +02:00
|
|
|
|
2005-09-09 14:22:19 +02:00
|
|
|
if [ "$nohome" = 0 ]
|
|
|
|
then
|
|
|
|
if [ ! "$auto" = r ]
|
|
|
|
then echo "Creating /dev/$home for /home .."
|
2011-12-22 17:54:36 +01:00
|
|
|
mkfs.$FSTYPE -B $blocksizebytes /dev/$home || exit
|
2005-09-09 14:22:19 +02:00
|
|
|
fi
|
|
|
|
else echo "Skipping /home"
|
2005-08-31 18:29:56 +02:00
|
|
|
fi
|
2005-08-12 13:42:57 +02:00
|
|
|
|
2005-09-09 11:14:44 +02:00
|
|
|
echo "Creating /dev/$usr for /usr .."
|
2011-12-22 17:54:36 +01:00
|
|
|
mkfs.$FSTYPE -B $blocksizebytes /dev/$usr || exit
|
2005-08-31 18:57:13 +02:00
|
|
|
|
2005-09-09 14:22:19 +02:00
|
|
|
if [ "$nohome" = 0 ]
|
|
|
|
then
|
2012-07-03 14:57:13 +02:00
|
|
|
fshome="/dev/$home /home $FSTYPE rw 0 2"
|
2005-09-09 14:22:19 +02:00
|
|
|
else fshome=""
|
|
|
|
fi
|
2005-08-31 18:57:13 +02:00
|
|
|
|
2005-08-12 13:08:23 +02:00
|
|
|
echo ""
|
2009-09-03 11:38:27 +02:00
|
|
|
echo " --- Step 7: Wait for files to be copied -------------------------------"
|
2005-08-11 15:12:55 +02:00
|
|
|
echo ""
|
2009-09-03 11:38:27 +02:00
|
|
|
echo "All files will now be copied to your hard disk. This may take a while."
|
2005-08-12 13:42:57 +02:00
|
|
|
echo ""
|
2005-08-09 13:16:15 +02:00
|
|
|
|
2005-08-12 13:42:57 +02:00
|
|
|
mount /dev/$usr /mnt >/dev/null || exit # Mount the intended /usr.
|
2005-07-13 15:04:56 +02:00
|
|
|
|
2005-09-12 17:22:49 +02:00
|
|
|
(cd /usr || exit 1
|
2007-01-22 16:47:40 +01:00
|
|
|
list="`ls | fgrep -v install`"
|
2014-07-27 14:19:54 +02:00
|
|
|
pax -rw -pe -v $list /mnt 2>&1
|
2005-09-12 17:22:49 +02:00
|
|
|
) | progressbar "$USRFILES" || exit # Copy the usr floppy.
|
|
|
|
|
2005-08-12 13:42:57 +02:00
|
|
|
umount /dev/$usr >/dev/null || exit # Unmount the intended /usr.
|
|
|
|
mount /dev/$root /mnt >/dev/null || exit
|
2005-08-24 09:26:48 +02:00
|
|
|
|
2005-07-13 16:59:43 +02:00
|
|
|
# Running from the installation CD.
|
2014-07-27 14:19:54 +02:00
|
|
|
pax -rw -pe -vX / /mnt 2>&1 | progressbar "$ROOTFILES" || exit
|
2011-05-25 22:39:14 +02:00
|
|
|
chmod o-w /mnt/usr
|
2006-04-13 20:07:42 +02:00
|
|
|
cp /mnt/etc/motd.install /mnt/etc/motd
|
2005-08-24 09:26:48 +02:00
|
|
|
|
2013-11-05 15:43:44 +01:00
|
|
|
|
2006-04-04 15:50:05 +02:00
|
|
|
# Fix /var/log
|
|
|
|
rm /mnt/var/log
|
|
|
|
ln -s /usr/log /mnt/var/log
|
|
|
|
|
2005-07-13 15:04:56 +02:00
|
|
|
# CD remnants that aren't for the installed system
|
2006-04-13 20:12:33 +02:00
|
|
|
rm /mnt/etc/issue /mnt/CD /mnt/.* 2>/dev/null
|
Add PTYFS, Unix98 pseudo terminal support
This patch adds support for Unix98 pseudo terminals, that is,
posix_openpt(3), grantpt(3), unlockpt(3), /dev/ptmx, and /dev/pts/.
The latter is implemented with a new pseudo file system, PTYFS.
In effect, this patch adds secure support for unprivileged pseudo
terminal allocation, allowing programs such as tmux(1) to be used by
non-root users as well. Test77 has been extended with new tests, and
no longer needs to run as root.
The new functionality is optional. To revert to the old behavior,
remove the "ptyfs" entry from /etc/fstab.
Technical nodes:
o The reason for not implementing the NetBSD /dev/ptm approach is that
implementing the corresponding ioctl (TIOCPTMGET) would require
adding a number of extremely hairy exceptions to VFS, including the
PTY driver having to create new file descriptors for its own device
nodes.
o PTYFS is required for Unix98 PTYs in order to avoid that the PTY
driver has to be aware of old-style PTY naming schemes and even has
to call chmod(2) on a disk-backed file system. PTY cannot be its
own PTYFS since a character driver may currently not also be a file
system. However, PTYFS may be subsumed into a DEVFS in the future.
o The Unix98 PTY behavior differs somewhat from NetBSD's, in that
slave nodes are created on ptyfs only upon the first call to
grantpt(3). This approach obviates the need to revoke access as
part of the grantpt(3) call.
o Shutting down PTY may leave slave nodes on PTYFS, but once PTY is
restarted, these leftover slave nodes will be removed before they
create a security risk. Unmounting PTYFS will make existing PTY
slaves permanently unavailable, and absence of PTYFS will block
allocation of new Unix98 PTYs until PTYFS is (re)mounted.
Change-Id: I822b43ba32707c8815fd0f7d5bb7a438f51421c1
2015-06-22 19:14:34 +02:00
|
|
|
echo >/mnt/etc/fstab "/dev/$root / mfs rw 0 1
|
|
|
|
/dev/$usr /usr $FSTYPE rw 0 2
|
2012-07-03 14:57:13 +02:00
|
|
|
$fshome
|
Add PTYFS, Unix98 pseudo terminal support
This patch adds support for Unix98 pseudo terminals, that is,
posix_openpt(3), grantpt(3), unlockpt(3), /dev/ptmx, and /dev/pts/.
The latter is implemented with a new pseudo file system, PTYFS.
In effect, this patch adds secure support for unprivileged pseudo
terminal allocation, allowing programs such as tmux(1) to be used by
non-root users as well. Test77 has been extended with new tests, and
no longer needs to run as root.
The new functionality is optional. To revert to the old behavior,
remove the "ptyfs" entry from /etc/fstab.
Technical nodes:
o The reason for not implementing the NetBSD /dev/ptm approach is that
implementing the corresponding ioctl (TIOCPTMGET) would require
adding a number of extremely hairy exceptions to VFS, including the
PTY driver having to create new file descriptors for its own device
nodes.
o PTYFS is required for Unix98 PTYs in order to avoid that the PTY
driver has to be aware of old-style PTY naming schemes and even has
to call chmod(2) on a disk-backed file system. PTY cannot be its
own PTYFS since a character driver may currently not also be a file
system. However, PTYFS may be subsumed into a DEVFS in the future.
o The Unix98 PTY behavior differs somewhat from NetBSD's, in that
slave nodes are created on ptyfs only upon the first call to
grantpt(3). This approach obviates the need to revoke access as
part of the grantpt(3) call.
o Shutting down PTY may leave slave nodes on PTYFS, but once PTY is
restarted, these leftover slave nodes will be removed before they
create a security risk. Unmounting PTYFS will make existing PTY
slaves permanently unavailable, and absence of PTYFS will block
allocation of new Unix98 PTYs until PTYFS is (re)mounted.
Change-Id: I822b43ba32707c8815fd0f7d5bb7a438f51421c1
2015-06-22 19:14:34 +02:00
|
|
|
none /sys devman rw,rslabel=devman 0 0
|
|
|
|
none /dev/pts ptyfs rw,rslabel=ptyfs 0 0"
|
2005-07-13 15:04:56 +02:00
|
|
|
|
|
|
|
# National keyboard map.
|
|
|
|
test -n "$keymap" && cp -p "/usr/lib/keymaps/$keymap.map" /mnt/etc/keymap
|
|
|
|
|
2012-01-30 14:21:41 +01:00
|
|
|
# Make bootable.
|
2012-06-19 18:07:40 +02:00
|
|
|
mount /dev/$usr /mnt/usr >/dev/null || exit
|
|
|
|
# XXX we have to use "-f" here, because installboot worries about BPB, which
|
|
|
|
# we don't have...
|
|
|
|
installboot_nbsd -f /dev/$primary /usr/mdec/bootxx_minixfs3 >/dev/null || exit
|
2013-11-05 15:43:44 +01:00
|
|
|
# give the install the boot loader
|
|
|
|
cp /usr/mdec/boot_monitor /mnt/
|
|
|
|
minixdir=/mnt/boot/minix_default
|
|
|
|
if [ ! -f $minixdir/kernel ]
|
|
|
|
then rm -rf $minixdir
|
2014-07-29 17:07:15 +02:00
|
|
|
cp -r /mnt/boot/minix/.temp $minixdir
|
2013-11-05 15:43:44 +01:00
|
|
|
fi
|
|
|
|
if [ ! -e /mnt/boot/minix_latest ]
|
|
|
|
then ln -sf minix_default /mnt/boot/minix_latest
|
|
|
|
fi
|
2012-06-19 18:07:40 +02:00
|
|
|
chroot /mnt update_bootcfg
|
|
|
|
|
2006-02-02 19:20:09 +01:00
|
|
|
# Save name of CD drive
|
2014-09-13 16:50:30 +02:00
|
|
|
cddrive="`mount | fgrep ' /usr ' | awk '{ print $1 }' | sed 's/p.*//'`"
|
2012-06-19 18:07:40 +02:00
|
|
|
echo "cddrive=$cddrive" >>/mnt/usr/etc/rc.package
|
2005-07-13 15:04:56 +02:00
|
|
|
|
2006-03-28 15:58:12 +02:00
|
|
|
bios="`echo $primary | sed -e 's/d./dX/g' -e 's/c.//g'`"
|
2005-08-25 11:47:31 +02:00
|
|
|
|
2006-03-17 21:22:39 +01:00
|
|
|
echo "Saving random data.."
|
2012-06-19 18:07:40 +02:00
|
|
|
dd if=/dev/random of=/mnt/usr/adm/random.dat bs=1024 count=1
|
2009-09-03 11:38:27 +02:00
|
|
|
|
|
|
|
# Networking.
|
|
|
|
echo ""
|
|
|
|
echo " --- Step 8: Select your Ethernet chip ---------------------------------"
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
/bin/netconf -p /mnt || echo FAILED TO CONFIGURE NETWORK
|
|
|
|
|
|
|
|
umount /dev/$usr && echo Unmounted $usr
|
|
|
|
umount /dev/$root && echo Unmounted $root
|
|
|
|
|
2005-07-13 15:04:56 +02:00
|
|
|
echo "
|
2014-08-07 13:08:12 +02:00
|
|
|
Please type 'reboot' to exit MINIX 3 and reboot. To boot into your new
|
2012-02-07 19:55:18 +01:00
|
|
|
system, you might have to remove installation media.
|
2005-08-12 13:08:23 +02:00
|
|
|
|
2014-08-07 13:08:12 +02:00
|
|
|
This ends the MINIX 3 setup script. You may want to take care of post
|
|
|
|
installation steps, such as local testing and configuration.
|
|
|
|
|
|
|
|
Please consult the user manual for more information.
|
2005-08-11 15:12:55 +02:00
|
|
|
|
2005-08-08 16:28:32 +02:00
|
|
|
"
|
2005-07-13 15:04:56 +02:00
|
|
|
|