3 # setup 4.1 - install a MINIX distribution
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)
11 LOCALRC
=/usr
/etc
/rc.
local
12 MYLOCALRC
=/mnt
/etc
/rc.
local
14 ROOTSECTS
="`expr $ROOTMB '*' 1024 '*' 2`"
16 if [ ! -f "$USRKBFILE" ]
17 then echo "Are you really running from CD?"
18 echo "No $USRKBFILE file."
22 TOTALMB
="`expr 3 + $USRKB / 1024 + $ROOTMB`"
23 ROOTFILES
="`cat /.rootfiles`"
24 USRFILES
="`cat /.usrfiles`"
26 if [ "$TOTALMB" -lt 1 ]
28 echo "Are you really running from CD?"
29 echo "Something wrong with size estimate on CD."
33 if [ "$ROOTFILES" -lt 1 ]
35 echo "Are you really running from CD?"
36 echo "Something wrong with root files count on CD."
40 if [ "$USRFILES" -lt 1 ]
42 echo "Are you really running from CD?"
43 echo "Something wrong with usr files count on CD."
54 Usage: setup # Install a skeleton system on the hard disk.
55 setup /usr # Install the rest of the system (binaries or sources).
57 # To install from other things then floppies:
59 urlget http://... | setup /usr # Read from a web site.
60 urlget ftp://... | setup /usr # Read from an FTP site.
61 mtools copy c0d0p0:... - | setup /usr # Read from the C: drive.
62 dosread c0d0p0 ... | setup /usr # Likewise if no mtools.
69 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"
73 while getopts '' opt
; do usage
; done
74 shift `expr $OPTIND - 1`
76 if [ "$USER" != root
]
77 then echo "Please run setup as root."
81 # Find out what we are running from.
82 exec 9<&0 </etc
/mtab
# Mounted file table.
83 read thisroot rest
# Current root (/dev/ram or /dev/fd?)
84 read fdusr rest
# USR (/dev/fd? or /dev/fd?p2)
87 # What do we know about ROOT?
88 case $thisroot:$fdusr in
89 /dev
/ram
:/dev
/fd0p2
) fdroot
=/dev
/fd0
# Combined ROOT+USR in drive 0
91 /dev
/ram
:/dev
/fd1p2
) fdroot
=/dev
/fd1
# Combined ROOT+USR in drive 1
93 /dev
/ram
:/dev
/fd
*) fdroot
=unknown
# ROOT is some other floppy
95 /dev
/fd
*:/dev
/fd
*) fdroot
=$thisroot # ROOT is mounted directly
97 *) fdroot
=$thisroot # ?
101 Welcome to the MINIX 3 setup script. This script will guide you in setting up
102 MINIX on your machine. Please consult the manual for detailed instructions.
104 Note 1: If the screen blanks, hit CTRL+F3 to select \"software scrolling\".
105 Note 2: If things go wrong then hit CTRL+C to abort and start over.
106 Note 3: Default answers, like [y], can simply be chosen by hitting ENTER.
107 Note 4: If you see a colon (:) then you should hit ENTER to continue.
113 echo " --- Step 1: Select keyboard type --------------------------------------"
116 echo "What type of keyboard do you have? You can choose one of:"
118 ls -C /usr
/lib
/keymaps |
sed -e 's/\.map//g' -e 's/^/ /'
121 while [ "$step1" != ok
]
123 echo -n "Keyboard type? [us-std] "; read keymap
124 test -n "$keymap" || keymap
=us-std
125 if loadkeys
"/usr/lib/keymaps/$keymap.map" 2>/dev
/null
127 else warn
"invalid keyboard"
134 #while [ "$step2" != ok ]
137 # echo " --- Step 2: Select minimal or full distribution -----------------------"
139 # echo "You can install MINIX as (M)inimal or (F)ull. (M)inimal"
140 # echo "includes only the binary system and basic system sources."
141 # echo "(F)ull also includes commands sources."
143 # echo "Please select:"
144 # echo " (M)inimal install (only basic sources) ($NOSRCMB MB required)"
145 # echo " (F)ull install (full install) ($TOTALMB MB required)"
147 # echo -n "Basic (M)inimal or (F)ull install? [F] "
150 # "") step2="ok"; nobigsource="" ;;
151 # [Ff]*) step2="ok"; nobigsource="" ;;
152 # [Mm]*) step2="ok"; nobigsource="1"; TOTALMB=$NOSRCMB; USRFILES=$NOSRCUSRFILES ;;
158 echo " --- Step 2: Selecting full distribution -------------------------------"
164 while [ "$step3" != ok
]
167 echo " --- Step 3: Create or select a partition for MINIX 3 -------------------"
170 echo "Now you need to create a MINIX 3 partition on your hard disk."
171 echo "You can also select one that's already there."
173 echo "If you have an existing installation, reinstalling will let you"
174 echo "keep your current partitioning and subpartitioning, and overwrite"
175 echo "everything except your s1 subpartition (/home). If you want to"
176 echo "reinstall, select your existing minix partition."
178 echo "Unless you are an expert, you are advised to use the automated"
179 echo "step-by-step help in setting up."
184 echo -n "Press ENTER for automatic mode, or type 'expert': "
186 if [ -z "$mode" ]; then auto
="1"; ok
="yes"; fi
187 if [ "$mode" = expert
]; then auto
=""; ok
="yes"; fi
188 if [ "$ok" != yes ]; then warn
"try again"; fi
197 MINIX needs one primary partition of $TOTALMB MB for a full install,
198 plus what you want for /home.
200 If there is no free space on your disk then you have to choose an option:
201 (1) Delete one or more partitions
202 (2) Allocate an existing partition to MINIX 3
203 (3) Exit setup and shrink a partition using a different OS
205 To make this partition you will be put in the editor \"part\". Follow the
206 advice under the '!' key to make a new partition of type MINIX. Do not
207 touch an existing partition unless you know precisely what you are doing!
208 Please note the name of the partition (e.g. c0d0p1, c0d1p3, c1d1p0) you
209 make. (See the devices section in usage(8) on MINIX device names.)
213 while [ -z "$primary" ]
218 Please finish the name of the primary partition you have created:
219 (Just type ENTER if you want to rerun \"part\") /dev/"
223 echo "This is the point of no return. You have selected to install MINIX"
224 echo "on partition /dev/$primary. Please confirm that you want to use this"
225 echo "selection to install MINIX."
229 if [ ! -b "/dev/$primary" ]
230 then echo "/dev/$primary is not a block device."
233 while [ -z "$confirmation" -o "$confirmation" != yes -a "$confirmation" != no
]
235 echo -n "Are you sure you want to continue? Please enter 'yes' or 'no': "
237 if [ "$confirmation" = yes ]; then step3
=ok
; fi
239 biosdrivename
="Actual BIOS device name unknown, due to expert mode."
245 if autopart
-m$TOTALMB -f$PF
251 biosdrivename
="Probably, the right command is \"boot $bdn\"."
254 else echo "Funny device $bd from autopart."
257 echo "Didn't find output from autopart."
259 else echo "Autopart tool failed. Trying again."
262 # Reset at retries and timeouts in case autopart left
266 if [ -n "$primary" ]; then step3
=ok
; fi
270 if [ ! -b "/dev/$primary" ]
271 then echo Doing step
3 again.
274 devsize
="`devsize /dev/$primary`"
276 if [ "$devsize" -lt 1 ]
277 then echo "/dev/$primary is a 0-sized device."
281 done # while step3 != ok
287 umount
/dev
/$root 2>/dev
/null
&& echo "Unmounted $root for you."
288 umount
/dev
/$home 2>/dev
/null
&& echo "Unmounted $home for you."
289 umount
/dev
/$usr 2>/dev
/null
&& echo "Unmounted $usr for you."
291 devsizemb
="`expr $devsize / 1024 / 2`"
292 maxhome
="`expr $devsizemb - $TOTALMB - 1`"
294 if [ "$devsizemb" -lt "$TOTALMB" ]
295 then echo "The selected partition ($devsizemb MB) is too small."
296 echo "You'll need $TOTALMB MB at least."
300 if [ "$maxhome" -lt 1 ]
301 then echo "Note: you can't have /home with that size partition."
306 mkdir
$TMPMP >/dev
/null
2>&1
310 while [ "$confirm" = "" ]
314 echo " --- Step 4: Reinstall choice ------------------------------------------"
315 if mount
-r /dev
/$home $TMPMP >/dev
/null
2>&1
316 then umount
/dev
/$home >/dev
/null
2>&1
318 echo "You have selected an existing MINIX 3 partition."
319 echo "Type F for full installation (to overwrite entire partition)"
320 echo "Type R for a reinstallation (existing /home will not be affected)"
322 echo -n "(F)ull or (R)einstall? [R] "
325 "") confirm
="ok"; auto
="r"; ;;
326 [Rr
]*) confirm
="ok"; auto
="r"; ;;
327 [Ff
]*) confirm
="ok"; auto
="" ;;
331 echo "No old /home found. Doing full install."
346 echo " --- Step 5: Select the size of /home ----------------------------------"
347 while [ -z "$homesize" ]
350 # 20% of what is left over after / and /usr
352 defmb
="`expr $maxhome / 5`"
353 if [ "$defmb" -gt "$maxhome" ]
359 echo "MINIX will take up $TOTALMB MB, without /home."
360 echo -n "How big do you want your /home to be in MB (0-$maxhome) ? [$defmb] "
362 if [ "$homesize" = "" ] ; then homesize
=$defmb; fi
363 if [ "$homesize" -lt 1 ]
365 echo "Ok, not making a /home."
368 if [ "$homesize" -gt "$maxhome" ]
369 then echo "That won't fit!"
373 echo -n "$homesize MB Ok? [Y] "
375 [ "$ok" = Y
-o "$ok" = y
-o "$ok" = "" ] || homesize
=""
380 # Homesize in sectors
381 homemb
="$homesize MB"
382 homesize
="`expr $homesize '*' 1024 '*' 2`"
384 homepart
="`devsize /dev/$home`"
385 homesize
="`expr $homepart / 2 / 1024`"
386 if [ "$homesize" -gt "$maxhome" ]
388 echo "Sorry, but your /home is too big ($homesize MB) to leave enough"
389 echo "space on the rest of the partition ($devsizemb MB) for your"
390 echo "selected installation size ($TOTALMB MB)."
393 # Homesize unchanged (reinstall)
395 homemb
="current size"
402 if [ ! "$auto" = "r" ]
405 echo " --- Step 6: Select a block size ---------------------------------------"
408 echo "The default file system block size is $blockdefault kB."
411 while [ -z "$blocksize" ]
413 echo -n "Block size in kilobytes? [$blockdefault] "; read blocksize
414 test -z "$blocksize" && blocksize
=$blockdefault
415 if [ "$blocksize" -lt $minblocksize -o "$blocksize" -gt $maxblocksize ]
417 warn
"At least $minblocksize kB and at most $maxblocksize kB please."
422 blocksize
=$blockdefault
425 blocksizebytes
="`expr $blocksize '*' 1024`"
428 You have selected to (re)install MINIX 3 in the partition /dev/$primary.
429 The following subpartitions are now being created on /dev/$primary:
431 Root subpartition: /dev/$root $ROOTMB MB
432 /home subpartition: /dev/$home $homemb
433 /usr subpartition: /dev/$usr rest of $primary
435 # Secondary master bootstrap.
436 installboot
-m /dev
/$primary /usr
/mdec
/masterboot
>/dev
/null ||
exit
437 # Partition the primary.
438 partition
/dev
/$primary 1 81:${ROOTSECTS}* 81:$homesize 81:0+ > /dev
/null ||
exit
440 echo "Creating /dev/$root for / .."
441 mkfs
/dev
/$root ||
exit
446 then echo "Creating /dev/$home for /home .."
447 mkfs
-B $blocksizebytes /dev
/$home ||
exit
449 else echo "Skipping /home"
452 echo "Creating /dev/$usr for /usr .."
453 mkfs
-B $blocksizebytes /dev
/$usr ||
exit
457 fshome
="home=/dev/$home"
462 echo " --- Step 7: Wait for files to be copied -------------------------------"
464 echo "All files will now be copied to your hard disk. This may take a while."
467 mount
/dev
/$usr /mnt
>/dev
/null ||
exit # Mount the intended /usr.
470 list
="`ls | fgrep -v install`"
475 ) | progressbar
"$USRFILES" ||
exit # Copy the usr floppy.
477 umount
/dev
/$usr >/dev
/null ||
exit # Unmount the intended /usr.
478 mount
/dev
/$root /mnt
>/dev
/null ||
exit
480 # Running from the installation CD.
481 cpdir
-vx / /mnt | progressbar
"$ROOTFILES" ||
exit
482 cp /mnt
/etc
/motd.
install /mnt
/etc
/motd
486 ln -s /usr
/log
/mnt
/var
/log
488 # CD remnants that aren't for the installed system
489 rm /mnt
/etc
/issue
/mnt
/CD
/mnt
/.
* 2>/dev
/null
490 echo >/mnt
/etc
/fstab
"\
491 # Poor man's File System Table.
497 # National keyboard map.
498 test -n "$keymap" && cp -p "/usr/lib/keymaps/$keymap.map" /mnt
/etc
/keymap
500 umount
/dev
/$root >/dev
/null ||
exit # Unmount the new root.
501 mount
/dev
/$usr /mnt
>/dev
/null ||
exit
504 installboot
-d /dev
/$root /usr
/mdec
/bootblock
/boot
/boot
>/dev
/null ||
exit
506 edparams
/dev
/$root "rootdev=$root; ramimagedev=$root; minix(1,Start MINIX 3) { image=/boot/image_big; boot; }; newminix(2,Start Custom MINIX 3) { unset image; boot }; main() { echo By default, MINIX 3 will automatically load in 3 seconds.; echo Press ESC to enter the monitor for special configuration.; trap 3000 boot; menu; }; save" ||
exit
507 pfile
="/mnt/src/tools/fdbootparams"
508 echo "rootdev=$root; ramimagedev=$root; save" >$pfile
509 # Save name of CD drive
510 cddrive
="`mount | grep usr | awk '{ print $1 }' | sed 's/p.*//'`"
511 echo "cddrive=$cddrive" >>/mnt
/etc
/rc.package
513 bios
="`echo $primary | sed -e 's/d./dX/g' -e 's/c.//g'`"
515 if [ ! "$auto" = "r" ]
516 then if mount
/dev
/$home /home
2>/dev
/null
517 then for u
in bin ast
518 do h
=`eval echo "~$u"`
520 then echo " * Creating home directory for $u in $h"
522 chown
-R $u:operator
$h
523 else echo " * Couldn't create $h"
530 echo "Saving random data.."
531 dd if=/dev
/random of
=/mnt
/adm
/random.dat bs
=1024 count
=1
533 umount
/dev
/$usr >/dev
/null ||
exit
537 echo " --- Step 8: Select your Ethernet chip ---------------------------------"
540 mount
/dev
/$root /mnt
>/dev
/null ||
exit
541 mount
/dev
/$usr /mnt
/usr
>/dev
/null ||
exit
543 /bin
/netconf
-p /mnt ||
echo FAILED TO CONFIGURE NETWORK
545 umount
/dev
/$usr && echo Unmounted
$usr
546 umount
/dev
/$root && echo Unmounted
$root
549 Please type 'shutdown' to exit MINIX 3 and enter the boot monitor. At
550 the boot monitor prompt, type 'boot $bios', where X is the bios drive
551 number of the drive you installed on, to try your new MINIX system.
554 This ends the MINIX 3 setup script. After booting your newly set up system,
555 you can run the test suites as indicated in the setup manual. You also
556 may want to take care of local configuration, such as securing your system
557 with a password. Please consult the usage manual for more information.