root/morphix/trunk/clusterix/miniroot/linuxrc

Revision 2, 18.6 kB (checked in by nextime, 2 years ago)

Initial import, branching from morphix svn

  • Property svn:executable set to
Line 
1 #!/static/sh
2 #
3 # KNOPPIX General Startup Script
4 # (C) Klaus Knopper <knoppix@knopper.net>
5 # Adapted for the Morphix Base image (www.morphix.org)
6 # by Alex de Landgraaf <alextreme@xs4all.nl>
7 #
8 #
9 # This script needs some of the builtin ash commands (if, test, ...)
10 # mount/umount are also builtin in ash(-knoppix).
11
12 # insmod and rmmod are staticly compiled and are in /static/
13
14 # hardcoded configurable options
15 # Default maximum size of dynamic ramdisk in kilobytes
16 RAMSIZE=1000000
17 # End of options
18
19 # Don't allow interrupt signals
20 trap "" 1 2 3 15
21
22 # "Safe" SCSI modules in the right order for autoprobe
23 # Warning: The sym53c8xx.o and g_NCR* cause a kernel Oops if no such adapter
24 # is present.
25 #
26 # NB: It looks like that ncr53c8xx.o is more stable than 53c7,8xx.o for
27 # a ncr53c810 controller (at least on my installation box it's more
28 # immune to SCSI timeouts)
29 # Removed 53c7,8xx -> crashes if no device attached.
30 # Removed AM53C974 -> crashes tmscsim if adapter found
31 # Possible segfault with 2.6 ??
32 # aha1740.ko, atp870u.ko, megaraid.ko, qlogicfc.ko, a100u2w.ko
33 KEXT=".o"
34 SCSI_MODULES="aic7xxx$KEXT BusLogic$KEXT \
35 ncr53c8xx$KEXT NCR53c406a$KEXT \
36 ata_piix$KEXT \
37 advansys$KEXT aha1740$KEXT aha1542$KEXT aha152x$KEXT \
38 atp870u$KEXT dtc$KEXT eata$KEXT fdomain$KEXT gdth$KEXT \
39 megaraid$KEXT pas16$KEXT pci2220i$KEXT pci2000$KEXT psi240i$KEXT \
40 qlogicfas$KEXT qlogicfc$KEXT qlogicisp$KEXT \
41 seagate$KEXT t128$KEXT tmscsim$KEXT u14-34f$KEXT ultrastor$KEXT wd7000$KEXT \
42 a100u2w$KEXT 3w-xxxx$KEXT"
43
44 # Misc functions
45 INSMOD="insmod"
46 /static/[ -x /static/insmod ] && INSMOD="/static/insmod"
47
48 RMMOD="rmmod"
49 /static/[ -x /static/rmmod ] && RMMOD="/static/rmmod"
50
51 LOSETUP="losetup"
52 /static/[ -x /static/losetup ] && LOSETUP="/static/losetup"
53
54 BUILTIN_FS="iso9660 ext2 vfat ntfs"
55
56 mountit(){
57 # Usage: mountit src dst "options"
58 # Uses builtin mount of ash.knoppix
59 # Builin filesystems
60     BUILTIN_FS="iso9660 ext2 vfat ntfs"
61     for fs in $BUILTIN_FS; do
62         test -b $1 && mount -t $fs $3 $1 $2 >/dev/null 2>&1 && return 0
63     done
64     return 1
65 }
66
67 FOUND_SCSI=""
68 FOUND_MORPHIX=""
69 INTERACTIVE=""
70 #USE_SQUASH="default"
71
72 # Clean input/output
73 exec >/dev/console </dev/console 2>&1
74
75 # Reset fb color mode
76 RESET="]R"
77 # ANSI COLORS
78 # Erase to end of line
79 CRE="
80 "
81 # Clear and reset Screen
82 CLEAR="c"
83 # Normal color
84 NORMAL=""
85 # RED: Failure or error message
86 RED=""
87 # GREEN: Success message
88 GREEN=""
89 # YELLOW: Descriptions
90 YELLOW=""
91 # BLUE: System mesages
92 BLUE=""
93 # MAGENTA: Found devices or drivers
94 MAGENTA=""
95 # CYAN: Questions
96 CYAN=""
97 # BOLD WHITE: Hint
98 WHITE=""
99
100 # Clear screen with colormode reset
101 # echo "$CLEAR$RESET"
102 # echo "$CLEAR"
103 # Just go to the top of the screen
104 # echo -n ""
105 /static/echo ""
106 # Be verbose
107 /static/echo "${WHITE}Welcome to the ${BLUE}Clusterix${WHITE} liveCD!${NORMAL}"
108 /static/echo ""
109 /static/echo ""
110
111 # We only need the builtin commands and /static at this point
112 PATH=/static
113 export PATH
114
115 umask 022
116
117 # Mount /proc, /sys and /dev/pts
118 mount -t proc none /proc
119 mount -t devpts none /dev/pts
120 #mount -t sysfs /sys /sys > /dev/null 2>&1
121
122 # Read boot command line with builtin cat command (shell read function fails in Kernel 2.4.19-rc1)
123 CMDLINE="$(cat /proc/cmdline)"
124 # DMA is now on by default
125 DMA="yes"
126
127 # Check if we are in interactive startup mode
128 case "$CMDLINE" in *BOOT_IMAGE=expert\ *) INTERACTIVE="yes"; :>/interactive; ;; esac
129 # patch from Fabian's linuxrc_modules-disk.diff patch, 2003-07-28
130 case "$CMDLINE" in *modules-disk*) INTERACTIVE="yes"; ;; esac
131 NOCD=""
132 case "$CMDLINE" in *\ nodma*) DMA=""; ;; esac
133 case "$CMDLINE" in *\ fromhd*) NOCD="yes"; ;; esac
134 case "$CMDLINE" in *\ fromdirectory*) NOCD="yes"; HD_DIRECTORY="Yes"; ;; esac
135 case "$CMDLINE" in *\ fromnfs*) NOCD="yes"; NFS_SERVER="Yes"; ;; esac
136 # Does the user want to skip scsi detection?
137 NOSCSI=""
138 case "$CMDLINE" in *\ noscsi*) NOSCSI="yes"; ;; esac
139 case "$CMDLINE" in *\ debugmorphix*) DEBUG="yes"; ;; esac
140 case "$CMDLINE" in *\ debugmorphix=miniroot*) DEBUGMINIROOT="yes"; ;; esac
141 case "$CMDLINE" in *\ splash*) SPLASH="yes"; ;; esac
142
143 # added by guido socher to suppress warnings about nonexistant /proc/splash
144 if [ ! -f "/proc/splash" ]; then
145      unset SPLASH
146 fi
147
148 # Bootsplash by Eadz at eadz.co.nz
149 if test -n "$SPLASH"; then
150 splash -s -u 0 /bootsplash/config/bootsplash-1024x768.cfg >/dev/null
151 fi
152
153 # Disable kernel messages while probing modules in autodetect mode
154 echo "0" > /proc/sys/kernel/printk
155
156 # Check for IDE-SCSI capable CD-Rom(s) first
157 $INSMOD /modules/ide-scsi.o >/dev/null 2>&1
158 # Use ide-cd for ATAPI-only CD-Rom(s)
159 $INSMOD /modules/ide-cd.o >/dev/null 2>&1
160
161 # Mount module disk
162 mountmodules(){
163     TYPE="$1"; shift
164     echo -n "${CRE}${CYAN}Please insert ${TYPE} modules disk and hit Return. ${NORMAL}"
165     read a
166     echo -n "${CRE}${BLUE}Mounting ${TYPE} modules disk... ${NORMAL}"
167 # We always mount over /modules/scsi (because it's there ;-)
168     if mountit /dev/fd0 /modules/scsi "-o ro"; then
169         echo "${GREEN}OK.${NORMAL}"
170         return 0
171     fi
172     echo "${RED}NOT FOUND.${NORMAL}"
173     return 1
174 }
175
176 # Unmount module disk
177 umountmodules(){
178     TYPE="$1"; shift
179     echo -n "${CRE}${BLUE}Unmounting ${TYPE} modules disk... ${NORMAL}"
180     umount /modules/scsi >/dev/null
181     echo "${GREEN}DONE.${NORMAL}"
182 }
183
184 # Ask user for modules
185 askmodules(){
186     TYPE="$1"; shift
187     echo "${BLUE}${TYPE} modules available:${WHITE}"
188     c=""; for m in "$@"; do
189         if test -f "/modules/scsi/$m"; then
190             test -z "$c"  && { echo -n "        $m"; c="1"; } || { echo "               $m"; c=""; }
191         fi
192     done
193     [ -n "$c" ] && echo ""
194     echo "${CYAN}Load ${TYPE} Modules?${NORMAL}"
195     echo "${CYAN}[Enter full filename(s) (space-separated), Return for autoprobe, ${WHITE}n${CYAN} for none] ${NORMAL}"
196     echo -n "${CYAN}insmod module(s)> ${NORMAL}"
197     read MODULES
198     case "$MODULES" in n|N) MODULES=""; ;; y|"")  MODULES="$*"; ;; esac
199 }
200
201 # Try to load the given modules (full path or current directory)
202 loadmodules(){
203     TYPE="$1"; shift
204     test -n "$INTERACTIVE" && echo "6" > /proc/sys/kernel/printk
205     for i in "$@"; do
206         echo -n "${CRE}${BLUE}Probing ${TYPE}... ${MAGENTA}$i${NORMAL}"
207         if test -f /modules/scsi/$i && $INSMOD -f /modules/scsi/$i >/dev/null 2>&1
208             then
209             echo "${CRE} ${GREEN}Found ${TYPE} device(s) handled by ${MAGENTA}$i${GREEN}.${NORMAL}"
210             case "$TYPE" in scsi|SCSI) FOUND_SCSI="yes"; ;; esac
211         fi
212     done
213     test -n "$INTERACTIVE" && echo "0" > /proc/sys/kernel/printk
214     echo -n "${CRE}"
215 }
216
217 case "$CMDLINE" in *bootusb2*) USBBOOT2="yes"; ;; esac
218 case "$CMDLINE" in *bootusb1*) USBBOOT1="yes"; ;; esac
219
220 if test -n "$USBBOOT2" -o -n "$USBBOOT1"
221     then
222 # load usb-modules first (so that memory-stick becomes /dev/sda1)
223     echo "6" > /proc/sys/kernel/printk
224     $INSMOD -f /modules/usb/usbcore$KEXT >/dev/null
225 # uncomment for USB 2.0 support (experimental)
226     if test -n "$USBBOOT2"
227         then
228         $INSMOD -f /modules/usb/ehci-hcd$KEXT >/dev/null
229     fi
230     if test -n "$USBBOOT1"
231         then
232         $INSMOD -f /modules/usb/usb-uhci$KEXT >/dev/null
233         $INSMOD -f /modules/usb/uhci$KEXT >/dev/null
234         $INSMOD -f /modules/usb/usb-ohci$KEXT >/dev/null
235     fi
236     $INSMOD -f /modules/usb/usb-storage$KEXT  >/dev/null
237     # wait 4 seconds for usb device to be registered
238     sleep 4
239     echo "0" > /proc/sys/kernel/printk
240 fi
241
242 # Check for SCSI, use modules on bootfloppy first
243 if test -n "$INTERACTIVE"; then
244 # Let the user select interactively
245 askmodules SCSI $(cd /modules/scsi; echo *$KEXT)
246 else
247 # these are the autoprobe-safe modules
248 MODULES="$SCSI_MODULES"
249 fi
250 test -z "$NOSCSI" && test -n "$MODULES" && loadmodules SCSI $MODULES
251 # End of SCSI check
252
253 # Check for misc modules in expert mode
254 if test -n "$INTERACTIVE"; then
255     another=""; answer=""
256     while test "$answer" != "n" -a "$answer" != "N"; do
257         echo -n "${CYAN}Do you want to load additional modules from$another floppy disk? [${WHITE}Y${CYAN}/n] ${NORMAL}"
258         another=" another"
259         read answer
260         case "$answer" in n*|N*) break; ;; esac
261         if mountmodules new; then
262             askmodules new $(cd /modules/scsi; echo *$KEXT)
263             test -n "$MODULES" && loadmodules new $MODULES
264             umountmodules current
265         fi
266     done
267 fi
268 # All interactively requested modules should be loaded now.
269
270 # Check for ide-scsi supported CD-Roms et al.
271 test -f /proc/scsi/scsi && FOUND_SCSI="yes"
272
273 # Disable kernel messages again
274 echo "0" > /proc/sys/kernel/printk
275
276
277 if test -n "$NFS_SERVER" -a -f /nfsrc; then
278   . /nfsrc
279 else
280 if test -n "$NFS_SERVER"; then
281   echo "couldn't find nfsrc, booting from CDROM"
282 fi
283
284 # Now that the right SCSI driver is (hopefully) loaded, try to find CDROM
285 DEVICES="/dev/hd?"
286 test -n "$FOUND_SCSI" -a -z "$NOCD" && DEVICES="/dev/scd? /dev/scd?? $DEVICES"
287 # New: Also try parallel port CD-Roms [for Mike].
288 DEVICES="$DEVICES /dev/pcd?"
289 # New: also check HD partitions for a MORPHIX/MORPHIX image
290 test -n "$FOUND_SCSI" && DEVICES="$DEVICES /dev/sd?[1-9] /dev/sd?[1-9][0-9]"
291 test -n "$USBBOOT2" -o -n "$USBBOOT1" && DEVICES="$DEVICES /dev/sda1"
292 DEVICES="$DEVICES /dev/hd?[1-9] /dev/hd?[1-9][0-9]"
293 DEVICES="$DEVICES /dev/ubd[1-9]"
294
295 for i in $DEVICES
296   do
297   echo -n "${CRE}${BLUE}Looking for CDROM in: ${MAGENTA}$i${NORMAL}   "
298   if mountit $i /cdrom "-o ro"   >/dev/null
299       then
300       if test -d /cdrom/base
301           then
302           echo -n "${CRE} ${GREEN}Accessing Clusterix CDROM at ${MAGENTA}$i${GREEN}...${NORMAL}"
303           FOUND_MORPHIX="$i"
304           break
305       fi
306       umount /cdrom
307   fi
308 done
309
310 if test -n "$SPLASH"; then
311 splash -s -u 1000 /bootsplash/config/bootsplash2-1024x768.cfg >/dev/null
312 fi
313
314 # We now enable DMA right here, for faster reading/writing from/to IDE devices
315 # in NOCD mode
316 if test -n "$DMA" ; then
317   echo ""
318   for d in $(cd /proc/ide  >/dev/null && echo hd[a-z]); do
319     if test -d /proc/ide/$d; then
320       MODEL="$(cat /proc/ide/$d/model 2>/dev/null)"
321       test -z "$MODEL" && MODEL="[GENERIC IDE DEVICE]"
322       echo "${BLUE}Enabling DMA acceleration for: ${MAGENTA}$d  ${YELLOW}[${MODEL}]${NORMAL}"
323       echo "using_dma:1" >/proc/ide/$d/settings
324     fi
325   done
326 fi
327
328 fi
329 # Harddisk-installed script part version has been removed
330 # (MORPHIX can be booted directly from HD now).
331
332 if test -n "$FOUND_MORPHIX" -a -f /cdrom/base/clusterix; then
333 # DEBUG
334     if test -n "$DEBUG"; then
335         echo "6" > /proc/sys/kernel/printk
336     fi
337
338 # Squashfs usage is set to default for Clusterix base mod, detection not required
339 #    USE_SQUASH=`head -n 1 /cdrom/base/morphix | grep "hsqs"`
340 #    if [ -z "$USE_SQUASH" ];then
341 #       $INSMOD -f /modules/cloop$KEXT 2> /dev/null
342 #       $LOSETUP /dev/cloop /cdrom/base/morphix
343 #       mountit /dev/cloop /MorphixCD "-o ro" || FOUND_MORPHIX="" 2> /dev/null
344 #    else
345         $INSMOD -f /modules/cloop$KEXT 2> /dev/null
346         $LOSETUP /dev/loop1 /cdrom/base/clusterix
347         mount -t squashfs -o ro /dev/loop1 /MorphixCD  || FOUND_MORPHIX="" 2> /dev/null
348 #    fi
349 else
350     echo "Warning: unable to find base module!"
351 fi
352
353 # COPYTORAM copied (ironic, isn't it?) from Fabian's linuxrc.rampatch 2003-07-26
354 COPYTOHD=""
355 COPYTO=""
356 COPYTORAM=""
357
358 case "$CMDLINE" in *toram*) COPYTO="yes"; COPYTORAM="yes"; ;; esac
359 case "$CMDLINE" in *tohd=*) COPYTO="yes"; COPYTOHD="yes"; ;; esac
360
361 # Copy the whole cdrom to ram ?
362 if  test -n "$COPYTO";
363 then 
364   # Pre-test if everything succeeded.
365   if test -n "$FOUND_MORPHIX"
366   then
367     # copy library cache
368     cat /MorphixCD/etc/ld.so.cache > /etc/ld.so.cache
369     echo ""
370
371     echo "Copying /cdrom to RamDisk/Harddisk, please be patient..." # Hey, we could use some fancy dialog skript here :-))
372     /bin/mkdir /cdrom2
373     if [ -n "$COPYTORAM" ]
374         then
375         /bin/mount -t tmpfs -o size=800M /dev/shm /cdrom2
376         /bin/cp -a /cdrom/* /cdrom2 # Copy everything to /cdrom2; yes we need more things then only the KNOPPIX/Morphix image, we don't want to produce problems we hadn't before, do we ? (note from Alex: this also copies any modules on the cdrom. Gotta love this patch :)
377     else
378         COPYTOHD=$(echo $CMDLINE | /usr/bin/tr ' ' '\n' | /bin/sed -n '/tohd=/s/.*=//p' | /usr/bin/tail -1)
379         echo -n "${CRE} ${GREEN}Copying Clusterix CDROM to ${MAGENTA}/dev/$COPYTOHD${GREEN}... Please be patient. ${NORMAL}"
380         if mountit /dev/$COPYTOHD /cdrom2 >/dev/null
381             then
382             /bin/cp -a /cdrom/* /cdrom2
383            #/bin/mount -o remount,ro /dev/$COPYTOHD /cdrom2
384         else
385             echo "${CRE} ${RED}Copying KNOPPIX CDROM failed. /dev/$COPYTOHD is not mountable. ${NORMAL}"
386         fi
387     fi
388     umount /MorphixCD # unmount it
389     echo "6" > /proc/sys/kernel/printk # Debugging
390     $RMMOD cloop # release CD
391     echo "0" > /proc/sys/kernel/printk # Debugging
392     umount /cdrom  # unmount CD
393     if test -f /cdrom2/base/morphix; then
394 #       if [ -z "$USE_SQUASH" ];then
395             $INSMOD -f /modules/cloop$KEXT 2> /dev/null
396 #           $LOSETUP /dev/cloop /cdrom2/base/morphix
397 #           mountit /dev/cloop /MorphixCD "-o ro" || FOUND_MORPHIX="" 2> /dev/null
398 #       else
399             $LOSETUP /dev/loop2 /cdrom/base/clusterix
400             mount -t squashfs -o ro /dev/loop2 /MorphixCD  || FOUND_MORPHIX="" 2> /dev/null
401 #       fi
402     else
403       FOUND_MORPHIX=""
404     fi
405   fi
406 fi 
407  
408
409 # Final test if everything succeeded.
410 if test -n "$FOUND_MORPHIX"
411     then
412 # copy library cache
413     cat /MorphixCD/etc/ld.so.cache > /etc/ld.so.cache
414     echo ""
415    
416 # Enable kernel messages
417     echo "6" > /proc/sys/kernel/printk
418    
419 # Set paths
420     echo -n "${CRE}${BLUE}Setting paths...${NORMAL}"
421     PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:."
422     export PATH
423    
424 # Debian weirdness (is this necessary for Morphix?)
425     /bin/cp -a /MorphixCD/etc/alternatives /etc/ 2>/dev/null
426    
427 # From here, we should have all essential commands available.
428     hash -r
429    
430 # Did we copy from ram ?
431     if  test -n "$COPYTO";
432         then
433         rmdir /cdrom
434         ln -s /cdrom2 /cdrom # make a symlink and go on to normal boot
435     fi
436    
437 # Clean up / (saves a meg)
438     rm -rf /modules
439
440 # New in Kernel 2.4.x: tempfs with variable ramdisk size.
441 # We check for available memory anyways and limit the ramdisks
442 # to a reasonable size.
443     FOUNDMEM="$(awk '/MemTotal/{print $2}' /proc/meminfo)"
444     TOTALMEM="$(awk 'BEGIN{m=0};/MemFree|Cached/{m+=$2};END{print m}' /proc/meminfo)"
445  
446 # Be verbose
447     echo "${CRE}${BLUE}Total memory found: ${YELLOW}${FOUNDMEM}${BLUE} kB${NORMAL}"
448
449 # Now we need to use a little intuition for finding a ramdisk size
450 # that keeps us from running out of space, but still doesn't crash the
451 # machine due to lack of Ram
452
453 # Minimum size of additional ram partitions
454     MINSIZE=2000
455 # At least this much memory minus 30% should remain when home and var are full.
456     MINLEFT=16000
457 # Maximum ramdisk size
458     MAXSIZE="$(expr $TOTALMEM - $MINLEFT)"
459 # Default ramdisk size for ramdisk
460     RAMSIZE="$(expr $TOTALMEM / 5)"
461
462 # Check for sufficient memory to mount extra ramdisk for /home + /var
463     if test -n "$TOTALMEM" -a "$TOTALMEM" -gt "$MINLEFT"; then
464         test -z "$RAMSIZE" && RAMSIZE=1000000
465         mkdir -p /ramdisk
466
467 # tmpfs/varsize version, can use swap
468         RAMSIZE=$(expr $RAMSIZE \* 4)
469         echo -n "${CRE}${BLUE}Creating ${YELLOW}/ramdisk${BLUE} (dynamic size=${RAMSIZE}k) on ${MAGENTA}/dev/shm${BLUE}...${NORMAL}"
470 # We need /bin/mount here for the -o size= option
471         /bin/mount -t tmpfs -o "size=${RAMSIZE}k" /dev/shm /ramdisk && mkdir -p /ramdisk/home /ramdisk/var /ramdisk/etc /ramdisk/dev && ln -s /ramdisk/home /ramdisk/var /
472         echo "${BLUE}Done.${NORMAL}"
473     else
474         mkdir -p /home /var
475     fi
476
477     if test -n "$DEBUGMORPHIX"; then
478         echo "Dropping to shell for debugging"
479         sh
480     fi
481
482     echo -n "${CRE}${BLUE}Creating directories and symlinks on ramdisk...${NORMAL}"
483 # Create common WRITABLE (empty) dirs
484
485 # We only need directories writeable that are used in the base module for
486 # hardware detection. Some of these might be removeable
487     mkdir -p /var/run /var/backups /var/local /var/lock/news \
488         /var/nis /var/preserve /var/tmp /var/lib /var/state/misc \
489         /mnt/cdrom /mnt/floppy /mnt/hd /mnt/test \
490         /var/spool/cups/tmp \
491         /home/root /etc/sysconfig /etc/X11 \
492         /home/morph
493 #       /var/nis /var/preserve
494 #       /var/spool/cups/tmp \
495     chown morph.morph /home/morph
496 # Create empty utmp and wtmp
497     :> /var/run/utmp
498     :> /var/run/wtmp
499
500     cp -a /MorphixCD/var/local /MorphixCD/var/log \
501     /MorphixCD/var/spool /var/ 2>/dev/null
502 #       /MorphixCD/var/spool
503     cp -a /MorphixCD/var/lib/nfs /MorphixCD/var/lib/xkb /MorphixCD/var/lib/isdn \
504         /MorphixCD/var/lib/pcmcia /var/lib/ 2>/dev/null
505 # Problematic directories in /var/lib (lots and lots of inodes)
506     ln -s /MorphixCD/var/lib/dpkg /MorphixCD/var/lib/apt \
507         /MorphixCD/var/lib/scrollkeeper \
508         /var/lib/ 2>/dev/null
509 # Debian-apt
510     ln -s /MorphixCD/var/cache/apt /var/cache/ 2>/dev/null
511     ln -s /MorphixCD/etc/skel /etc/dhcpc/resolv.conf \
512         /etc/ 2>/dev/null
513
514 # This is a memory-hogging hack, but somehow there isn't enough room on the first ramdisk
515 # to copy over the device nodes directly. TODO
516
517     ln -s /MorphixCD/dev/* /dev/ 2>/dev/null
518 #    /bin/mount --bind /MorphixCD/dev /dev
519 #    /bin/cp -aus /MorphixCD/dev/* /ramdisk/dev/
520 #    /bin/cp -a /dev /ramdisk/dev/
521 #    /bin/mount --bind /ramdisk/dev /dev
522
523 # Index files can be HUGE, so better replace cache/man tree by links later
524 # cp -a /MorphixCD/var/cache/man /var/cache/ 2>/dev/null
525 # Create links from CDROM for UNWRITABLE (remaining) files
526     /bin/cp -aus /MorphixCD/var/* /var/ 2>/dev/null
527     /bin/cp -aus /MorphixCD/etc/* /etc/ 2>/dev/null
528 # This possibly causes more problems, but is linked to the same issues as above with /dev
529
530 #    cp -a /MorphixCD/etc/* /ramdisk/etc/
531 #    cp -a /etc /ramdisk/etc/
532 #    /bin/mount --bind /ramdisk/etc /etc
533 #    cp -aus /MorphixCD/etc/* /etc/ >/dev/null
534
535 # Make SURE that these are files, not links!
536     rm -rf /etc/passwd /etc/shadow /etc/group \
537         /etc/ppp /etc/isdn /etc/ssh /etc/ioctl.save \
538         /etc/inittab /etc/network /etc/sudoers \
539         /etc/init /etc/localtime /etc/dhcpc /etc/pnm2ppa.conf 2>/dev/null
540
541     cp -a /MorphixCD/etc/passwd /MorphixCD/etc/shadow /MorphixCD/etc/group \
542         /MorphixCD/etc/ppp /MorphixCD/etc/isdn /MorphixCD/etc/ssh \
543         /MorphixCD/etc/inittab /MorphixCD/etc/network /MorphixCD/etc/sudoers \
544         /MorphixCD/sbin/init /MorphixCD/etc/dhcpc /etc/ 2>/dev/null
545 # Extremely important, init crashes on shutdown if this is only a link
546     :> /etc/ioctl.save
547     :> /etc/pnm2ppa.conf
548 # Diet libc bug workaround
549     cp -f /MorphixCD/etc/localtime /etc/localtime
550     echo "${BLUE}Done.${NORMAL}"
551
552 # Now tell kernel where the real modprobe lives
553     echo "/sbin/modprobe" > /proc/sys/kernel/modprobe
554
555 # Change root device from /dev/fd0 to /dev/ram0
556     echo "0x100" > /proc/sys/kernel/real-root-dev
557
558 # Give control to the init process.
559     echo "${CRE}${BLUE}Starting init process.${NORMAL}"
560     rm -f /linuxrc
561     exit 0
562
563 else
564     echo "${CRE}${RED}Can't find Morphix filesystem, sorry${NORMAL}"
565     echo "${RED}Dropping you to a busybox shell${NORMAL}"
566     echo "${RED}Make sure you have a Morphix Base image on your CD-ROM/HDD/NETWORK devices"
567     echo "${RED}Press reset button to quit.${NORMAL}"
568     echo ""
569     echo "Additional builtin commands avaliable:"
570     echo "busybox --help"
571     echo ""
572     PS1="morphix# "
573     export PS1
574     echo "6" > /proc/sys/kernel/printk
575 # Allow signals
576     trap 1 2 3 15
577     exec /static/ash
578 fi
Note: See TracBrowser for help on using the browser.