1#!/bin/sh 2# 3# setup 4.1 - install a MINIX distribution 4# 5# Changes: 6# Aug 2005 robustness checks and beautifications (Jorrit N. Herder) 7# Jul 2005 extended with autopart and networking (Ben Gras) 8# Dec 20, 1994 created (Kees J. Bot) 9# 10 11LOCALRC=/usr/etc/rc.local 12MYLOCALRC=/mnt/etc/rc.local 13ROOTMB=128 14ROOTSECTS="`expr $ROOTMB '*' 1024 '*' 2`" 15BOOTXXSECTS=32 16#LSC: Slight over shoot, as files for / are taken into account, although 17# metadata is not, all in all should be pretty accurate. 18USRKB=$(cat /i386/binary/sets/*.size | awk '{s+=$1} END{print (s/1024)}') 19TOTALMB="`expr 3 + $USRKB / 1024 + $ROOTMB`" 20TOTALFILES="`find -x / | wc -l`" 21 22# /usr/install isn't copied onto the new system; compensate 23INSTALLDIR=/usr/install 24if [ -d $INSTALLDIR ] 25then USRFILES=$(($USRFILES - `find -x $INSTALLDIR | wc -l`)) 26 USRKB=$(($USRKB - `du -sxk $INSTALLDIR | awk '{ print $1 }'`)) 27fi 28 29if [ -z "$FSTYPE" ] 30then FSTYPE=mfs 31fi 32 33PATH=/bin:/sbin:/usr/bin:/usr/sbin 34export PATH 35 36 37usage() 38{ 39 cat >&2 <<'EOF' 40Usage: setup # Install a skeleton system on the hard disk. 41 setup /usr # Install the rest of the system (binaries or sources). 42 43 # To install from other things then floppies: 44 45 fetch -q -o - http://... | setup /usr # Read from a web site. 46 fetch -q -o - ftp://... | setup /usr # Read from an FTP site. 47 mtools copy c0d0p0:... - | setup /usr # Read from the C: drive. 48 dosread c0d0p0 ... | setup /usr # Likewise if no mtools. 49EOF 50 exit 1 51} 52 53warn() 54{ 55 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" 56} 57 58check_mbr() 59{ 60 # check for potential problems with old mbr. 61 disk=`echo -n "/dev/$primary" | sed 's/p[0-3]//'` 62 minix_primaries=`echo -n "" | fdisk "$disk" | grep "MINIX" | wc -l` 63 if [ "$minix_primaries" -gt 1 ] 64 then 65 # old mbr + bootxx will not work with several partitions of 66 # the same type. 67 dd if=/usr/mdec/mbr of=temp_mbr_netbsd bs=1 count=440 2>/dev/null 68 dd if="$disk" bs=1 count=440 2>/dev/null | cmp - temp_mbr_netbsd >/dev/null 69 if [ "$?" -ne 0 ] 70 then 71 echo "" 72 echo "Warning: you have MBR which doesn't support multiple MINIX 3 partitions!" 73 echo "You will be able to boot from the first one only!" 74 echo -n "Do you want to install new MBR into $disk? [Y] " 75 read ok 76 if [ "$ok" = Y -o "$ok" = y -o "$ok" = "" ] 77 then 78 installboot_nbsd -m "$disk" /usr/mdec/mbr >/dev/null 79 fi 80 fi 81 rm temp_mbr_netbsd 82 fi 83 84} 85 86# No options. 87while getopts '' opt; do usage; done 88shift `expr $OPTIND - 1` 89 90if [ "$USER" != root ] 91then echo "Please run setup as root." 92 exit 1 93fi 94 95# Find out what we are running from. 96exec 9<&0 </etc/mtab # Mounted file table. 97read thisroot rest # Current root (/dev/ram or /dev/fd?) 98read fdusr rest # USR (/dev/fd? or /dev/fd?p2) 99exec 0<&9 9<&- 100 101# What do we know about ROOT? 102case $thisroot:$fdusr in 103/dev/ram:/dev/fd0p2) fdroot=/dev/fd0 # Combined ROOT+USR in drive 0 104 ;; 105/dev/ram:/dev/fd1p2) fdroot=/dev/fd1 # Combined ROOT+USR in drive 1 106 ;; 107/dev/ram:/dev/fd*) fdroot=unknown # ROOT is some other floppy 108 ;; 109/dev/fd*:/dev/fd*) fdroot=$thisroot # ROOT is mounted directly 110 ;; 111*) fdroot=$thisroot # ? 112esac 113 114echo -n " 115Welcome to the MINIX 3 setup script. This script will guide you in setting up 116MINIX on your machine. Please consult the manual for detailed instructions. 117 118Note 1: If the screen blanks, hit CTRL+F3 to select \"software scrolling\". 119Note 2: If things go wrong then hit CTRL+C to abort and start over. 120Note 3: Default answers, like [y], can simply be chosen by hitting ENTER. 121Note 4: If you see a colon (:) then you should hit ENTER to continue. 122:" 123read ret 124 125# begin Step 1 126echo "" 127echo " --- Step 1: Select keyboard type --------------------------------------" 128echo "" 129 130 echo "What type of keyboard do you have? You can choose one of:" 131 echo "" 132 ls -C /usr/lib/keymaps | sed -e 's/\.map//g' -e 's/^/ /' 133 echo "" 134step1="" 135while [ "$step1" != ok ] 136do 137 echo -n "Keyboard type? [us-std] "; read keymap 138 test -n "$keymap" || keymap=us-std 139 if loadkeys "/usr/lib/keymaps/$keymap.map" 2>/dev/null 140 then step1=ok 141 else warn "invalid keyboard" 142 fi 143done 144# end Step 1 145 146# begin Step 2 147#step2="" 148#while [ "$step2" != ok ] 149#do 150# echo "" 151# echo " --- Step 2: Select minimal or full distribution -----------------------" 152# echo "" 153# echo "You can install MINIX as (M)inimal or (F)ull. (M)inimal" 154# echo "includes only the binary system and basic system sources." 155# echo "(F)ull also includes commands sources." 156# echo "" 157# echo "Please select:" 158# echo " (M)inimal install (only basic sources) ($NOSRCMB MB required)" 159# echo " (F)ull install (full install) ($TOTALMB MB required)" 160# echo " " 161# echo -n "Basic (M)inimal or (F)ull install? [F] " 162# read conf 163# case "$conf" in 164# "") step2="ok"; nobigsource="" ;; 165# [Ff]*) step2="ok"; nobigsource="" ;; 166# [Mm]*) step2="ok"; nobigsource="1"; TOTALMB=$NOSRCMB; USRFILES=$NOSRCUSRFILES ;; 167# esac 168#done 169# end Step 2 170 171echo "" 172echo " --- Step 2: Selecting full distribution -------------------------------" 173echo "" 174nobigsource="" 175 176# begin Step 3 177step3="" 178while [ "$step3" != ok ] 179do 180 echo "" 181 echo " --- Step 3: Create or select a partition for MINIX 3 -------------------" 182 echo "" 183 184 echo "Now you need to create a MINIX 3 partition on your hard disk." 185 echo "You can also select one that's already there." 186 echo " " 187 echo "If you have an existing installation, reinstalling will let you" 188 echo "keep your current partitioning and subpartitioning, and overwrite" 189 echo "everything except your s1 subpartition (/home). If you want to" 190 echo "reinstall, select your existing minix partition." 191 echo " " 192 echo "Unless you are an expert, you are advised to use the automated" 193 echo "step-by-step help in setting up." 194 echo "" 195 ok="" 196 while [ "$ok" = "" ] 197 do 198 echo -n "Press ENTER for automatic mode, or type 'expert': " 199 read mode 200 if [ -z "$mode" ]; then auto="1"; ok="yes"; fi 201 if [ "$mode" = expert ]; then auto=""; ok="yes"; fi 202 if [ "$ok" != yes ]; then warn "try again"; fi 203 done 204 205 primary= 206 207 if [ -z "$auto" ] 208 then 209 # Expert mode 210 echo -n " 211MINIX needs one primary partition of $TOTALMB MB for a full install, 212plus what you want for /home. 213 214If there is no free space on your disk then you have to choose an option: 215 (1) Delete one or more partitions 216 (2) Allocate an existing partition to MINIX 3 217 (3) Exit setup and shrink a partition using a different OS 218 219To make this partition you will be put in the editor \"part\". Follow the 220advice under the '!' key to make a new partition of type MINIX. Do not 221touch an existing partition unless you know precisely what you are doing! 222Please note the name of the partition (e.g. c0d0p1, c0d1p3, c1d1p0) you 223make. (See the devices section in usage(8) on MINIX device names.) 224:" 225 read ret 226 227 while [ -z "$primary" ] 228 do 229 part || exit 230 231 echo -n " 232Please finish the name of the primary partition you have created: 233(Just type ENTER if you want to rerun \"part\") /dev/" 234 read primary 235 done 236 echo "" 237 echo "This is the point of no return. You have selected to install MINIX" 238 echo "on partition /dev/$primary. Please confirm that you want to use this" 239 echo "selection to install MINIX." 240 echo "" 241 confirmation="" 242 243 if [ ! -b "/dev/$primary" ] 244 then echo "/dev/$primary is not a block device." 245 fi 246 247 while [ -z "$confirmation" -o "$confirmation" != yes -a "$confirmation" != no ] 248 do 249 echo -n "Are you sure you want to continue? Please enter 'yes' or 'no': " 250 read confirmation 251 if [ "$confirmation" = yes ]; then step3=ok; fi 252 done 253 biosdrivename="Actual BIOS device name unknown, due to expert mode." 254 else 255 if [ "$auto" = "1" ] 256 then 257 # Automatic mode 258 PF="/tmp/pf" 259 if autopart -m$TOTALMB -f$PF 260 then if [ -s "$PF" ] 261 then 262 set `cat $PF` 263 bd="$1" 264 bdn="$2" 265 biosdrivename="Probably, the right command is \"boot $bdn\"." 266 if [ -b "/dev/$bd" ] 267 then primary="$bd" 268 else echo "Funny device $bd from autopart." 269 fi 270 else 271 echo "Didn't find output from autopart." 272 fi 273 else echo "Autopart tool failed. Trying again." 274 fi 275 276 # Reset at retries and timeouts in case autopart left 277 # them messy. 278 atnormalize 279 280 if [ -n "$primary" ]; then step3=ok; fi 281 fi 282 fi 283 284 if [ ! -b "/dev/$primary" ] 285 then echo Doing step 3 again. 286 step3="" 287 else 288 devsize="`devsize /dev/$primary`" 289 290 if [ "$devsize" -lt 1 ] 291 then echo "/dev/$primary is a 0-sized device." 292 step3="" 293 fi 294 fi 295done # while step3 != ok 296# end Step 3 297 298root=${primary}s0 299home=${primary}s1 300usr=${primary}s2 301umount /dev/$root 2>/dev/null && echo "Unmounted $root for you." 302umount /dev/$home 2>/dev/null && echo "Unmounted $home for you." 303umount /dev/$usr 2>/dev/null && echo "Unmounted $usr for you." 304 305devsizemb="`expr $devsize / 1024 / 2`" 306maxhome="`expr $devsizemb - $TOTALMB - 1`" 307 308if [ "$devsizemb" -lt "$TOTALMB" ] 309then echo "The selected partition ($devsizemb MB) is too small." 310 echo "You'll need $TOTALMB MB at least." 311 exit 1 312fi 313 314if [ "$maxhome" -lt 1 ] 315then echo "Note: you can't have /home with that size partition." 316 maxhome=0 317fi 318 319TMPMP=/m 320mkdir $TMPMP >/dev/null 2>&1 321 322confirm="" 323 324while [ "$confirm" = "" ] 325do 326 auto="" 327 echo "" 328echo " --- Step 4: Reinstall choice ------------------------------------------" 329 if mount -r /dev/$home $TMPMP >/dev/null 2>&1 330 then umount /dev/$home >/dev/null 2>&1 331 echo "" 332 echo "You have selected an existing MINIX 3 partition." 333 echo "Type F for full installation (to overwrite entire partition)" 334 echo "Type R for a reinstallation (existing /home will not be affected)" 335 echo "Type B to reinstall/upgrade bootloader (no data affected)" 336 echo "" 337 echo -n "(F)ull, (R)einstall or (B)ootloader install? [R] " 338 read conf 339 case "$conf" in 340 "") confirm="ok"; auto="r"; ;; 341 [Rr]*) confirm="ok"; auto="r"; ;; 342 [Ff]*) confirm="ok"; auto="" ;; 343 [Bb]*) confirm="ok"; bootreinstall="ok" ;; 344 esac 345 346 else echo "" 347 echo "No old /home found. Doing full install." 348 echo "" 349 confirm="ok"; 350 fi 351 352done 353 354if [ "$bootreinstall" = "ok" ] 355then 356 echo "" 357 echo " --- Step 5: Reinstall bootloader ----------------------------------" 358 echo "" 359 360 echo "WARNING: This procedure uses your current /usr to store your /." 361 echo "Once the procedure starts, it has to finish" 362 echo "to restore your / partition. Please make sure it is not interrupted." 363 echo "" 364 365 echo -n "It's recommended to run fsck before you continue, run? [Y/n] " 366 read ok 367 if [ "$ok" = "y" -o "$ok" = "Y" -o "$ok" = "" ] 368 then 369 fsck -t mfs -T mfs:-a "/dev/$root" >/dev/null 370 fsck -t mfs -T mfs:-a "/dev/$usr" >/dev/null 371 fi 372 373 # If there is no ELF stuff and not enough space after repartitioning, 374 # user will fall into trouble. So at first copy new stuff. 375 mount "/dev/$root" /mnt >/dev/null || exit 376 377 # grep, stat, etc in chroot 378 mount "/dev/$usr" /mnt/usr >/dev/null || exit 379 380 cp -pf /bin/update_bootcfg /mnt/bin/ && \ 381 cp -pf /etc/boot.cfg.default /mnt/etc/ && \ 382 cp -pf /usr/mdec/boot_monitor /mnt/ || exit 383 384 if [ ! -d /mnt/boot/minix_default -o ! -r /mnt/boot/minix_default/kernel ] 385 then 386 if [ -r /mnt/boot.cfg ] 387 then 388 echo "" 389 echo "There is no /boot/minix_default/, but /boot.cfg exists." 390 echo -n "Do you want to copy minix_default from CD? [Y/n] " 391 else 392 echo "" 393 echo -n "There is no /boot/minix_default/, do you want to copy it from CD? [Y/n] " 394 fi 395 read ok 396 if [ "$ok" = "y" -o "$ok" = "Y" -o "$ok" = "" ] 397 then 398 if [ -e /mnt/boot/minix_default ] 399 then 400 echo "Old /boot/minix_default moved to /boot/minix_default_old" 401 mv /mnt/boot/minix_default /mnt/boot/minix_default_old 402 fi 403 404 cp -rfp /boot/minix_default /mnt/boot/ || exit 405 fi 406 fi 407 408 echo " * Updating /boot.cfg" 409 410 chroot /mnt update_bootcfg 411 412 sync 413 414 # Get sizes and space availability while the file systems are still 415 # mounted. Otherwise we have to mount them again just for this. 416 required_root_space=`df -kP /dev/$root | awk '{print $3}' | tail -n 1` 417 free_root_space=`df -kP /dev/$root | awk '{print $4}' | tail -n 1` 418 free_usr_space=`df -kP /dev/$usr | awk '{print $4}' | tail -n 1` 419 420 umount /mnt/usr && umount /mnt || exit 421 422 # Check if enough space for new boot 423 bootspace=$((`devsize /dev/$primary`-`devsize /dev/$root`-`devsize /dev/$home`-`devsize /dev/$usr`)) >/dev/null 424 if [ $bootspace -lt $BOOTXXSECTS ] 425 then 426 echo "" 427 echo "Root partition size will be reduced by up to 16Kb to fit new bootloader." 428 echo "This is not a problem." 429 430 # round 16 => 20 431 if [ "$free_root_space" -le 20 ] 432 then 433 echo "" 434 echo "Not enough space on /dev/$root, you need at least 20Kb to use new bootloader!" 435 exit 1 436 fi 437 438 ROOTSECTS=`expr \`devsize /dev/$root\` - $BOOTXXSECTS + $bootspace` 439 440 if [ "$required_root_space" -gt "$free_usr_space" ] 441 then 442 echo "" 443 echo "You don't have enough free space on /dev/$usr to backup /dev/$root!" 444 echo "${free_usr_space}Kb available, ${required_root_space} required." 445 exit 1 446 fi 447 448 mkdir /mnt/root && mkdir /mnt/usr || exit 449 450 echo "Re-mounting your current / and /usr" 451 452 mount "/dev/$root" /mnt/root || exit 453 mount "/dev/$usr" /mnt/usr || exit 454 455 mkdir /mnt/usr/tmp/root_backup || exit 456 457 echo " * Copying / contents" 458 459 cp -rfp /mnt/root/* /mnt/usr/tmp/root_backup 460 if [ $? -ne 0 ] 461 then 462 echo "" 463 echo "Failed to backup root partition, aborting!" 464 rm -rf /mnt/usr/tmp/root_backup 465 # umount shouldn't fail here, but if it will, next 466 # "rm -rf" will serve for user's pleasure. 467 umount /mnt/root >/dev/null || exit 468 umount /mnt/usr >/dev/null || exit 469 rm -rf /mnt/root /mnt/usr 470 exit 1 471 fi 472 473 echo " * Copying done" 474 475 umount /mnt/root 476 umount /mnt/usr 477 478 add_subpart="" 479 minix_subparts=`echo -n "" | fdisk /dev/$primary | grep "MINIX" | wc -l` 480 if [ "$minix_subparts" -gt 3 ] 481 then 482 echo "" 483 echo "You have additional subpartition except /, /usr and /home." 484 echo "Partition type will be set to MINIX (81), you can change it later using part." 485 echo -n "Do you want to continue? [Y/n] " 486 read ok 487 [ "$ok" = "n" -o "$ok" = "N" ] && exit 488 add_subpart="81:exist" 489 fi 490 491 echo " * Repartitioning" 492 493 partition /dev/$primary $BOOTXXSECTS 81:${ROOTSECTS}* 81:exist 81:exist $add_subpart || exit 494 495 echo " * mkfs on new /" 496 497 mkfs.mfs "/dev/$root" || exit 498 499 if [ $? -ne 0 ] 500 then 501 echo "Failed to repartition /dev/$primary" 502 rmdir /mnt/root 503 rmdir /mnt/usr 504 exit 1 505 fi 506 507 mount "/dev/$usr" /mnt/usr || exit 508 mount "/dev/$root" /mnt/root || exit 509 510 echo " * Filling new / filesystem" 511 512 mv /mnt/usr/tmp/root_backup/* /mnt/root/ || exit 513 if [ $? -ne 0 ] 514 then 515 echo "Failed to copy old root data! It is in /tmp/root_backup/" 516 fi 517 518 rmdir /mnt/usr/tmp/root_backup/ 519 520 umount /mnt/root 521 umount /mnt/usr 522 fi 523 524 check_mbr 525 installboot_nbsd -f /dev/$primary /usr/mdec/bootxx_minixfs3 >/dev/null || exit 1 526 527 if [ $? -ne 0 ] 528 then 529 echo "Warning: failed to remove /tmp/root_backup!" 530 fi 531 532 echo "New boot installed successfully! You can reboot now." 533 exit 534fi 535 536rmdir $TMPMP 537 538nohome="0" 539 540homesize="" 541if [ ! "$auto" = r ] 542then 543echo "" 544echo " --- Step 5: Select the size of /home ----------------------------------" 545 while [ -z "$homesize" ] 546 do 547 548 # 20% of what is left over after / and /usr 549 # are taken. 550 defmb="`expr $maxhome / 5`" 551 if [ "$defmb" -gt "$maxhome" ] 552 then 553 defmb=$maxhome 554 fi 555 556 echo "" 557 echo "MINIX will take up $TOTALMB MB, without /home." 558 echo -n "How big do you want your /home to be in MB (0-$maxhome) ? [$defmb] " 559 read homesize 560 if [ "$homesize" = "" ] ; then homesize=$defmb; fi 561 if [ "$homesize" -lt 1 ] 562 then nohome=1 563 echo "Ok, not making a /home." 564 homesize=0 565 else 566 if [ "$homesize" -gt "$maxhome" ] 567 then echo "That won't fit!" 568 homesize="" 569 else 570 echo "" 571 echo -n "$homesize MB Ok? [Y] " 572 read ok 573 [ "$ok" = Y -o "$ok" = y -o "$ok" = "" ] || homesize="" 574 fi 575 fi 576 echo "" 577 done 578 # Homesize in sectors 579 homemb="$homesize MB" 580 homesize="`expr $homesize '*' 1024 '*' 2`" 581else 582 # Root size same as our default? If not, warn and keep old root size 583 ROOTSECTSDEFAULT=$ROOTSECTS 584 ROOTSECTS="`devsize /dev/$root`" 585 ROOTMB="`expr $ROOTSECTS / 2048`" 586 if [ $ROOTSECTS -ne $ROOTSECTSDEFAULT ] 587 then 588 # Check if we 589 echo "Root partition size `expr $ROOTSECTS / 2`kb differs from default `expr $ROOTSECTSDEFAULT / 2`kb." 590 echo "This is not a problem, but you may want to do a fresh install at some point to" 591 echo "be able to benefit from the new default." 592 fi 593 594 # Check if enough space for new boot (even if old used) 595 bootspace=$((`devsize /dev/$primary`-`devsize /dev/$root`-`devsize /dev/$home`-`devsize /dev/$usr`)) >/dev/null 596 if [ $bootspace -lt $BOOTXXSECTS ] 597 then 598 echo "Root partition size will be reduced by up to 16Kb to fit new bootloader." 599 echo "This is not a problem." 600 ROOTSECTS=`expr $ROOTSECTS - $BOOTXXSECTS + $bootspace` 601 fi 602 603 # Recompute totals based on root size 604 TOTALMB="`expr 3 + $USRKB / 1024 + $ROOTMB`" 605 maxhome="`expr $devsizemb - $TOTALMB - 1`" 606 607 homepart="`devsize /dev/$home`" 608 homesize="`expr $homepart / 2 / 1024`" 609 if [ "$homesize" -gt "$maxhome" ] 610 then 611 echo "Sorry, but your /home is too big ($homesize MB) to leave enough" 612 echo "space on the rest of the partition ($devsizemb MB) for your" 613 echo "selected installation size ($TOTALMB MB)." 614 exit 1 615 fi 616 # Homesize unchanged (reinstall) 617 homesize=exist 618 homemb="current size" 619fi 620 621minblocksize=1 622maxblocksize=64 623blockdefault=4 624 625if [ ! "$auto" = "r" ] 626then 627 echo "" 628echo " --- Step 6: Select a block size ---------------------------------------" 629 echo "" 630 631 echo "The default file system block size is $blockdefault kB." 632 echo "" 633 634 while [ -z "$blocksize" ] 635 do 636 echo -n "Block size in kilobytes? [$blockdefault] "; read blocksize 637 test -z "$blocksize" && blocksize=$blockdefault 638 if [ "$blocksize" -lt $minblocksize -o "$blocksize" -gt $maxblocksize ] 639 then 640 warn "At least $minblocksize kB and at most $maxblocksize kB please." 641 blocksize="" 642 fi 643 done 644else 645 blocksize=$blockdefault 646fi 647 648blocksizebytes="`expr $blocksize '*' 1024`" 649 650bootsectors=$BOOTXXSECTS 651 652check_mbr 653 654echo " 655You have selected to (re)install MINIX 3 in the partition /dev/$primary. 656The following subpartitions are now being created on /dev/$primary: 657 658 Root subpartition: /dev/$root $ROOTMB MB 659 /home subpartition: /dev/$home $homemb 660 /usr subpartition: /dev/$usr rest of $primary 661" 662 # Secondary master bootstrap. 663# New boot doesn't require mbr on pN (bootxx will be there) 664# When necessarily mbr is installed on dN by partition. 665 # Partition the primary. 666partition /dev/$primary $bootsectors 81:${ROOTSECTS}* 81:$homesize 81:0+ > /dev/null || exit 667 668echo "Creating /dev/$root for / .." 669mkfs.mfs /dev/$root || exit 670 671if [ "$nohome" = 0 ] 672then 673 if [ ! "$auto" = r ] 674 then echo "Creating /dev/$home for /home .." 675 mkfs.$FSTYPE -B $blocksizebytes /dev/$home || exit 676 fi 677else echo "Skipping /home" 678fi 679 680echo "Creating /dev/$usr for /usr .." 681mkfs.$FSTYPE -B $blocksizebytes /dev/$usr || exit 682 683if [ "$nohome" = 0 ] 684then 685 fshome="/dev/$home /home $FSTYPE rw 0 2" 686else fshome="" 687fi 688 689echo "" 690echo " --- Step 7: Wait for files to be copied -------------------------------" 691echo "" 692echo "All files will now be copied to your hard disk. This may take a while." 693echo "" 694 695mount /dev/$root /mnt >/dev/null || exit 696mkdir -p /mnt/usr 697mount /dev/$usr /mnt/usr >/dev/null || exit # Mount the intended /usr. 698if [ "$nohome" = 0 ]; then 699 mkdir -p /mnt/home 700 mount /dev/$home /mnt/home >/dev/null || exit # Mount the intended /home 701fi 702 703# Running from the installation CD. 704for set in /i386/binary/sets/*.tgz; do 705 echo "Extracting $(basename "$set")..." 706 COUNT_FILES=$(cat $(echo "$set" | sed -e "s/\.tgz/\.count/")) 707 (cd /mnt; pax -rz -f $set -v -pe 2>&1 | progressbar "$COUNT_FILES" || exit) 708done; 709 710echo "Creating device nodes..." 711(cd /mnt/dev; MAKEDEV -s all) 712 713# Fix permissions 714chmod $(stat -f %Lp /usr) /mnt/usr 715chown $(stat -f %u /usr) /mnt/usr 716chgrp $(stat -f %g /usr) /mnt/usr 717if [ "$nohome" = 0 ]; then 718 chmod $(stat -f %Lp /home) /mnt/home 719 chown $(stat -f %u /home) /mnt/home 720 chgrp $(stat -f %g /home) /mnt/home 721fi 722 723cp /mnt/etc/motd.install /mnt/etc/motd 724 725# CD remnants that aren't for the installed system 726rm /mnt/etc/issue /mnt/CD /mnt/.* 2>/dev/null 727echo >/mnt/etc/fstab "/dev/$root / mfs rw 0 1 728/dev/$usr /usr $FSTYPE rw 0 2 729$fshome 730none /sys devman rw,rslabel=devman 0 0 731none /dev/pts ptyfs rw,rslabel=ptyfs 0 0" 732 733 # National keyboard map. 734test -n "$keymap" && cp -p "/usr/lib/keymaps/$keymap.map" /mnt/etc/keymap 735 736# XXX we have to use "-f" here, because installboot worries about BPB, which 737# we don't have... 738installboot_nbsd -f /dev/$primary /usr/mdec/bootxx_minixfs3 >/dev/null || exit 739# give the install the boot loader 740cp /usr/mdec/boot_monitor /mnt/ 741minixdir=/mnt/boot/minix_default 742if [ ! -f $minixdir/kernel ] 743then rm -rf $minixdir 744 cp -r /mnt/boot/minix/.temp $minixdir 745fi 746if [ ! -e /mnt/boot/minix_latest ] 747then ln -sf minix_default /mnt/boot/minix_latest 748fi 749chroot /mnt update_bootcfg 750 751# Save name of CD drive 752cddrive="`mount | fgrep ' /usr ' | awk '{ print $1 }' | sed 's/p.*//'`" 753echo "cddrive=$cddrive" >>/mnt/usr/etc/rc.package 754 755bios="`echo $primary | sed -e 's/d./dX/g' -e 's/c.//g'`" 756 757echo "Saving random data.." 758dd if=/dev/random of=/mnt/usr/adm/random.dat bs=1024 count=1 759 760# Networking. 761echo "" 762echo " --- Step 8: Select your Ethernet chip ---------------------------------" 763echo "" 764 765/bin/netconf -p /mnt || echo FAILED TO CONFIGURE NETWORK 766 767PACKAGES_DIR="/usr/packages/$(uname -v | cut -f2 -d' ')/$(uname -p)/All" 768if [ -e "$PACKAGES_DIR" ] 769then 770 echo "Installing pkgin..." 771 772 sh -c "cp $PACKAGES_DIR/pkgin-* $PACKAGES_DIR/pkg_install-* $PACKAGES_DIR/openssl-* /mnt/tmp && 773 chroot /mnt pkg_add /tmp/openssl-* /tmp/pkg_install-* /tmp/pkgin-*" 774 rm -f /mnt/tmp/* 775 776 if [ -f "$PACKAGES_DIR/pkg_summary.bz2" ] 777 then 778 echo "" 779 echo "Packages are bundled on this installation media." 780 echo "They are available under the directory $PACKAGES_DIR" 781 echo "To install them after rebooting, mount this CD, set PKG_PATH to this directory" 782 echo "and use pkg_add." 783 echo "If you mount the CD at /mnt, PKG_PATH should be:" 784 echo "/mnt$PACKAGES_DIR" 785 echo "" 786 fi 787fi 788 789umount /dev/$usr && echo Unmounted $usr 790umount /dev/$root && echo Unmounted $root 791if [ "$nohome" = 0 ]; then 792 umount /dev/$home && echo Unmounted $home 793fi 794 795echo " 796Please type 'shutdown -r now' to exit MINIX 3 and reboot. To boot into 797your new system, you might have to remove the installation media. 798 799This ends the MINIX 3 setup script. You may want to take care of post 800installation steps, such as local testing and configuration. 801 802Please consult the user manual for more information. 803 804" 805 806