c3d5239881ca5b7cf77ce6b0b695158746e474e2
[genkernel.git] / defaults / linuxrc
1 #!/bin/sh
2
3 . /etc/initrd.defaults
4 . /etc/initrd.scripts
5
6 splash() {
7         return 0
8 }
9
10 [ -e /etc/initrd.splash ] && . /etc/initrd.splash
11
12 # Clean input/output
13 exec >${CONSOLE} <${CONSOLE} 2>&1
14
15 if [ "$$" != '1' ]
16 then
17         echo '/linuxrc has to be run as the init process as the one'
18         echo 'with a PID of 1. Try adding init="/linuxrc" to the'
19         echo 'kernel command line or running "exec /linuxrc".'
20         exit 1
21 fi
22
23 mount -t proc proc /proc >/dev/null 2>&1
24 mount -o remount,rw / >/dev/null 2>&1
25
26 # Set up symlinks
27 /bin/busybox --install -s
28
29 if [ "$0" = '/init' ]
30 then
31         [ -e /linuxrc ] && rm /linuxrc
32          
33         if [ -e /bin/lvm ]
34         then
35                 ln -s /bin/lvm /bin/vgscan
36                 ln -s /bin/lvm /bin/vgchange
37         fi
38 fi
39
40 quiet_kmsg
41
42 CMDLINE=`cat /proc/cmdline`
43 # Scan CMDLINE for any specified real_root= or cdroot arguments
44 FAKE_ROOT=''
45 REAL_ROOTFLAGS=''
46 CRYPT_SILENT=0
47 for x in ${CMDLINE}
48 do
49         case "${x}" in
50                 real_root\=*)
51                         REAL_ROOT=`parse_opt "${x}"`
52                 ;;
53                 root\=*)
54                         FAKE_ROOT=`parse_opt "${x}"`
55                 ;;
56                 subdir\=*)
57                         SUBDIR=`parse_opt "${x}"`
58                 ;;
59                 real_init\=*)
60                         REAL_INIT=`parse_opt "${x}"`
61                 ;;
62                 init_opts\=*)
63                         INIT_OPTS=`parse_opt "${x}"`
64                 ;;
65                 # Livecd options
66                 cdroot)
67                         CDROOT=1
68                 ;;
69                 cdroot\=*)
70                         CDROOT=1
71                         CDROOT_DEV=`parse_opt "${x}"`
72                 ;;
73                 cdroot_type\=*)
74                         CDROOT_TYPE=`parse_opt "${x}"`
75                 ;;
76                 # Start livecd loop, looptype options
77                 loop\=*)
78                         LOOP=`parse_opt "${x}"`
79                 ;;
80                 looptype\=*)
81                         LOOPTYPE=`parse_opt "${x}"`
82                 ;;
83                 # Start Volume manager options 
84                 dolvm)
85                         USE_LVM_NORMAL=1
86                 ;;
87                 dolvm2)
88                         bad_msg 'Using dolvm2 is deprecated, use dolvm, instead.'
89                         USE_LVM_NORMAL=1
90                 ;;
91                 domdadm)
92                         USE_MDADM=1
93                 ;;
94                 dodmraid)
95                         USE_DMRAID_NORMAL=1
96                 ;;
97                 dodmraid\=*)
98                         DMRAID_OPTS=`parse_opt "${x}"`
99                         USE_DMRAID_NORMAL=1
100                 ;;
101                 doevms)
102                         USE_EVMS_NORMAL=1
103                 ;;
104                 doevms2)
105                         bad_msg 'Using doevms2 is deprecated, use doevms, instead.'
106                         USE_EVMS_NORMAL=1
107                 ;;
108                 # Debug Options
109                 debug)
110                         DEBUG='yes'
111                 ;;
112                 # Scan delay options 
113                 scandelay\=*)
114                         SDELAY=`parse_opt "${x}"`
115                 ;;
116                 scandelay)
117                         SDELAY=10
118                 ;;
119                 # Module no-loads
120                 doload\=*)
121                         MDOLIST=`parse_opt "${x}"`
122                         MDOLIST="`echo ${MDOLIST} | sed -e 's/,/ /g'`"
123                 ;;
124                 nodetect)
125                         NODETECT=1
126                 ;;
127                 noload\=*)
128                         MLIST=`parse_opt "${x}"`
129                         MLIST="`echo ${MLIST} | sed -e 's/,/ /g'`"
130                         export MLIST
131                 ;;
132                 # Redirect output to a specific tty
133                 CONSOLE\=*|console\=*)
134                         CONSOLE=`parse_opt "${x}"`
135 #                       exec >${CONSOLE} <${CONSOLE} 2>&1
136                 ;;
137                 # /dev/md
138                 lvmraid\=*)
139                         RAID_DEVICES="`parse_opt ${x}`"
140                         RAID_DEVICES="`echo ${RAID_DEVICES} | sed -e 's/,/ /g'`"
141                 ;;
142                 part\=*)
143                         MDPART=`parse_opt "${x}"`
144                 ;;
145                 # NFS
146                 ip\=*)
147                         IP=`parse_opt "${x}"`
148                 ;;
149                 nfsroot\=*)
150                         NFSROOT=`parse_opt "${x}"`
151                 ;;
152                 # ISCSI
153                 iscsi_i\=*)
154                         ISCSI_I=`parse_opt "${x}"`
155                 ;;
156                 iscsi_t\=*)
157                         ISCSI_T=`parse_opt "${x}"`
158                 ;;
159                 iscsi_a\=*)
160                         ISCSI_A=`parse_opt "${x}"`
161                 ;;
162                 # Crypto
163                 crypt_root\=*)
164                         CRYPT_ROOT=`parse_opt "${x}"`
165                 ;;
166                 crypt_swap\=*)
167                         CRYPT_SWAP=`parse_opt "${x}"`
168                 ;;
169                 root_key\=*)
170                         CRYPT_ROOT_KEY=`parse_opt "${x}"`
171                 ;;
172                 root_keydev\=*)
173                         CRYPT_ROOT_KEYDEV=`parse_opt "${x}"`
174                 ;;
175                 swap_key\=*)
176                         CRYPT_SWAP_KEY=`parse_opt "${x}"`
177                 ;;
178                 swap_keydev\=*)
179                         CRYPT_SWAP_KEYDEV=`parse_opt "${x}"`
180                 ;;
181                 real_resume\=*)
182                         REAL_RESUME=`parse_opt "${x}"`
183                 ;;
184                 noresume)
185                         NORESUME=1
186                 ;;
187                 crypt_silent)
188                         CRYPT_SILENT=1
189                 ;;
190                 real_rootflags\=*)
191                         REAL_ROOTFLAGS=`parse_opt "${x}"`
192                 ;;
193                 keymap\=*)
194                         keymap=`parse_opt "${x}"`
195                 ;;
196                 unionfs)
197                         if [ ! -x /sbin/unionfs ]
198                         then
199                                 USE_UNIONFS_NORMAL=0
200                                 bad_msg 'unionfs binary not found: aborting use of unionfs!'
201                         else
202                                 USE_UNIONFS_NORMAL=1
203                         fi
204                         ;;
205                 nounionfs)
206                         USE_UNIONFS_NORMAL=0
207                         ;;
208 #                 unionfs\=*)    
209 #                         if [ ! -x /sbin/unionfs ]      
210 #                         then   
211 #                                 USE_UNIONFS_NORMAL=0   
212 #                                 bad_msg 'unionfs binary not found: aborting use of unionfs!'
213 #                         else   
214 #                                 USE_UNIONFS_NORMAL=1   
215 #                                 CMD_UNIONFS=`parse_opt "${x}"`         
216 #                                 echo ${CMD_UNIONFS}|grep , >/dev/null 2>&1     
217 #                                 if [ "$?" -eq '0' ]    
218 #                                 then   
219 #                                         UID=`echo ${CMD_UNIONFS#*,}`   
220 #                                         UNIONFS=`echo ${CMD_UNIONFS%,*}`       
221 #                                 else   
222 #                                         UNIONFS=${CMD_UNIONFS}         
223 #                                 fi     
224 #                         fi     
225 #                 ;;
226         esac
227 done
228
229 if [ -z "${REAL_ROOT}" -a \( "${CDROOT}" -eq 0 \)  -a \( "${FAKE_ROOT}" != "/dev/ram0" \) ]
230 then
231         REAL_ROOT="${FAKE_ROOT}"        
232 fi
233
234 splash 'init'
235
236 cmdline_hwopts
237
238 # Mount sysfs
239 mount_sysfs
240
241 # Setup hotplugging for firmware loading
242 setup_hotplug
243
244 # Load modules listed in MY_HWOPTS if /lib/modules exists for the running kernel
245 if [ -z "${DO_modules}" ]
246 then
247         good_msg 'Skipping module load; disabled via commandline'
248 elif [ -d "/lib/modules/${KV}" ]
249 then
250         good_msg 'Loading modules'
251         # Load appropriate kernel modules
252         if [ "${NODETECT}" != '1' ]
253         then
254                 for modules in ${MY_HWOPTS}
255                 do
256                         modules_scan ${modules}
257                 done
258         fi
259         # Always eval doload=...
260         modules_load ${MDOLIST}
261 else
262         good_msg 'Skipping module load; no modules in the ramdisk!'
263 fi
264
265 # Delay if needed for USB hardware
266 sdelay
267
268 # Start device manager
269 start_dev_mgr
270
271 # Setup md device nodes if they dont exist
272 setup_md_device
273
274 # Scan volumes
275 startVolumes
276
277 # Start ISCSI
278 startiscsi
279
280 setup_keymap
281
282 # Initialize LUKS root device except for livecd's
283 if [ "${CDROOT}" != 1 ]
284 then
285         startLUKS
286         if [ "${NORESUME}" != '1' ] && [ -n "${REAL_RESUME}" ]
287         then
288                 case "${REAL_RESUME}" in
289                         LABEL\=*|UUID\=*)
290
291                                 RESUME_DEV=""
292                                 retval=1
293                                 
294                                 if [ "${retval}" -ne '0' ]; then
295                                         RESUME_DEV=`findfs "${REAL_RESUME}" 2>/dev/null`
296                                         retval=$?
297                                 fi
298                                 
299                                 if [ "$retval" -ne '0' ]; then
300                                         RESUME_DEV=`busybox findfs "${REAL_RESUME}" 2>/dev/null`
301                                         retval=$?
302                                 fi
303                                 
304                                 if [ "${retval}" -ne '0' ]; then
305                                         RESUME_DEV=`blkid -t "${REAL_RESUME}" | cut -d ":" -f 1 2>/dev/null`
306                                         retval=$?
307                                 fi
308                                 
309                                 if [ "${retval}" -eq '0' ] && [ -n "${RESUME_DEV}" ]; then
310                                         good_msg "Detected real_resume=${RESUME_DEV}"
311                                         REAL_RESUME="${RESUME_DEV}"
312                                 fi
313                                 ;;
314                 esac
315
316                 swsusp_resume
317 #               suspend_resume
318                 tuxonice_resume
319         fi
320 fi
321
322 mkdir -p "${NEW_ROOT}"
323 CHROOT="${NEW_ROOT}"
324
325 # Run debug shell if requested
326 rundebugshell
327
328 if [ "${CDROOT}" = '1' ]
329 then
330         good_msg "Making tmpfs for ${NEW_ROOT}"
331         mount -n -t tmpfs tmpfs "${NEW_ROOT}"
332         
333         for i in dev mnt mnt/cdrom mnt/livecd mnt/key tmp tmp/.initrd mnt/gentoo sys
334         do
335                 mkdir -p "${NEW_ROOT}/${i}"
336                 chmod 755 "${NEW_ROOT}/${i}"
337         done
338         [ ! -e "${NEW_ROOT}/dev/null" ] && mknod "${NEW_ROOT}"/dev/null c 1 3
339         [ ! -e "${NEW_ROOT}/dev/console" ] && mknod "${NEW_ROOT}"/dev/console c 5 1
340
341         # For SGI LiveCDs ...
342         if [ "${LOOPTYPE}" = "sgimips" ]
343         then
344                 [ ! -e "${NEW_ROOT}/dev/sr0" ] && mknod "${NEW_ROOT}/dev/sr0" b 11 0
345                 [ ! -e "${NEW_ROOT}/dev/loop0" ] && mknod "${NEW_ROOT}/dev/loop0" b 7 0
346         fi
347
348         # Required for splash to work.  Not an issue with the initrd as this
349         # device isn't created there and is not needed.
350         if [ -e /dev/tty1 ]
351         then
352                 [ ! -e "${NEW_ROOT}/dev/tty1" ] && mknod "${NEW_ROOT}/dev/tty1" c 4 1
353         fi
354
355         if [ "${REAL_ROOT}" != "/dev/nfs" ] && [ "${LOOPTYPE}" != "sgimips" ]
356         then
357                 bootstrapCD
358         fi
359
360         if [ "${REAL_ROOT}" = '' ]
361         then
362                 echo -n -e "${WARN}>>${NORMAL}${BOLD} No bootable medium found. Waiting for new devices"
363                 
364                 COUNTER=0
365                 while [ ${COUNTER} -lt 3 ]; do
366                         sleep 3
367                         echo -n '.'
368                         let COUNTER=${COUNTER}+1
369                 done
370
371                 sleep 1
372                 echo -e "${NORMAL}"
373                 bootstrapCD
374         fi
375
376         if [ "${REAL_ROOT}" = '' ]
377         then
378                 # Undo stuff
379                 umount  "${NEW_ROOT}/dev" 2>/dev/null
380                 umount  "${NEW_ROOT}/sys" 2>/dev/null
381                 umount /sys 2>/dev/null
382
383                 umount  "${NEW_ROOT}"
384                 rm -rf  "${NEW_ROOT}/*"
385
386                 bad_msg 'Could not find CD to boot, something else needed!'
387                 CDROOT=0
388         fi
389 fi
390
391 # Determine root device
392 good_msg 'Determining root device...'
393 while true
394 do
395         while [ "${got_good_root}" != '1' ]
396         do
397                 case "${REAL_ROOT}" in
398                         LABEL\=*|UUID\=*)
399                         
400                                 ROOT_DEV=""
401                                 retval=1
402                                 
403                                 if [ "${retval}" -ne '0' ]; then
404                                         ROOT_DEV=`findfs "${REAL_ROOT}" 2>/dev/null`
405                                         retval=$?
406                                 fi
407                                 
408                                 if [ "$retval" -ne '0' ]; then
409                                         ROOT_DEV=`busybox findfs "${REAL_ROOT}" 2>/dev/null`
410                                         retval=$?
411                                 fi
412                                 
413                                 if [ "${retval}" -ne '0' ]; then
414                                         ROOT_DEV=`blkid -t "${REAL_ROOT}" | cut -d ":" -f 1 2>/dev/null`
415                                         retval=$?
416                                 fi
417                                 
418                                 if [ "${retval}" -eq '0' ] && [ -n "${ROOT_DEV}" ]; then
419                                         good_msg "Detected real_root=${ROOT_DEV}"
420                                         REAL_ROOT="${ROOT_DEV}"
421                                 else
422                                         whereis "REAL_ROOT" "root block device"
423                                         got_good_root=0
424                                         continue
425                                 fi
426                                 ;;
427                 esac
428                                 
429                 if [ "${REAL_ROOT}" = '' ]
430                 then
431                         # No REAL_ROOT determined/specified. Prompt user for root block device.
432                         whereis "REAL_ROOT" "root block device"
433                         got_good_root=0
434
435                 # Check for a block device or /dev/nfs
436                 elif [ -b "${REAL_ROOT}" ] || [ "${REAL_ROOT}" = "/dev/nfs" ]
437                 then
438                         got_good_root=1
439
440                 else
441                         bad_msg "Block device ${REAL_ROOT} is not a valid root device..."
442                         REAL_ROOT=""
443                         got_good_root=0
444                 fi
445         done
446
447
448         if [ "${CDROOT}" = 1 -a "${got_good_root}" = '1' -a "${REAL_ROOT}" != "/dev/nfs" ]
449         then
450                 # CD already mounted; no further checks necessary
451                 break
452         elif [ "${LOOPTYPE}" = "sgimips" ]
453         then
454                 # sgimips mounts the livecd root partition directly
455                 # there is no isofs filesystem to worry about
456                 break
457         else
458                 good_msg "Mounting root..."
459
460                 # Try to mount the device as ${NEW_ROOT}
461                 if [ "${REAL_ROOT}" = '/dev/nfs' ]; then
462                         findnfsmount
463                 else
464                         # mount ro so fsck doesn't barf later
465                         if [ "${REAL_ROOTFLAGS}" = '' ]; then
466                                 mount -o ro ${REAL_ROOT} ${NEW_ROOT}
467                         else
468                                 good_msg "Using mount -o ro,${REAL_ROOTFLAGS}"
469                                 mount -o ro,${REAL_ROOTFLAGS} ${REAL_ROOT} ${NEW_ROOT}
470                         fi
471                 fi
472                 
473                 # If mount is successful break out of the loop 
474                 # else not a good root and start over.
475                 if [ "$?" = '0' ]
476                 then
477                         if [ -d ${NEW_ROOT}/dev -a -x ${NEW_ROOT}/sbin/init ] || [ "${REAL_ROOT}" = "/dev/nfs" ]
478                         then
479                                 break
480                         else
481                                 bad_msg "The filesystem mounted at ${REAL_ROOT} does not appear to be a valid /, try again"
482                                 got_good_root=0
483                                 REAL_ROOT=''
484                         fi
485                 else
486                         bad_msg "Could not mount specified ROOT, try again"
487                         got_good_root=0
488                         REAL_ROOT=''
489                 fi
490         fi
491 done
492 # End determine root device
493
494 #verbose_kmsg
495
496 # If CD root is set determine the looptype to boot
497 if [ "${CDROOT}" = '1' ]
498 then
499         good_msg 'Determining looptype ...'
500         cd "${NEW_ROOT}"
501
502         # Find loop and looptype
503         [ -z "${LOOP}" ] && find_loop
504         [ -z "${LOOPTYPE}" ] && find_looptype
505
506         cache_cd_contents
507
508         # If encrypted, find key and mount, otherwise mount as usual
509         if [ -n "${CRYPT_ROOT}" ]
510         then
511                 CRYPT_ROOT_KEY="$(head -n 1 ${NEW_ROOT}/mnt/cdrom/livecd)"
512                 CRYPT_ROOT='/dev/loop0'
513                 good_msg 'You booted an encrypted livecd' "${CRYPT_SILENT}"
514
515                 losetup /dev/loop0 "${NEW_ROOT}/mnt/cdrom/${LOOPEXT}${LOOP}"
516                 test_success 'Preparing loop filesystem'
517
518                 startLUKS
519
520                 case ${LOOPTYPE} in
521                         normal)
522                                 MOUNTTYPE="ext2"
523                                 ;;
524                         *)
525                                 MOUNTTYPE="${LOOPTYPE}"
526                                 ;;
527                 esac
528                 mount -t "${MOUNTTYPE}" -o ro /dev/mapper/root "${NEW_ROOT}/mnt/livecd"
529                 test_success 'Mount filesystem'
530                 FS_LOCATION='mnt/livecd'
531         # Setup the loopback mounts, if unencrypted
532         else
533                 if [ "${LOOPTYPE}" = 'normal' ]
534                 then
535                         good_msg 'Mounting loop filesystem'
536                         mount -t ext2 -o loop,ro "${NEW_ROOT}/mnt/cdrom/${LOOPEXT}${LOOP}" "${NEW_ROOT}/mnt/livecd"
537                         test_success 'Mount filesystem'
538                         FS_LOCATION='mnt/livecd'
539                 elif [ "${LOOPTYPE}" = 'squashfs' ]
540                 then
541                         good_msg 'Mounting squashfs filesystem'
542                         mount -t squashfs -o loop,ro "${NEW_ROOT}/mnt/cdrom/${LOOPEXT}${LOOP}" "${NEW_ROOT}/mnt/livecd"
543                         test_success 'Mount filesystem'
544                         FS_LOCATION='mnt/livecd'
545                 elif [ "${LOOPTYPE}" = 'gcloop' ]
546                 then
547                         good_msg 'Mounting gcloop filesystem'
548                         echo ' ' | losetup -E 19 -e ucl-0 -p0 "${NEW_ROOT}/dev/loop0" "${NEW_ROOT}/mnt/cdrom/${LOOPEXT}${LOOP}"
549                         test_success 'losetup the loop device'
550
551                         mount -t ext2 -o ro "${NEW_ROOT}/dev/loop0" "${NEW_ROOT}/mnt/livecd"
552                         test_success 'Mount the losetup loop device'
553                         FS_LOCATION='mnt/livecd'
554                 elif [ "${LOOPTYPE}" = 'zisofs' ]
555                 then
556                         FS_LOCATION="mnt/cdrom/${LOOPEXT}${LOOP}"
557                 elif [ "${LOOPTYPE}" = 'noloop' ]
558                 then
559                         FS_LOCATION='mnt/cdrom'
560                 elif [ "${LOOPTYPE}" = 'sgimips' ]
561                 then
562                         # getdvhoff finds the starting offset (in bytes) of the squashfs
563                         # partition on the cdrom and returns this offset for losetup
564                         #
565                         # All currently supported SGI Systems use SCSI CD-ROMs, so
566                         # so we know that the CD-ROM is usually going to be /dev/sr0.
567                         #
568                         # We use the value given to losetup to set /dev/loop0 to point
569                         # to the liveCD root partition, and then mount /dev/loop0 as
570                         # the LiveCD rootfs
571                         good_msg 'Locating the SGI LiveCD Root Partition'
572                         echo ' ' | \
573                                 losetup -o $(getdvhoff "${NEW_ROOT}${REAL_ROOT}" 0) \
574                                         "${NEW_ROOT}${CDROOT_DEV}" \
575                                         "${NEW_ROOT}${REAL_ROOT}"
576                         test_success 'losetup /dev/sr0 /dev/loop0'
577         
578                         good_msg 'Mounting the Root Partition'
579                         mount -t squashfs -o ro "${NEW_ROOT}${CDROOT_DEV}" "${NEW_ROOT}/mnt/livecd"
580                         test_success 'mount /dev/loop0 /'
581                         FS_LOCATION='mnt/livecd'
582                 fi
583         fi
584
585
586
587         # Unpacking additional packages from NFS mount
588         # This is useful for adding kernel modules to /lib
589         # We do this now, so that additional packages can add whereever they want.
590         if [ "${REAL_ROOT}" = '/dev/nfs' ]
591         then
592                 if [ -e "${NEW_ROOT}/mnt/cdrom/add" ]
593                 then
594                                 for targz in `ls ${NEW_ROOT}/mnt/cdrom/add/*.tar.gz`
595                                 do      
596                                         tarname=`basename ${targz}`
597                                         good_msg "Adding additional package ${tarname}"
598                                         (cd ${NEW_ROOT} ; /bin/tar -xzf ${targz})
599                                 done
600                 fi
601         fi
602
603
604         if [ "${USE_UNIONFS_NORMAL}" = '1' ]
605         then
606                 setup_unionfs ${NEW_ROOT} ${NEW_ROOT}/${FS_LOCATION}
607                 CHROOT=/union
608         else
609         
610         good_msg "Copying read-write image contents to tmpfs"
611         # Copy over stuff that should be writable
612         (cd "${NEW_ROOT}/${FS_LOCATION}"; cp -a ${ROOT_TREES} "${NEW_ROOT}")
613
614         # Now we do the links.
615         for x in ${ROOT_LINKS}
616         do
617                 if [ -L "${NEW_ROOT}/${FS_LOCATION}/${x}" ]
618                 then
619                         ln -s "`readlink ${NEW_ROOT}/${FS_LOCATION}/${x}`" "${x}" 2>/dev/null
620                 else
621                         # List all subdirectories of x
622                         find "${NEW_ROOT}/${FS_LOCATION}/${x}" -type d 2>/dev/null | while read directory
623                         do
624                                 # Strip the prefix of the FS_LOCATION
625                                 directory="${directory#${NEW_ROOT}/${FS_LOCATION}/}"
626
627                                 # Skip this directory if we already linked a parent directory
628                                 if [ "${curent_parrent}" != '' ]; then
629                                         var=`echo "${directory}" | grep "^${curent_parrent}"`
630                                         if [ "${var}" != '' ]; then
631                                                 continue
632                                         fi
633                                 fi
634                                 # Test if the directory exists already
635                                 if [ -e "/${NEW_ROOT}/${directory}" ]
636                                 then
637                                         # It does exist, link all the individual files
638                                         for file in `ls /${NEW_ROOT}/${FS_LOCATION}/${directory}`
639                                         do
640                                         if [ ! -d "/${NEW_ROOT}/${FS_LOCATION}/${directory}/${file}" ] && [ ! -e "${NEW_ROOT}/${directory}/${file}" ]; then
641                                                         ln -s "/${FS_LOCATION}/${directory}/${file}" "${directory}/${file}" 2> /dev/null
642                                                 fi
643                                         done
644                                 else
645                                         # It does not exist, make a link to the livecd
646                                         ln -s "/${FS_LOCATION}/${directory}" "${directory}" 2>/dev/null
647                                         current_parent="${directory}"
648                                 fi
649                         done
650                 fi
651         done
652
653         if [ "${DO_slowusb}" ] || [ "${FORCE_slowusb}" ]
654         then
655                 sleep 10
656         fi
657         mkdir initramfs proc tmp sys 2>/dev/null
658         chmod 1777 tmp
659
660         fi
661
662         #UML=`cat /proc/cpuinfo|grep UML|sed -e 's|model name.*: ||'`
663         #if [ "${UML}" = 'UML' ]
664         #then
665         #       # UML Fixes
666         #       good_msg 'Updating for uml system'
667         #fi
668
669         # Let Init scripts know that we booted from CD
670         export CDBOOT
671         CDBOOT=1
672         check_slowusb
673         if [ "${DO_slowusb}" ] || [ "${FORCE_slowusb}" ]
674         then
675                 sleep 10
676         fi
677 else
678         if [ "${USE_UNIONFS_NORMAL}" = '1' ]
679         then
680                 mkdir /union_changes
681                 mount -t tmpfs tmpfs /union_changes
682                 setup_unionfs /union_changes ${NEW_ROOT}
683                 mkdir -p ${UNION}/tmp/.initrd
684         fi
685 fi
686
687 # Execute script on the cdrom just before boot to update things if necessary
688 cdupdate
689
690 if [ "${SUBDIR}" != '' -a -e "${CHROOT}/${SUBDIR}" ]
691 then
692         good_msg "Entering ${SUBDIR} to boot"
693         CHROOT="${CHROOT}/${SUBDIR}"
694 fi
695
696 verbose_kmsg
697
698 echo -ne "${GOOD}>>${NORMAL}${BOLD} Booting (initramfs)${NORMAL}"
699 if [ ! -e "${CHROOT}/dev/console" ] || [ ! -e "${CHROOT}/dev/null" ]
700 then
701         echo -ne "${BAD}>>${NORMAL}${BOLD} ERROR: your real /dev is missing files required to boot (console and null)${NORMAL}"
702 elif [ -e /etc/initrd.splash -a ! -e "${CHROOT}/dev/tty1" ]
703 then
704         echo -ne "${BAD}>>${NORMAL}${BOLD} ERROR: your real /dev is missing tty1, which is required for splash${NORMAL}"
705 fi
706
707 cd "${CHROOT}"
708 mkdir "${CHROOT}/proc" "${CHROOT}/sys" 2>/dev/null
709 echo -ne "${BOLD}.${NORMAL}"
710 umount /sys || echo '*: Failed to unmount the ramdisk /sys!'
711 umount /proc || echo '*: Failed to unmount the ramdisk /proc!'
712 echo -e "${BOLD}.${NORMAL}"
713
714 exec /sbin/switch_root -c "/dev/console" "${CHROOT}" "${REAL_INIT:-/sbin/init}" "${INIT_OPTS}"
715
716 # If we get here, something bad has happened
717 splash 'verbose'
718
719 echo 'A fatal error has probably occured since /sbin/init did not'
720 echo 'boot correctly. Trying to open a shell...'
721 echo
722 exec /bin/bash
723 exec /bin/sh
724 exec /bin/ash
725 exec sh