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)
12 ROOTSECTS
="`expr $ROOTMB '*' 1024 '*' 2`"
14 #LSC: Slight over shoot, as files for / are taken into account, although
15 # metadata is not, all in all should be pretty accurate.
16 USRKB
=$
(cat /i386
/binary
/sets
/*.size |
awk '{s+=$1} END{print (s/1024)}')
17 TOTALMB
="`expr 3 + $USRKB / 1024 + $ROOTMB`"
18 TOTALFILES
="`find -x / | wc -l`"
20 # /usr/install isn't copied onto the new system; compensate
21 INSTALLDIR
=/usr
/install
23 then USRFILES
=$
(($USRFILES - `find -x $INSTALLDIR | wc -l`))
24 USRKB
=$
(($USRKB - `du -sxk $INSTALLDIR | awk '{ print $1 }'`))
31 PATH
=/bin
:/sbin
:/usr
/bin
:/usr
/sbin
38 Usage: setup # Install a skeleton system on the hard disk.
39 setup /usr # Install the rest of the system (binaries or sources).
41 # To install from other things then floppies:
43 fetch -q -o - http://... | setup /usr # Read from a web site.
44 fetch -q -o - ftp://... | setup /usr # Read from an FTP site.
45 mtools copy c0d0p0:... - | setup /usr # Read from the C: drive.
46 dosread c0d0p0 ... | setup /usr # Likewise if no mtools.
53 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"
58 # check for potential problems with old mbr.
59 disk
=`echo -n "/dev/$primary" | sed 's/p[0-3]//'`
60 minix_primaries
=`echo -n "" | fdisk "$disk" | grep "MINIX" | wc -l`
61 if [ "$minix_primaries" -gt 1 ]
63 # old mbr + bootxx will not work with several partitions of
65 dd if=/usr
/mdec
/mbr of
=temp_mbr_netbsd bs
=1 count
=440 2>/dev
/null
66 dd if="$disk" bs
=1 count
=440 2>/dev
/null |
cmp - temp_mbr_netbsd
>/dev
/null
70 echo "Warning: you have MBR which doesn't support multiple MINIX 3 partitions!"
71 echo "You will be able to boot from the first one only!"
72 echo -n "Do you want to install new MBR into $disk? [Y] "
74 if [ "$ok" = Y
-o "$ok" = y
-o "$ok" = "" ]
76 installboot_nbsd
-m "$disk" /usr
/mdec
/mbr
>/dev
/null
85 while getopts '' opt
; do usage
; done
86 shift `expr $OPTIND - 1`
88 if [ "$USER" != root
]
89 then echo "Please run setup as root."
93 # Find out what we are running from.
94 exec 9<&0 </etc
/mtab
# Mounted file table.
95 read thisroot rest
# Current root (/dev/ram or /dev/fd?)
96 read fdusr rest
# USR (/dev/fd? or /dev/fd?p2)
99 # What do we know about ROOT?
100 case $thisroot:$fdusr in
101 /dev
/ram
:/dev
/fd0p2
) fdroot
=/dev
/fd0
# Combined ROOT+USR in drive 0
103 /dev
/ram
:/dev
/fd1p2
) fdroot
=/dev
/fd1
# Combined ROOT+USR in drive 1
105 /dev
/ram
:/dev
/fd
*) fdroot
=unknown
# ROOT is some other floppy
107 /dev
/fd
*:/dev
/fd
*) fdroot
=$thisroot # ROOT is mounted directly
109 *) fdroot
=$thisroot # ?
113 Welcome to the MINIX 3 setup script. This script will guide you in setting up
114 MINIX on your machine. Please consult the manual for detailed instructions.
116 Note 1: If the screen blanks, hit CTRL+F3 to select \"software scrolling\".
117 Note 2: If things go wrong then hit CTRL+C to abort and start over.
118 Note 3: Default answers, like [y], can simply be chosen by hitting ENTER.
119 Note 4: If you see a colon (:) then you should hit ENTER to continue.
125 echo " --- Step 1: Select keyboard type --------------------------------------"
128 echo "What type of keyboard do you have? You can choose one of:"
130 ls -C /usr
/lib
/keymaps |
sed -e 's/\.map//g' -e 's/^/ /'
133 while [ "$step1" != ok
]
135 echo -n "Keyboard type? [us-std] "; read keymap
136 test -n "$keymap" || keymap
=us-std
137 if loadkeys
"/usr/lib/keymaps/$keymap.map" 2>/dev
/null
139 else warn
"invalid keyboard"
146 #while [ "$step2" != ok ]
149 # echo " --- Step 2: Select minimal or full distribution -----------------------"
151 # echo "You can install MINIX as (M)inimal or (F)ull. (M)inimal"
152 # echo "includes only the binary system and basic system sources."
153 # echo "(F)ull also includes commands sources."
155 # echo "Please select:"
156 # echo " (M)inimal install (only basic sources) ($NOSRCMB MB required)"
157 # echo " (F)ull install (full install) ($TOTALMB MB required)"
159 # echo -n "Basic (M)inimal or (F)ull install? [F] "
162 # "") step2="ok"; nobigsource="" ;;
163 # [Ff]*) step2="ok"; nobigsource="" ;;
164 # [Mm]*) step2="ok"; nobigsource="1"; TOTALMB=$NOSRCMB; USRFILES=$NOSRCUSRFILES ;;
170 echo " --- Step 2: Selecting full distribution -------------------------------"
176 while [ "$step3" != ok
]
179 echo " --- Step 3: Create or select a partition for MINIX 3 -------------------"
182 echo "Now you need to create a MINIX 3 partition on your hard disk."
183 echo "You can also select one that's already there."
185 echo "If you have an existing installation, reinstalling will let you"
186 echo "keep your current partitioning and subpartitioning, and overwrite"
187 echo "everything except your s1 subpartition (/home). If you want to"
188 echo "reinstall, select your existing minix partition."
190 echo "Unless you are an expert, you are advised to use the automated"
191 echo "step-by-step help in setting up."
196 echo -n "Press ENTER for automatic mode, or type 'expert': "
198 if [ -z "$mode" ]; then auto
="1"; ok
="yes"; fi
199 if [ "$mode" = expert
]; then auto
=""; ok
="yes"; fi
200 if [ "$ok" != yes ]; then warn
"try again"; fi
209 MINIX needs one primary partition of $TOTALMB MB for a full install,
210 plus what you want for /home.
212 If there is no free space on your disk then you have to choose an option:
213 (1) Delete one or more partitions
214 (2) Allocate an existing partition to MINIX 3
215 (3) Exit setup and shrink a partition using a different OS
217 To make this partition you will be put in the editor \"part\". Follow the
218 advice under the '!' key to make a new partition of type MINIX. Do not
219 touch an existing partition unless you know precisely what you are doing!
220 Please note the name of the partition (e.g. c0d0p1, c0d1p3, c1d1p0) you
221 make. (See the devices section in usage(8) on MINIX device names.)
225 while [ -z "$primary" ]
230 Please finish the name of the primary partition you have created:
231 (Just type ENTER if you want to rerun \"part\") /dev/"
235 echo "This is the point of no return. You have selected to install MINIX"
236 echo "on partition /dev/$primary. Please confirm that you want to use this"
237 echo "selection to install MINIX."
241 if [ ! -b "/dev/$primary" ]
242 then echo "/dev/$primary is not a block device."
245 while [ -z "$confirmation" -o "$confirmation" != yes -a "$confirmation" != no
]
247 echo -n "Are you sure you want to continue? Please enter 'yes' or 'no': "
249 if [ "$confirmation" = yes ]; then step3
=ok
; fi
251 biosdrivename
="Actual BIOS device name unknown, due to expert mode."
257 if autopart
-m$TOTALMB -f$PF
263 biosdrivename
="Probably, the right command is \"boot $bdn\"."
266 else echo "Funny device $bd from autopart."
269 echo "Didn't find output from autopart."
271 else echo "Autopart tool failed. Trying again."
274 # Reset at retries and timeouts in case autopart left
278 if [ -n "$primary" ]; then step3
=ok
; fi
282 if [ ! -b "/dev/$primary" ]
283 then echo Doing step
3 again.
286 devsize
="`devsize /dev/$primary`"
288 if [ "$devsize" -lt 1 ]
289 then echo "/dev/$primary is a 0-sized device."
293 done # while step3 != ok
299 umount
/dev
/$home 2>/dev
/null
&& echo "Unmounted $home for you."
300 umount
/dev
/$usr 2>/dev
/null
&& echo "Unmounted $usr for you."
301 umount
/dev
/$root 2>/dev
/null
&& echo "Unmounted $root for you."
303 devsizemb
="`expr $devsize / 1024 / 2`"
304 maxhome
="`expr $devsizemb - $TOTALMB - 1`"
306 if [ "$devsizemb" -lt "$TOTALMB" ]
307 then echo "The selected partition ($devsizemb MB) is too small."
308 echo "You'll need $TOTALMB MB at least."
312 if [ "$maxhome" -lt 1 ]
313 then echo "Note: you can't have /home with that size partition."
318 mkdir
$TMPMP >/dev
/null
2>&1
322 while [ "$confirm" = "" ]
326 echo " --- Step 4: Reinstall choice ------------------------------------------"
327 if mount
-r /dev
/$home $TMPMP >/dev
/null
2>&1
328 then umount
/dev
/$home >/dev
/null
2>&1
330 echo "You have selected an existing MINIX 3 partition."
331 echo "Type F for full installation (to overwrite entire partition)"
332 echo "Type R for a reinstallation (existing /home will not be affected)"
334 echo -n "(F)ull or (R)einstall? [R] "
337 "") confirm
="ok"; auto
="r"; ;;
338 [Rr
]*) confirm
="ok"; auto
="r"; ;;
339 [Ff
]*) confirm
="ok"; auto
="" ;;
343 echo "No old /home found. Doing full install."
358 echo " --- Step 5: Select the size of /home ----------------------------------"
359 while [ -z "$homesize" ]
362 # 20% of what is left over after / and /usr
364 defmb
="`expr $maxhome / 5`"
365 if [ "$defmb" -gt "$maxhome" ]
371 echo "MINIX will take up $TOTALMB MB, without /home."
372 echo -n "How big do you want your /home to be in MB (0-$maxhome) ? [$defmb] "
374 if [ "$homesize" = "" ] ; then homesize
=$defmb; fi
375 if [ "$homesize" -lt 1 ]
377 echo "Ok, not making a /home."
380 if [ "$homesize" -gt "$maxhome" ]
381 then echo "That won't fit!"
385 echo -n "$homesize MB Ok? [Y] "
387 [ "$ok" = Y
-o "$ok" = y
-o "$ok" = "" ] || homesize
=""
392 # Homesize in sectors
393 homemb
="$homesize MB"
394 homesize
="`expr $homesize '*' 1024 '*' 2`"
396 # Root size same as our default? If not, warn and keep old root size
397 ROOTSECTSDEFAULT
=$ROOTSECTS
398 ROOTSECTS
="`devsize /dev/$root`"
399 ROOTMB
="`expr $ROOTSECTS / 2048`"
400 if [ $ROOTSECTS -ne $ROOTSECTSDEFAULT ]
403 echo "Root partition size `expr $ROOTSECTS / 2`kb differs from default `expr $ROOTSECTSDEFAULT / 2`kb."
404 echo "This is not a problem, but you may want to do a fresh install at some point to"
405 echo "be able to benefit from the new default."
408 # Check if enough space for new boot (even if old used)
409 bootspace
=$
((`devsize /dev/$primary`-`devsize /dev/$root`-`devsize /dev/$home`-`devsize /dev/$usr`)) >/dev
/null
410 if [ $bootspace -lt $BOOTXXSECTS ]
412 echo "Root partition size will be reduced by up to 16Kb to fit new bootloader."
413 echo "This is not a problem."
414 ROOTSECTS
=`expr $ROOTSECTS - $BOOTXXSECTS + $bootspace`
417 # Recompute totals based on root size
418 TOTALMB
="`expr 3 + $USRKB / 1024 + $ROOTMB`"
419 maxhome
="`expr $devsizemb - $TOTALMB - 1`"
421 homepart
="`devsize /dev/$home`"
422 homesize
="`expr $homepart / 2 / 1024`"
423 if [ "$homesize" -gt "$maxhome" ]
425 echo "Sorry, but your /home is too big ($homesize MB) to leave enough"
426 echo "space on the rest of the partition ($devsizemb MB) for your"
427 echo "selected installation size ($TOTALMB MB)."
430 # Homesize unchanged (reinstall)
432 homemb
="current size"
439 if [ ! "$auto" = "r" ]
442 echo " --- Step 6: Select a block size ---------------------------------------"
445 echo "The default file system block size is $blockdefault kB."
448 while [ -z "$blocksize" ]
450 echo -n "Block size in kilobytes? [$blockdefault] "; read blocksize
451 test -z "$blocksize" && blocksize
=$blockdefault
452 if [ "$blocksize" -lt $minblocksize -o "$blocksize" -gt $maxblocksize ]
454 warn
"At least $minblocksize kB and at most $maxblocksize kB please."
459 blocksize
=$blockdefault
462 blocksizebytes
="`expr $blocksize '*' 1024`"
464 bootsectors
=$BOOTXXSECTS
469 You have selected to (re)install MINIX 3 in the partition /dev/$primary.
470 The following subpartitions are now being created on /dev/$primary:
472 Root subpartition: /dev/$root $ROOTMB MB
473 /home subpartition: /dev/$home $homemb
474 /usr subpartition: /dev/$usr rest of $primary
476 # Secondary master bootstrap.
477 # New boot doesn't require mbr on pN (bootxx will be there)
478 # When necessarily mbr is installed on dN by partition.
479 # Partition the primary.
480 partition
/dev
/$primary $bootsectors 81:${ROOTSECTS}* 81:$homesize 81:0+ > /dev
/null ||
exit
482 echo "Creating /dev/$root for / .."
483 mkfs.mfs
/dev
/$root ||
exit
488 then echo "Creating /dev/$home for /home .."
489 mkfs.
$FSTYPE -B $blocksizebytes /dev
/$home ||
exit
491 else echo "Skipping /home"
494 echo "Creating /dev/$usr for /usr .."
495 mkfs.
$FSTYPE -B $blocksizebytes /dev
/$usr ||
exit
499 fshome
="/dev/$home /home $FSTYPE rw 0 2"
504 echo " --- Step 7: Wait for files to be copied -------------------------------"
506 echo "All files will now be copied to your hard disk. This may take a while."
509 mount
/dev
/$root /mnt
>/dev
/null ||
exit
511 mount
/dev
/$usr /mnt
/usr
>/dev
/null ||
exit # Mount the intended /usr.
512 if [ "$nohome" = 0 ]; then
514 mount
/dev
/$home /mnt
/home
>/dev
/null ||
exit # Mount the intended /home
517 # Running from the installation CD.
518 for set in /i386
/binary
/sets
/*.tgz
; do
519 echo "Extracting $(basename "$set")..."
520 COUNT_FILES
=$
(cat $
(echo "$set" |
sed -e "s/\.tgz/\.count/"))
521 (cd /mnt
; pax
-rz -f $set -v -pe 2>&1 | progressbar
"$COUNT_FILES" ||
exit)
524 echo "Creating device nodes..."
525 (cd /mnt
/dev
; MAKEDEV
-s all
)
528 chmod $
(stat
-f %Lp
/usr
) /mnt
/usr
529 chown $
(stat
-f %u
/usr
) /mnt
/usr
530 chgrp $
(stat
-f %g
/usr
) /mnt
/usr
531 if [ "$nohome" = 0 ]; then
532 chmod $
(stat
-f %Lp
/home
) /mnt
/home
533 chown $
(stat
-f %u
/home
) /mnt
/home
534 chgrp $
(stat
-f %g
/home
) /mnt
/home
537 # CD remnants that aren't for the installed system
538 rm /mnt
/etc
/issue
/mnt
/CD
/mnt
/.
* 2>/dev
/null
539 echo >/mnt
/etc
/fstab
"/dev/$root / mfs rw 0 1
540 /dev/$usr /usr $FSTYPE rw 0 2
542 none /sys devman rw,rslabel=devman 0 0
543 none /dev/pts ptyfs rw,rslabel=ptyfs 0 0"
545 # National keyboard map.
546 test -n "$keymap" && cp -p "/usr/lib/keymaps/$keymap.map" /mnt
/etc
/keymap
548 # XXX we have to use "-f" here, because installboot worries about BPB, which
550 installboot_nbsd
-f /dev
/$primary /usr
/mdec
/bootxx_minixfs3
>/dev
/null ||
exit
551 # give the install the boot loader
552 cp /usr
/mdec
/boot_monitor
/mnt
/
553 minixdir
=/mnt
/boot
/minix_default
554 if [ ! -f $minixdir/kernel
]
555 then rm -rf $minixdir
556 cp -r /mnt
/boot
/minix
/.temp
$minixdir
558 if [ ! -e /mnt
/boot
/minix_latest
]
559 then ln -sf minix_default
/mnt
/boot
/minix_latest
561 chroot
/mnt update_bootcfg
563 bios
="`echo $primary | sed -e 's/d./dX/g' -e 's/c.//g'`"
565 echo "Saving random data.."
566 dd if=/dev
/random of
=/mnt
/usr
/adm
/random.dat bs
=1024 count
=1
570 echo " --- Step 8: Select your Ethernet chip ---------------------------------"
573 /bin
/netconf
-p /mnt ||
echo FAILED TO CONFIGURE NETWORK
575 PACKAGES_DIR
="/packages/$(uname -v | cut -f2 -d' ')/$(uname -p)/All"
576 if [ -e "$PACKAGES_DIR" ]
578 echo "Installing pkgin..."
579 sh
-c "cp $PACKAGES_DIR/pkgin-* $PACKAGES_DIR/pkg_install-* $PACKAGES_DIR/libarchive-* /mnt/tmp &&
580 chroot /mnt pkg_add /tmp/pkgin-*"
583 # Save name of CD drive
584 cddrive
=$
(mount |
grep ' on / ' | cut
-f1 -d' ')
585 echo "cddrive=$cddrive" >>/mnt
/usr
/etc
/rc.package
587 echo "Package dir not found, skipping pkgin installation..."
590 if [ "$nohome" = 0 ]; then
591 umount
/dev
/$home && echo Unmounted
$home
593 umount
/dev
/$usr && echo Unmounted
$usr
594 umount
/dev
/$root && echo Unmounted
$root
597 Please type 'shutdown -r now' to exit MINIX 3 and reboot. To boot into
598 your new system, you might have to remove the installation media.
600 This ends the MINIX 3 setup script. You may want to take care of post
601 installation steps, such as local testing and configuration.
603 Please consult the user manual for more information.