1433d6423SLionel Sambuc#!/bin/sh 2433d6423SLionel Sambuc# 3433d6423SLionel Sambuc# setup 4.1 - install a MINIX distribution 4433d6423SLionel Sambuc# 5433d6423SLionel Sambuc# Changes: 6433d6423SLionel Sambuc# Aug 2005 robustness checks and beautifications (Jorrit N. Herder) 7433d6423SLionel Sambuc# Jul 2005 extended with autopart and networking (Ben Gras) 8433d6423SLionel Sambuc# Dec 20, 1994 created (Kees J. Bot) 9433d6423SLionel Sambuc# 10433d6423SLionel Sambuc 11fcba33f5SBen GrasROOTMB=128 12433d6423SLionel SambucROOTSECTS="`expr $ROOTMB '*' 1024 '*' 2`" 13433d6423SLionel SambucBOOTXXSECTS=32 140a6a1f1dSLionel Sambuc#LSC: Slight over shoot, as files for / are taken into account, although 150a6a1f1dSLionel Sambuc# metadata is not, all in all should be pretty accurate. 160a6a1f1dSLionel SambucUSRKB=$(cat /i386/binary/sets/*.size | awk '{s+=$1} END{print (s/1024)}') 17433d6423SLionel SambucTOTALMB="`expr 3 + $USRKB / 1024 + $ROOTMB`" 1869eead77SJean-Baptiste BoricTOTALFILES="`find -x / | wc -l`" 19433d6423SLionel Sambuc 20433d6423SLionel Sambuc# /usr/install isn't copied onto the new system; compensate 21433d6423SLionel SambucINSTALLDIR=/usr/install 22433d6423SLionel Sambucif [ -d $INSTALLDIR ] 23433d6423SLionel Sambucthen USRFILES=$(($USRFILES - `find -x $INSTALLDIR | wc -l`)) 24433d6423SLionel Sambuc USRKB=$(($USRKB - `du -sxk $INSTALLDIR | awk '{ print $1 }'`)) 25433d6423SLionel Sambucfi 26433d6423SLionel Sambuc 27433d6423SLionel Sambucif [ -z "$FSTYPE" ] 28433d6423SLionel Sambucthen FSTYPE=mfs 29433d6423SLionel Sambucfi 30433d6423SLionel Sambuc 31433d6423SLionel SambucPATH=/bin:/sbin:/usr/bin:/usr/sbin 32433d6423SLionel Sambucexport PATH 33433d6423SLionel Sambuc 34433d6423SLionel Sambuc 35433d6423SLionel Sambucusage() 36433d6423SLionel Sambuc{ 37433d6423SLionel Sambuc cat >&2 <<'EOF' 38433d6423SLionel SambucUsage: setup # Install a skeleton system on the hard disk. 39433d6423SLionel Sambuc setup /usr # Install the rest of the system (binaries or sources). 40433d6423SLionel Sambuc 41433d6423SLionel Sambuc # To install from other things then floppies: 42433d6423SLionel Sambuc 43433d6423SLionel Sambuc fetch -q -o - http://... | setup /usr # Read from a web site. 44433d6423SLionel Sambuc fetch -q -o - ftp://... | setup /usr # Read from an FTP site. 45433d6423SLionel Sambuc mtools copy c0d0p0:... - | setup /usr # Read from the C: drive. 46433d6423SLionel Sambuc dosread c0d0p0 ... | setup /usr # Likewise if no mtools. 47433d6423SLionel SambucEOF 48433d6423SLionel Sambuc exit 1 49433d6423SLionel Sambuc} 50433d6423SLionel Sambuc 51433d6423SLionel Sambucwarn() 52433d6423SLionel Sambuc{ 53433d6423SLionel Sambuc 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" 54433d6423SLionel Sambuc} 55433d6423SLionel Sambuc 56433d6423SLionel Sambuccheck_mbr() 57433d6423SLionel Sambuc{ 58433d6423SLionel Sambuc # check for potential problems with old mbr. 59433d6423SLionel Sambuc disk=`echo -n "/dev/$primary" | sed 's/p[0-3]//'` 60433d6423SLionel Sambuc minix_primaries=`echo -n "" | fdisk "$disk" | grep "MINIX" | wc -l` 61433d6423SLionel Sambuc if [ "$minix_primaries" -gt 1 ] 62433d6423SLionel Sambuc then 63433d6423SLionel Sambuc # old mbr + bootxx will not work with several partitions of 64433d6423SLionel Sambuc # the same type. 65433d6423SLionel Sambuc dd if=/usr/mdec/mbr of=temp_mbr_netbsd bs=1 count=440 2>/dev/null 66433d6423SLionel Sambuc dd if="$disk" bs=1 count=440 2>/dev/null | cmp - temp_mbr_netbsd >/dev/null 67433d6423SLionel Sambuc if [ "$?" -ne 0 ] 68433d6423SLionel Sambuc then 69433d6423SLionel Sambuc echo "" 70433d6423SLionel Sambuc echo "Warning: you have MBR which doesn't support multiple MINIX 3 partitions!" 71433d6423SLionel Sambuc echo "You will be able to boot from the first one only!" 72433d6423SLionel Sambuc echo -n "Do you want to install new MBR into $disk? [Y] " 73433d6423SLionel Sambuc read ok 74433d6423SLionel Sambuc if [ "$ok" = Y -o "$ok" = y -o "$ok" = "" ] 75433d6423SLionel Sambuc then 76433d6423SLionel Sambuc installboot_nbsd -m "$disk" /usr/mdec/mbr >/dev/null 77433d6423SLionel Sambuc fi 78433d6423SLionel Sambuc fi 79433d6423SLionel Sambuc rm temp_mbr_netbsd 80433d6423SLionel Sambuc fi 81433d6423SLionel Sambuc 82433d6423SLionel Sambuc} 83433d6423SLionel Sambuc 84433d6423SLionel Sambuc# No options. 85433d6423SLionel Sambucwhile getopts '' opt; do usage; done 86433d6423SLionel Sambucshift `expr $OPTIND - 1` 87433d6423SLionel Sambuc 88433d6423SLionel Sambucif [ "$USER" != root ] 89433d6423SLionel Sambucthen echo "Please run setup as root." 90433d6423SLionel Sambuc exit 1 91433d6423SLionel Sambucfi 92433d6423SLionel Sambuc 93433d6423SLionel Sambuc# Find out what we are running from. 94433d6423SLionel Sambucexec 9<&0 </etc/mtab # Mounted file table. 95433d6423SLionel Sambucread thisroot rest # Current root (/dev/ram or /dev/fd?) 96433d6423SLionel Sambucread fdusr rest # USR (/dev/fd? or /dev/fd?p2) 97433d6423SLionel Sambucexec 0<&9 9<&- 98433d6423SLionel Sambuc 99433d6423SLionel Sambuc# What do we know about ROOT? 100433d6423SLionel Sambuccase $thisroot:$fdusr in 101433d6423SLionel Sambuc/dev/ram:/dev/fd0p2) fdroot=/dev/fd0 # Combined ROOT+USR in drive 0 102433d6423SLionel Sambuc ;; 103433d6423SLionel Sambuc/dev/ram:/dev/fd1p2) fdroot=/dev/fd1 # Combined ROOT+USR in drive 1 104433d6423SLionel Sambuc ;; 105433d6423SLionel Sambuc/dev/ram:/dev/fd*) fdroot=unknown # ROOT is some other floppy 106433d6423SLionel Sambuc ;; 107433d6423SLionel Sambuc/dev/fd*:/dev/fd*) fdroot=$thisroot # ROOT is mounted directly 108433d6423SLionel Sambuc ;; 109433d6423SLionel Sambuc*) fdroot=$thisroot # ? 110433d6423SLionel Sambucesac 111433d6423SLionel Sambuc 112433d6423SLionel Sambucecho -n " 113433d6423SLionel SambucWelcome to the MINIX 3 setup script. This script will guide you in setting up 114433d6423SLionel SambucMINIX on your machine. Please consult the manual for detailed instructions. 115433d6423SLionel Sambuc 116433d6423SLionel SambucNote 1: If the screen blanks, hit CTRL+F3 to select \"software scrolling\". 117433d6423SLionel SambucNote 2: If things go wrong then hit CTRL+C to abort and start over. 118433d6423SLionel SambucNote 3: Default answers, like [y], can simply be chosen by hitting ENTER. 119433d6423SLionel SambucNote 4: If you see a colon (:) then you should hit ENTER to continue. 120433d6423SLionel Sambuc:" 121433d6423SLionel Sambucread ret 122433d6423SLionel Sambuc 123433d6423SLionel Sambuc# begin Step 1 124433d6423SLionel Sambucecho "" 125433d6423SLionel Sambucecho " --- Step 1: Select keyboard type --------------------------------------" 126433d6423SLionel Sambucecho "" 127433d6423SLionel Sambuc 128433d6423SLionel Sambuc echo "What type of keyboard do you have? You can choose one of:" 129433d6423SLionel Sambuc echo "" 130433d6423SLionel Sambuc ls -C /usr/lib/keymaps | sed -e 's/\.map//g' -e 's/^/ /' 131433d6423SLionel Sambuc echo "" 132433d6423SLionel Sambucstep1="" 133433d6423SLionel Sambucwhile [ "$step1" != ok ] 134433d6423SLionel Sambucdo 135433d6423SLionel Sambuc echo -n "Keyboard type? [us-std] "; read keymap 136433d6423SLionel Sambuc test -n "$keymap" || keymap=us-std 137433d6423SLionel Sambuc if loadkeys "/usr/lib/keymaps/$keymap.map" 2>/dev/null 138433d6423SLionel Sambuc then step1=ok 139433d6423SLionel Sambuc else warn "invalid keyboard" 140433d6423SLionel Sambuc fi 141433d6423SLionel Sambucdone 142433d6423SLionel Sambuc# end Step 1 143433d6423SLionel Sambuc 144433d6423SLionel Sambuc# begin Step 2 145433d6423SLionel Sambuc#step2="" 146433d6423SLionel Sambuc#while [ "$step2" != ok ] 147433d6423SLionel Sambuc#do 148433d6423SLionel Sambuc# echo "" 149433d6423SLionel Sambuc# echo " --- Step 2: Select minimal or full distribution -----------------------" 150433d6423SLionel Sambuc# echo "" 151433d6423SLionel Sambuc# echo "You can install MINIX as (M)inimal or (F)ull. (M)inimal" 152433d6423SLionel Sambuc# echo "includes only the binary system and basic system sources." 153433d6423SLionel Sambuc# echo "(F)ull also includes commands sources." 154433d6423SLionel Sambuc# echo "" 155433d6423SLionel Sambuc# echo "Please select:" 156433d6423SLionel Sambuc# echo " (M)inimal install (only basic sources) ($NOSRCMB MB required)" 157433d6423SLionel Sambuc# echo " (F)ull install (full install) ($TOTALMB MB required)" 158433d6423SLionel Sambuc# echo " " 159433d6423SLionel Sambuc# echo -n "Basic (M)inimal or (F)ull install? [F] " 160433d6423SLionel Sambuc# read conf 161433d6423SLionel Sambuc# case "$conf" in 162433d6423SLionel Sambuc# "") step2="ok"; nobigsource="" ;; 163433d6423SLionel Sambuc# [Ff]*) step2="ok"; nobigsource="" ;; 164433d6423SLionel Sambuc# [Mm]*) step2="ok"; nobigsource="1"; TOTALMB=$NOSRCMB; USRFILES=$NOSRCUSRFILES ;; 165433d6423SLionel Sambuc# esac 166433d6423SLionel Sambuc#done 167433d6423SLionel Sambuc# end Step 2 168433d6423SLionel Sambuc 169433d6423SLionel Sambucecho "" 170433d6423SLionel Sambucecho " --- Step 2: Selecting full distribution -------------------------------" 171433d6423SLionel Sambucecho "" 172433d6423SLionel Sambucnobigsource="" 173433d6423SLionel Sambuc 174433d6423SLionel Sambuc# begin Step 3 175433d6423SLionel Sambucstep3="" 176433d6423SLionel Sambucwhile [ "$step3" != ok ] 177433d6423SLionel Sambucdo 178433d6423SLionel Sambuc echo "" 179433d6423SLionel Sambuc echo " --- Step 3: Create or select a partition for MINIX 3 -------------------" 180433d6423SLionel Sambuc echo "" 181433d6423SLionel Sambuc 182433d6423SLionel Sambuc echo "Now you need to create a MINIX 3 partition on your hard disk." 183433d6423SLionel Sambuc echo "You can also select one that's already there." 184433d6423SLionel Sambuc echo " " 185433d6423SLionel Sambuc echo "If you have an existing installation, reinstalling will let you" 186433d6423SLionel Sambuc echo "keep your current partitioning and subpartitioning, and overwrite" 187433d6423SLionel Sambuc echo "everything except your s1 subpartition (/home). If you want to" 188433d6423SLionel Sambuc echo "reinstall, select your existing minix partition." 189433d6423SLionel Sambuc echo " " 190433d6423SLionel Sambuc echo "Unless you are an expert, you are advised to use the automated" 191433d6423SLionel Sambuc echo "step-by-step help in setting up." 192433d6423SLionel Sambuc echo "" 193433d6423SLionel Sambuc ok="" 194433d6423SLionel Sambuc while [ "$ok" = "" ] 195433d6423SLionel Sambuc do 196433d6423SLionel Sambuc echo -n "Press ENTER for automatic mode, or type 'expert': " 197433d6423SLionel Sambuc read mode 198433d6423SLionel Sambuc if [ -z "$mode" ]; then auto="1"; ok="yes"; fi 199433d6423SLionel Sambuc if [ "$mode" = expert ]; then auto=""; ok="yes"; fi 200433d6423SLionel Sambuc if [ "$ok" != yes ]; then warn "try again"; fi 201433d6423SLionel Sambuc done 202433d6423SLionel Sambuc 203433d6423SLionel Sambuc primary= 204433d6423SLionel Sambuc 205433d6423SLionel Sambuc if [ -z "$auto" ] 206433d6423SLionel Sambuc then 207433d6423SLionel Sambuc # Expert mode 208433d6423SLionel Sambuc echo -n " 209433d6423SLionel SambucMINIX needs one primary partition of $TOTALMB MB for a full install, 210433d6423SLionel Sambucplus what you want for /home. 211433d6423SLionel Sambuc 212433d6423SLionel SambucIf there is no free space on your disk then you have to choose an option: 213433d6423SLionel Sambuc (1) Delete one or more partitions 214433d6423SLionel Sambuc (2) Allocate an existing partition to MINIX 3 215433d6423SLionel Sambuc (3) Exit setup and shrink a partition using a different OS 216433d6423SLionel Sambuc 217433d6423SLionel SambucTo make this partition you will be put in the editor \"part\". Follow the 218433d6423SLionel Sambucadvice under the '!' key to make a new partition of type MINIX. Do not 219433d6423SLionel Sambuctouch an existing partition unless you know precisely what you are doing! 220433d6423SLionel SambucPlease note the name of the partition (e.g. c0d0p1, c0d1p3, c1d1p0) you 221433d6423SLionel Sambucmake. (See the devices section in usage(8) on MINIX device names.) 222433d6423SLionel Sambuc:" 223433d6423SLionel Sambuc read ret 224433d6423SLionel Sambuc 225433d6423SLionel Sambuc while [ -z "$primary" ] 226433d6423SLionel Sambuc do 227433d6423SLionel Sambuc part || exit 228433d6423SLionel Sambuc 229433d6423SLionel Sambuc echo -n " 230433d6423SLionel SambucPlease finish the name of the primary partition you have created: 231433d6423SLionel Sambuc(Just type ENTER if you want to rerun \"part\") /dev/" 232433d6423SLionel Sambuc read primary 233433d6423SLionel Sambuc done 234433d6423SLionel Sambuc echo "" 235433d6423SLionel Sambuc echo "This is the point of no return. You have selected to install MINIX" 236433d6423SLionel Sambuc echo "on partition /dev/$primary. Please confirm that you want to use this" 237433d6423SLionel Sambuc echo "selection to install MINIX." 238433d6423SLionel Sambuc echo "" 239433d6423SLionel Sambuc confirmation="" 240433d6423SLionel Sambuc 241433d6423SLionel Sambuc if [ ! -b "/dev/$primary" ] 242433d6423SLionel Sambuc then echo "/dev/$primary is not a block device." 243433d6423SLionel Sambuc fi 244433d6423SLionel Sambuc 245433d6423SLionel Sambuc while [ -z "$confirmation" -o "$confirmation" != yes -a "$confirmation" != no ] 246433d6423SLionel Sambuc do 247433d6423SLionel Sambuc echo -n "Are you sure you want to continue? Please enter 'yes' or 'no': " 248433d6423SLionel Sambuc read confirmation 249433d6423SLionel Sambuc if [ "$confirmation" = yes ]; then step3=ok; fi 250433d6423SLionel Sambuc done 251433d6423SLionel Sambuc biosdrivename="Actual BIOS device name unknown, due to expert mode." 252433d6423SLionel Sambuc else 253433d6423SLionel Sambuc if [ "$auto" = "1" ] 254433d6423SLionel Sambuc then 255433d6423SLionel Sambuc # Automatic mode 256433d6423SLionel Sambuc PF="/tmp/pf" 257433d6423SLionel Sambuc if autopart -m$TOTALMB -f$PF 258433d6423SLionel Sambuc then if [ -s "$PF" ] 259433d6423SLionel Sambuc then 260433d6423SLionel Sambuc set `cat $PF` 261433d6423SLionel Sambuc bd="$1" 262433d6423SLionel Sambuc bdn="$2" 263433d6423SLionel Sambuc biosdrivename="Probably, the right command is \"boot $bdn\"." 264433d6423SLionel Sambuc if [ -b "/dev/$bd" ] 265433d6423SLionel Sambuc then primary="$bd" 266433d6423SLionel Sambuc else echo "Funny device $bd from autopart." 267433d6423SLionel Sambuc fi 268433d6423SLionel Sambuc else 269433d6423SLionel Sambuc echo "Didn't find output from autopart." 270433d6423SLionel Sambuc fi 271433d6423SLionel Sambuc else echo "Autopart tool failed. Trying again." 272433d6423SLionel Sambuc fi 273433d6423SLionel Sambuc 274433d6423SLionel Sambuc # Reset at retries and timeouts in case autopart left 275433d6423SLionel Sambuc # them messy. 276433d6423SLionel Sambuc atnormalize 277433d6423SLionel Sambuc 278433d6423SLionel Sambuc if [ -n "$primary" ]; then step3=ok; fi 279433d6423SLionel Sambuc fi 280433d6423SLionel Sambuc fi 281433d6423SLionel Sambuc 282433d6423SLionel Sambuc if [ ! -b "/dev/$primary" ] 283433d6423SLionel Sambuc then echo Doing step 3 again. 284433d6423SLionel Sambuc step3="" 285433d6423SLionel Sambuc else 286433d6423SLionel Sambuc devsize="`devsize /dev/$primary`" 287433d6423SLionel Sambuc 288433d6423SLionel Sambuc if [ "$devsize" -lt 1 ] 289433d6423SLionel Sambuc then echo "/dev/$primary is a 0-sized device." 290433d6423SLionel Sambuc step3="" 291433d6423SLionel Sambuc fi 292433d6423SLionel Sambuc fi 293433d6423SLionel Sambucdone # while step3 != ok 294433d6423SLionel Sambuc# end Step 3 295433d6423SLionel Sambuc 296433d6423SLionel Sambucroot=${primary}s0 297433d6423SLionel Sambuchome=${primary}s1 298433d6423SLionel Sambucusr=${primary}s2 299433d6423SLionel Sambucumount /dev/$home 2>/dev/null && echo "Unmounted $home for you." 300433d6423SLionel Sambucumount /dev/$usr 2>/dev/null && echo "Unmounted $usr for you." 3016e48120eSLionel Sambucumount /dev/$root 2>/dev/null && echo "Unmounted $root for you." 302433d6423SLionel Sambuc 303433d6423SLionel Sambucdevsizemb="`expr $devsize / 1024 / 2`" 304433d6423SLionel Sambucmaxhome="`expr $devsizemb - $TOTALMB - 1`" 305433d6423SLionel Sambuc 306433d6423SLionel Sambucif [ "$devsizemb" -lt "$TOTALMB" ] 307433d6423SLionel Sambucthen echo "The selected partition ($devsizemb MB) is too small." 308433d6423SLionel Sambuc echo "You'll need $TOTALMB MB at least." 309433d6423SLionel Sambuc exit 1 310433d6423SLionel Sambucfi 311433d6423SLionel Sambuc 312433d6423SLionel Sambucif [ "$maxhome" -lt 1 ] 313433d6423SLionel Sambucthen echo "Note: you can't have /home with that size partition." 314433d6423SLionel Sambuc maxhome=0 315433d6423SLionel Sambucfi 316433d6423SLionel Sambuc 317a617090dSDavid van MoolenbroekTMPMP=/mnt 318433d6423SLionel Sambucmkdir $TMPMP >/dev/null 2>&1 319433d6423SLionel Sambuc 320433d6423SLionel Sambucconfirm="" 321433d6423SLionel Sambuc 322433d6423SLionel Sambucwhile [ "$confirm" = "" ] 323433d6423SLionel Sambucdo 324433d6423SLionel Sambuc auto="" 325433d6423SLionel Sambuc echo "" 326433d6423SLionel Sambucecho " --- Step 4: Reinstall choice ------------------------------------------" 327433d6423SLionel Sambuc if mount -r /dev/$home $TMPMP >/dev/null 2>&1 328433d6423SLionel Sambuc then umount /dev/$home >/dev/null 2>&1 329433d6423SLionel Sambuc echo "" 330433d6423SLionel Sambuc echo "You have selected an existing MINIX 3 partition." 331433d6423SLionel Sambuc echo "Type F for full installation (to overwrite entire partition)" 332433d6423SLionel Sambuc echo "Type R for a reinstallation (existing /home will not be affected)" 333433d6423SLionel Sambuc echo "" 334a617090dSDavid van Moolenbroek echo -n "(F)ull or (R)einstall? [R] " 335433d6423SLionel Sambuc read conf 336433d6423SLionel Sambuc case "$conf" in 337433d6423SLionel Sambuc "") confirm="ok"; auto="r"; ;; 338433d6423SLionel Sambuc [Rr]*) confirm="ok"; auto="r"; ;; 339433d6423SLionel Sambuc [Ff]*) confirm="ok"; auto="" ;; 340433d6423SLionel Sambuc esac 341433d6423SLionel Sambuc 342433d6423SLionel Sambuc else echo "" 343433d6423SLionel Sambuc echo "No old /home found. Doing full install." 344433d6423SLionel Sambuc echo "" 345433d6423SLionel Sambuc confirm="ok"; 346433d6423SLionel Sambuc fi 347433d6423SLionel Sambuc 348433d6423SLionel Sambucdone 349433d6423SLionel Sambuc 350433d6423SLionel Sambucrmdir $TMPMP 351433d6423SLionel Sambuc 352433d6423SLionel Sambucnohome="0" 353433d6423SLionel Sambuc 354433d6423SLionel Sambuchomesize="" 355433d6423SLionel Sambucif [ ! "$auto" = r ] 356433d6423SLionel Sambucthen 357433d6423SLionel Sambucecho "" 358433d6423SLionel Sambucecho " --- Step 5: Select the size of /home ----------------------------------" 359433d6423SLionel Sambuc while [ -z "$homesize" ] 360433d6423SLionel Sambuc do 361433d6423SLionel Sambuc 362433d6423SLionel Sambuc # 20% of what is left over after / and /usr 363433d6423SLionel Sambuc # are taken. 364433d6423SLionel Sambuc defmb="`expr $maxhome / 5`" 365433d6423SLionel Sambuc if [ "$defmb" -gt "$maxhome" ] 366433d6423SLionel Sambuc then 367433d6423SLionel Sambuc defmb=$maxhome 368433d6423SLionel Sambuc fi 369433d6423SLionel Sambuc 370433d6423SLionel Sambuc echo "" 371433d6423SLionel Sambuc echo "MINIX will take up $TOTALMB MB, without /home." 372433d6423SLionel Sambuc echo -n "How big do you want your /home to be in MB (0-$maxhome) ? [$defmb] " 373433d6423SLionel Sambuc read homesize 374433d6423SLionel Sambuc if [ "$homesize" = "" ] ; then homesize=$defmb; fi 375433d6423SLionel Sambuc if [ "$homesize" -lt 1 ] 376433d6423SLionel Sambuc then nohome=1 377433d6423SLionel Sambuc echo "Ok, not making a /home." 378433d6423SLionel Sambuc homesize=0 379433d6423SLionel Sambuc else 380433d6423SLionel Sambuc if [ "$homesize" -gt "$maxhome" ] 381433d6423SLionel Sambuc then echo "That won't fit!" 382433d6423SLionel Sambuc homesize="" 383433d6423SLionel Sambuc else 384433d6423SLionel Sambuc echo "" 385433d6423SLionel Sambuc echo -n "$homesize MB Ok? [Y] " 386433d6423SLionel Sambuc read ok 387433d6423SLionel Sambuc [ "$ok" = Y -o "$ok" = y -o "$ok" = "" ] || homesize="" 388433d6423SLionel Sambuc fi 389433d6423SLionel Sambuc fi 390433d6423SLionel Sambuc echo "" 391433d6423SLionel Sambuc done 392433d6423SLionel Sambuc # Homesize in sectors 393433d6423SLionel Sambuc homemb="$homesize MB" 394433d6423SLionel Sambuc homesize="`expr $homesize '*' 1024 '*' 2`" 395433d6423SLionel Sambucelse 396433d6423SLionel Sambuc # Root size same as our default? If not, warn and keep old root size 397433d6423SLionel Sambuc ROOTSECTSDEFAULT=$ROOTSECTS 398433d6423SLionel Sambuc ROOTSECTS="`devsize /dev/$root`" 399433d6423SLionel Sambuc ROOTMB="`expr $ROOTSECTS / 2048`" 400433d6423SLionel Sambuc if [ $ROOTSECTS -ne $ROOTSECTSDEFAULT ] 401433d6423SLionel Sambuc then 402433d6423SLionel Sambuc # Check if we 403433d6423SLionel Sambuc echo "Root partition size `expr $ROOTSECTS / 2`kb differs from default `expr $ROOTSECTSDEFAULT / 2`kb." 404433d6423SLionel Sambuc echo "This is not a problem, but you may want to do a fresh install at some point to" 405433d6423SLionel Sambuc echo "be able to benefit from the new default." 406433d6423SLionel Sambuc fi 407433d6423SLionel Sambuc 408433d6423SLionel Sambuc # Check if enough space for new boot (even if old used) 4093f072cf3SLionel Sambuc bootspace=$((`devsize /dev/$primary`-`devsize /dev/$root`-`devsize /dev/$home`-`devsize /dev/$usr`)) >/dev/null 410433d6423SLionel Sambuc if [ $bootspace -lt $BOOTXXSECTS ] 411433d6423SLionel Sambuc then 412433d6423SLionel Sambuc echo "Root partition size will be reduced by up to 16Kb to fit new bootloader." 413433d6423SLionel Sambuc echo "This is not a problem." 414433d6423SLionel Sambuc ROOTSECTS=`expr $ROOTSECTS - $BOOTXXSECTS + $bootspace` 415433d6423SLionel Sambuc fi 416433d6423SLionel Sambuc 417433d6423SLionel Sambuc # Recompute totals based on root size 418433d6423SLionel Sambuc TOTALMB="`expr 3 + $USRKB / 1024 + $ROOTMB`" 419433d6423SLionel Sambuc maxhome="`expr $devsizemb - $TOTALMB - 1`" 420433d6423SLionel Sambuc 421433d6423SLionel Sambuc homepart="`devsize /dev/$home`" 422433d6423SLionel Sambuc homesize="`expr $homepart / 2 / 1024`" 423433d6423SLionel Sambuc if [ "$homesize" -gt "$maxhome" ] 424433d6423SLionel Sambuc then 425433d6423SLionel Sambuc echo "Sorry, but your /home is too big ($homesize MB) to leave enough" 426433d6423SLionel Sambuc echo "space on the rest of the partition ($devsizemb MB) for your" 427433d6423SLionel Sambuc echo "selected installation size ($TOTALMB MB)." 428433d6423SLionel Sambuc exit 1 429433d6423SLionel Sambuc fi 430433d6423SLionel Sambuc # Homesize unchanged (reinstall) 431433d6423SLionel Sambuc homesize=exist 432433d6423SLionel Sambuc homemb="current size" 433433d6423SLionel Sambucfi 434433d6423SLionel Sambuc 435433d6423SLionel Sambucminblocksize=1 436433d6423SLionel Sambucmaxblocksize=64 437433d6423SLionel Sambucblockdefault=4 438433d6423SLionel Sambuc 439433d6423SLionel Sambucif [ ! "$auto" = "r" ] 440433d6423SLionel Sambucthen 441433d6423SLionel Sambuc echo "" 442433d6423SLionel Sambucecho " --- Step 6: Select a block size ---------------------------------------" 443433d6423SLionel Sambuc echo "" 444433d6423SLionel Sambuc 445433d6423SLionel Sambuc echo "The default file system block size is $blockdefault kB." 446433d6423SLionel Sambuc echo "" 447433d6423SLionel Sambuc 448433d6423SLionel Sambuc while [ -z "$blocksize" ] 449433d6423SLionel Sambuc do 450433d6423SLionel Sambuc echo -n "Block size in kilobytes? [$blockdefault] "; read blocksize 451433d6423SLionel Sambuc test -z "$blocksize" && blocksize=$blockdefault 452433d6423SLionel Sambuc if [ "$blocksize" -lt $minblocksize -o "$blocksize" -gt $maxblocksize ] 453433d6423SLionel Sambuc then 454433d6423SLionel Sambuc warn "At least $minblocksize kB and at most $maxblocksize kB please." 455433d6423SLionel Sambuc blocksize="" 456433d6423SLionel Sambuc fi 457433d6423SLionel Sambuc done 458433d6423SLionel Sambucelse 459433d6423SLionel Sambuc blocksize=$blockdefault 460433d6423SLionel Sambucfi 461433d6423SLionel Sambuc 462433d6423SLionel Sambucblocksizebytes="`expr $blocksize '*' 1024`" 463433d6423SLionel Sambuc 464433d6423SLionel Sambucbootsectors=$BOOTXXSECTS 465433d6423SLionel Sambuc 466433d6423SLionel Sambuccheck_mbr 467433d6423SLionel Sambuc 468433d6423SLionel Sambucecho " 469433d6423SLionel SambucYou have selected to (re)install MINIX 3 in the partition /dev/$primary. 470433d6423SLionel SambucThe following subpartitions are now being created on /dev/$primary: 471433d6423SLionel Sambuc 472433d6423SLionel Sambuc Root subpartition: /dev/$root $ROOTMB MB 473433d6423SLionel Sambuc /home subpartition: /dev/$home $homemb 474433d6423SLionel Sambuc /usr subpartition: /dev/$usr rest of $primary 475433d6423SLionel Sambuc" 476433d6423SLionel Sambuc # Secondary master bootstrap. 477433d6423SLionel Sambuc# New boot doesn't require mbr on pN (bootxx will be there) 478433d6423SLionel Sambuc# When necessarily mbr is installed on dN by partition. 479433d6423SLionel Sambuc # Partition the primary. 480433d6423SLionel Sambucpartition /dev/$primary $bootsectors 81:${ROOTSECTS}* 81:$homesize 81:0+ > /dev/null || exit 481433d6423SLionel Sambuc 482433d6423SLionel Sambucecho "Creating /dev/$root for / .." 483433d6423SLionel Sambucmkfs.mfs /dev/$root || exit 484433d6423SLionel Sambuc 485433d6423SLionel Sambucif [ "$nohome" = 0 ] 486433d6423SLionel Sambucthen 487433d6423SLionel Sambuc if [ ! "$auto" = r ] 488433d6423SLionel Sambuc then echo "Creating /dev/$home for /home .." 489433d6423SLionel Sambuc mkfs.$FSTYPE -B $blocksizebytes /dev/$home || exit 490433d6423SLionel Sambuc fi 491433d6423SLionel Sambucelse echo "Skipping /home" 492433d6423SLionel Sambucfi 493433d6423SLionel Sambuc 494433d6423SLionel Sambucecho "Creating /dev/$usr for /usr .." 495433d6423SLionel Sambucmkfs.$FSTYPE -B $blocksizebytes /dev/$usr || exit 496433d6423SLionel Sambuc 497433d6423SLionel Sambucif [ "$nohome" = 0 ] 498433d6423SLionel Sambucthen 499433d6423SLionel Sambuc fshome="/dev/$home /home $FSTYPE rw 0 2" 500433d6423SLionel Sambucelse fshome="" 501433d6423SLionel Sambucfi 502433d6423SLionel Sambuc 503433d6423SLionel Sambucecho "" 504433d6423SLionel Sambucecho " --- Step 7: Wait for files to be copied -------------------------------" 505433d6423SLionel Sambucecho "" 506433d6423SLionel Sambucecho "All files will now be copied to your hard disk. This may take a while." 507433d6423SLionel Sambucecho "" 508433d6423SLionel Sambuc 509433d6423SLionel Sambucmount /dev/$root /mnt >/dev/null || exit 51069eead77SJean-Baptiste Boricmkdir -p /mnt/usr 51169eead77SJean-Baptiste Boricmount /dev/$usr /mnt/usr >/dev/null || exit # Mount the intended /usr. 51269eead77SJean-Baptiste Boricif [ "$nohome" = 0 ]; then 51369eead77SJean-Baptiste Boric mkdir -p /mnt/home 51469eead77SJean-Baptiste Boric mount /dev/$home /mnt/home >/dev/null || exit # Mount the intended /home 51569eead77SJean-Baptiste Boricfi 516433d6423SLionel Sambuc 517433d6423SLionel Sambuc# Running from the installation CD. 51869eead77SJean-Baptiste Boricfor set in /i386/binary/sets/*.tgz; do 51969eead77SJean-Baptiste Boric echo "Extracting $(basename "$set")..." 52069eead77SJean-Baptiste Boric COUNT_FILES=$(cat $(echo "$set" | sed -e "s/\.tgz/\.count/")) 52169eead77SJean-Baptiste Boric (cd /mnt; pax -rz -f $set -v -pe 2>&1 | progressbar "$COUNT_FILES" || exit) 52269eead77SJean-Baptiste Boricdone; 52369eead77SJean-Baptiste Boric 52469eead77SJean-Baptiste Boricecho "Creating device nodes..." 52569eead77SJean-Baptiste Boric(cd /mnt/dev; MAKEDEV -s all) 52669eead77SJean-Baptiste Boric 52769eead77SJean-Baptiste Boric# Fix permissions 52869eead77SJean-Baptiste Boricchmod $(stat -f %Lp /usr) /mnt/usr 52969eead77SJean-Baptiste Boricchown $(stat -f %u /usr) /mnt/usr 53069eead77SJean-Baptiste Boricchgrp $(stat -f %g /usr) /mnt/usr 53169eead77SJean-Baptiste Boricif [ "$nohome" = 0 ]; then 53269eead77SJean-Baptiste Boric chmod $(stat -f %Lp /home) /mnt/home 53369eead77SJean-Baptiste Boric chown $(stat -f %u /home) /mnt/home 53469eead77SJean-Baptiste Boric chgrp $(stat -f %g /home) /mnt/home 53569eead77SJean-Baptiste Boricfi 53669eead77SJean-Baptiste Boric 537433d6423SLionel Sambuc# CD remnants that aren't for the installed system 538433d6423SLionel Sambucrm /mnt/etc/issue /mnt/CD /mnt/.* 2>/dev/null 539433d6423SLionel Sambucecho >/mnt/etc/fstab "/dev/$root / mfs rw 0 1 540433d6423SLionel Sambuc/dev/$usr /usr $FSTYPE rw 0 2 541433d6423SLionel Sambuc$fshome 542da21d850SDavid van Moolenbroeknone /sys devman rw,rslabel=devman 0 0 543da21d850SDavid van Moolenbroeknone /dev/pts ptyfs rw,rslabel=ptyfs 0 0" 544433d6423SLionel Sambuc 545433d6423SLionel Sambuc # National keyboard map. 546433d6423SLionel Sambuctest -n "$keymap" && cp -p "/usr/lib/keymaps/$keymap.map" /mnt/etc/keymap 547433d6423SLionel Sambuc 548433d6423SLionel Sambuc# XXX we have to use "-f" here, because installboot worries about BPB, which 549433d6423SLionel Sambuc# we don't have... 550433d6423SLionel Sambucinstallboot_nbsd -f /dev/$primary /usr/mdec/bootxx_minixfs3 >/dev/null || exit 551433d6423SLionel Sambuc# give the install the boot loader 552433d6423SLionel Sambuccp /usr/mdec/boot_monitor /mnt/ 553433d6423SLionel Sambucminixdir=/mnt/boot/minix_default 554433d6423SLionel Sambucif [ ! -f $minixdir/kernel ] 555433d6423SLionel Sambucthen rm -rf $minixdir 55684bb300fSLionel Sambuc cp -r /mnt/boot/minix/.temp $minixdir 557433d6423SLionel Sambucfi 558433d6423SLionel Sambucif [ ! -e /mnt/boot/minix_latest ] 559433d6423SLionel Sambucthen ln -sf minix_default /mnt/boot/minix_latest 560433d6423SLionel Sambucfi 561433d6423SLionel Sambucchroot /mnt update_bootcfg 562433d6423SLionel Sambuc 563433d6423SLionel Sambucbios="`echo $primary | sed -e 's/d./dX/g' -e 's/c.//g'`" 564433d6423SLionel Sambuc 565433d6423SLionel Sambucecho "Saving random data.." 566433d6423SLionel Sambucdd if=/dev/random of=/mnt/usr/adm/random.dat bs=1024 count=1 567433d6423SLionel Sambuc 568433d6423SLionel Sambuc# Networking. 569433d6423SLionel Sambucecho "" 570433d6423SLionel Sambucecho " --- Step 8: Select your Ethernet chip ---------------------------------" 571433d6423SLionel Sambucecho "" 572433d6423SLionel Sambuc 573433d6423SLionel Sambuc/bin/netconf -p /mnt || echo FAILED TO CONFIGURE NETWORK 574433d6423SLionel Sambuc 575*c1d4abebSJean-Baptiste BoricPACKAGES_DIR="/packages/$(uname -v | cut -f2 -d' ')/$(uname -p)/All" 57669eead77SJean-Baptiste Boricif [ -e "$PACKAGES_DIR" ] 57769eead77SJean-Baptiste Boricthen 57869eead77SJean-Baptiste Boric echo "Installing pkgin..." 57939508cddSLionel Sambuc sh -c "cp $PACKAGES_DIR/pkgin-* $PACKAGES_DIR/pkg_install-* $PACKAGES_DIR/libarchive-* /mnt/tmp && 58039508cddSLionel Sambuc chroot /mnt pkg_add /tmp/pkgin-*" 58169eead77SJean-Baptiste Boric rm -f /mnt/tmp/* 58269eead77SJean-Baptiste Boric 583*c1d4abebSJean-Baptiste Boric # Save name of CD drive 584*c1d4abebSJean-Baptiste Boric cddrive=$(mount | grep ' on / ' | cut -f1 -d' ') 585*c1d4abebSJean-Baptiste Boric echo "cddrive=$cddrive" >>/mnt/usr/etc/rc.package 586*c1d4abebSJean-Baptiste Boricelse 587*c1d4abebSJean-Baptiste Boric echo "Package dir not found, skipping pkgin installation..." 58869eead77SJean-Baptiste Boricfi 58969eead77SJean-Baptiste Boric 59069eead77SJean-Baptiste Boricif [ "$nohome" = 0 ]; then 59169eead77SJean-Baptiste Boric umount /dev/$home && echo Unmounted $home 59269eead77SJean-Baptiste Boricfi 59339508cddSLionel Sambucumount /dev/$usr && echo Unmounted $usr 59439508cddSLionel Sambucumount /dev/$root && echo Unmounted $root 595433d6423SLionel Sambuc 596433d6423SLionel Sambucecho " 59769eead77SJean-Baptiste BoricPlease type 'shutdown -r now' to exit MINIX 3 and reboot. To boot into 59869eead77SJean-Baptiste Boricyour new system, you might have to remove the installation media. 599433d6423SLionel Sambuc 6007785012bSLionel SambucThis ends the MINIX 3 setup script. You may want to take care of post 6017785012bSLionel Sambucinstallation steps, such as local testing and configuration. 6027785012bSLionel Sambuc 6037785012bSLionel SambucPlease consult the user manual for more information. 604433d6423SLionel Sambuc 605433d6423SLionel Sambuc" 606433d6423SLionel Sambuc 607