Merge branch 'master' of git://git.wolf31o2.org/projs/genkernel
[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\=*|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                 do_resume
317         fi
318 fi
319
320 mkdir -p "${NEW_ROOT}"
321 CHROOT="${NEW_ROOT}"
322
323 # Run debug shell if requested
324 rundebugshell
325
326 if [ "${CDROOT}" = '1' ]
327 then
328         good_msg "Making tmpfs for ${NEW_ROOT}"
329         mount -n -t tmpfs tmpfs "${NEW_ROOT}"
330         
331         for i in dev mnt mnt/cdrom mnt/livecd mnt/key tmp tmp/.initrd mnt/gentoo sys
332         do
333                 mkdir -p "${NEW_ROOT}/${i}"
334                 chmod 755 "${NEW_ROOT}/${i}"
335         done
336         [ ! -e "${NEW_ROOT}/dev/null" ] && mknod "${NEW_ROOT}"/dev/null c 1 3
337         [ ! -e "${NEW_ROOT}/dev/console" ] && mknod "${NEW_ROOT}"/dev/console c 5 1
338
339         # For SGI LiveCDs ...
340         if [ "${LOOPTYPE}" = "sgimips" ]
341         then
342                 [ ! -e "${NEW_ROOT}/dev/sr0" ] && mknod "${NEW_ROOT}/dev/sr0" b 11 0
343                 [ ! -e "${NEW_ROOT}/dev/loop0" ] && mknod "${NEW_ROOT}/dev/loop0" b 7 0
344         fi
345
346         # Required for splash to work.  Not an issue with the initrd as this
347         # device isn't created there and is not needed.
348         if [ -e /dev/tty1 ]
349         then
350                 [ ! -e "${NEW_ROOT}/dev/tty1" ] && mknod "${NEW_ROOT}/dev/tty1" c 4 1
351         fi
352
353         if [ "${REAL_ROOT}" != "/dev/nfs" ] && [ "${LOOPTYPE}" != "sgimips" ]
354         then
355                 bootstrapCD
356         fi
357
358         if [ "${REAL_ROOT}" = '' ]
359         then
360                 echo -n -e "${WARN}>>${NORMAL}${BOLD} No bootable medium found. Waiting for new devices"
361                 
362                 COUNTER=0
363                 while [ ${COUNTER} -lt 3 ]; do
364                         sleep 3
365                         echo -n '.'
366                         let COUNTER=${COUNTER}+1
367                 done
368
369                 sleep 1
370                 echo -e "${NORMAL}"
371                 bootstrapCD
372         fi
373
374         if [ "${REAL_ROOT}" = '' ]
375         then
376                 # Undo stuff
377                 umount  "${NEW_ROOT}/dev" 2>/dev/null
378                 umount  "${NEW_ROOT}/sys" 2>/dev/null
379                 umount /sys 2>/dev/null
380
381                 umount  "${NEW_ROOT}"
382                 rm -rf  "${NEW_ROOT}/*"
383
384                 bad_msg 'Could not find CD to boot, something else needed!'
385                 CDROOT=0
386         fi
387 fi
388
389 # Determine root device
390 good_msg 'Determining root device...'
391 while true
392 do
393         while [ "${got_good_root}" != '1' ]
394         do
395                 case "${REAL_ROOT}" in
396                         LABEL\=*|UUID\=*)
397                         
398                                 ROOT_DEV=""
399                                 retval=1
400                                 
401                                 if [ "${retval}" -ne '0' ]; then
402                                         ROOT_DEV=`findfs "${REAL_ROOT}" 2>/dev/null`
403                                         retval=$?
404                                 fi
405                                 
406                                 if [ "$retval" -ne '0' ]; then
407                                         ROOT_DEV=`busybox findfs "${REAL_ROOT}" 2>/dev/null`
408                                         retval=$?
409                                 fi
410                                 
411                                 if [ "${retval}" -ne '0' ]; then
412                                         ROOT_DEV=`blkid -t "${REAL_ROOT}" | cut -d ":" -f 1 2>/dev/null`
413                                         retval=$?
414                                 fi
415                                 
416                                 if [ "${retval}" -eq '0' ] && [ -n "${ROOT_DEV}" ]; then
417                                         good_msg "Detected real_root=${ROOT_DEV}"
418                                         REAL_ROOT="${ROOT_DEV}"
419                                 else
420                                         whereis "REAL_ROOT" "root block device"
421                                         got_good_root=0
422                                         continue
423                                 fi
424                                 ;;
425                 esac
426                                 
427                 if [ "${REAL_ROOT}" = '' ]
428                 then
429                         # No REAL_ROOT determined/specified. Prompt user for root block device.
430                         whereis "REAL_ROOT" "root block device"
431                         got_good_root=0
432
433                 # Check for a block device or /dev/nfs
434                 elif [ -b "${REAL_ROOT}" ] || [ "${REAL_ROOT}" = "/dev/nfs" ]
435                 then
436                         got_good_root=1
437
438                 else
439                         bad_msg "Block device ${REAL_ROOT} is not a valid root device..."
440                         REAL_ROOT=""
441                         got_good_root=0
442                 fi
443         done
444
445
446         if [ "${CDROOT}" = 1 -a "${got_good_root}" = '1' -a "${REAL_ROOT}" != "/dev/nfs" ]
447         then
448                 # CD already mounted; no further checks necessary
449                 break
450         elif [ "${LOOPTYPE}" = "sgimips" ]
451         then
452                 # sgimips mounts the livecd root partition directly
453                 # there is no isofs filesystem to worry about
454                 break
455         else
456                 good_msg "Mounting root..."
457
458                 # Try to mount the device as ${NEW_ROOT}
459                 if [ "${REAL_ROOT}" = '/dev/nfs' ]; then
460                         findnfsmount
461                 else
462                         # mount ro so fsck doesn't barf later
463                         if [ "${REAL_ROOTFLAGS}" = '' ]; then
464                                 mount -o ro ${REAL_ROOT} ${NEW_ROOT}
465                         else
466                                 good_msg "Using mount -o ro,${REAL_ROOTFLAGS}"
467                                 mount -o ro,${REAL_ROOTFLAGS} ${REAL_ROOT} ${NEW_ROOT}
468                         fi
469                 fi
470                 
471                 # If mount is successful break out of the loop 
472                 # else not a good root and start over.
473                 if [ "$?" = '0' ]
474                 then
475                         if [ -d ${NEW_ROOT}/dev -a -x ${NEW_ROOT}/sbin/init ] || [ "${REAL_ROOT}" = "/dev/nfs" ]
476                         then
477                                 break
478                         else
479                                 bad_msg "The filesystem mounted at ${REAL_ROOT} does not appear to be a valid /, try again"
480                                 got_good_root=0
481                                 REAL_ROOT=''
482                         fi
483                 else
484                         bad_msg "Could not mount specified ROOT, try again"
485                         got_good_root=0
486                         REAL_ROOT=''
487                 fi
488         fi
489 done
490 # End determine root device
491
492 #verbose_kmsg
493
494 # If CD root is set determine the looptype to boot
495 if [ "${CDROOT}" = '1' ]
496 then
497         good_msg 'Determining looptype ...'
498         cd "${NEW_ROOT}"
499
500         # Find loop and looptype
501         [ -z "${LOOP}" ] && find_loop
502         [ -z "${LOOPTYPE}" ] && find_looptype
503
504         cache_cd_contents
505
506         # If encrypted, find key and mount, otherwise mount as usual
507         if [ -n "${CRYPT_ROOT}" ]
508         then
509                 CRYPT_ROOT_KEY="$(head -n 1 ${NEW_ROOT}/mnt/cdrom/livecd)"
510                 CRYPT_ROOT='/dev/loop0'
511                 good_msg 'You booted an encrypted livecd' "${CRYPT_SILENT}"
512
513                 losetup /dev/loop0 "${NEW_ROOT}/mnt/cdrom/${LOOPEXT}${LOOP}"
514                 test_success 'Preparing loop filesystem'
515
516                 startLUKS
517
518                 case ${LOOPTYPE} in
519                         normal)
520                                 MOUNTTYPE="ext2"
521                                 ;;
522                         *)
523                                 MOUNTTYPE="${LOOPTYPE}"
524                                 ;;
525                 esac
526                 mount -t "${MOUNTTYPE}" -o ro /dev/mapper/root "${NEW_ROOT}/mnt/livecd"
527                 test_success 'Mount filesystem'
528                 FS_LOCATION='mnt/livecd'
529         # Setup the loopback mounts, if unencrypted
530         else
531                 if [ "${LOOPTYPE}" = 'normal' ]
532                 then
533                         good_msg 'Mounting loop filesystem'
534                         mount -t ext2 -o loop,ro "${NEW_ROOT}/mnt/cdrom/${LOOPEXT}${LOOP}" "${NEW_ROOT}/mnt/livecd"
535                         test_success 'Mount filesystem'
536                         FS_LOCATION='mnt/livecd'
537                 elif [ "${LOOPTYPE}" = 'squashfs' ]
538                 then
539                         good_msg 'Mounting squashfs filesystem'
540                         mount -t squashfs -o loop,ro "${NEW_ROOT}/mnt/cdrom/${LOOPEXT}${LOOP}" "${NEW_ROOT}/mnt/livecd"
541                         test_success 'Mount filesystem'
542                         FS_LOCATION='mnt/livecd'
543                 elif [ "${LOOPTYPE}" = 'gcloop' ]
544                 then
545                         good_msg 'Mounting gcloop filesystem'
546                         echo ' ' | losetup -E 19 -e ucl-0 -p0 "${NEW_ROOT}/dev/loop0" "${NEW_ROOT}/mnt/cdrom/${LOOPEXT}${LOOP}"
547                         test_success 'losetup the loop device'
548
549                         mount -t ext2 -o ro "${NEW_ROOT}/dev/loop0" "${NEW_ROOT}/mnt/livecd"
550                         test_success 'Mount the losetup loop device'
551                         FS_LOCATION='mnt/livecd'
552                 elif [ "${LOOPTYPE}" = 'zisofs' ]
553                 then
554                         FS_LOCATION="mnt/cdrom/${LOOPEXT}${LOOP}"
555                 elif [ "${LOOPTYPE}" = 'noloop' ]
556                 then
557                         FS_LOCATION='mnt/cdrom'
558                 elif [ "${LOOPTYPE}" = 'sgimips' ]
559                 then
560                         # getdvhoff finds the starting offset (in bytes) of the squashfs
561                         # partition on the cdrom and returns this offset for losetup
562                         #
563                         # All currently supported SGI Systems use SCSI CD-ROMs, so
564                         # so we know that the CD-ROM is usually going to be /dev/sr0.
565                         #
566                         # We use the value given to losetup to set /dev/loop0 to point
567                         # to the liveCD root partition, and then mount /dev/loop0 as
568                         # the LiveCD rootfs
569                         good_msg 'Locating the SGI LiveCD Root Partition'
570                         echo ' ' | \
571                                 losetup -o $(getdvhoff "${NEW_ROOT}${REAL_ROOT}" 0) \
572                                         "${NEW_ROOT}${CDROOT_DEV}" \
573                                         "${NEW_ROOT}${REAL_ROOT}"
574                         test_success 'losetup /dev/sr0 /dev/loop0'
575         
576                         good_msg 'Mounting the Root Partition'
577                         mount -t squashfs -o ro "${NEW_ROOT}${CDROOT_DEV}" "${NEW_ROOT}/mnt/livecd"
578                         test_success 'mount /dev/loop0 /'
579                         FS_LOCATION='mnt/livecd'
580                 fi
581         fi
582
583
584
585         # Unpacking additional packages from NFS mount
586         # This is useful for adding kernel modules to /lib
587         # We do this now, so that additional packages can add whereever they want.
588         if [ "${REAL_ROOT}" = '/dev/nfs' ]
589         then
590                 if [ -e "${NEW_ROOT}/mnt/cdrom/add" ]
591                 then
592                                 for targz in `ls ${NEW_ROOT}/mnt/cdrom/add/*.tar.gz`
593                                 do      
594                                         tarname=`basename ${targz}`
595                                         good_msg "Adding additional package ${tarname}"
596                                         (cd ${NEW_ROOT} ; /bin/tar -xzf ${targz})
597                                 done
598                 fi
599         fi
600
601
602         if [ "${USE_UNIONFS_NORMAL}" = '1' ]
603         then
604                 setup_unionfs ${NEW_ROOT} ${NEW_ROOT}/${FS_LOCATION}
605                 CHROOT=/union
606         else
607         
608         good_msg "Copying read-write image contents to tmpfs"
609         # Copy over stuff that should be writable
610         (cd "${NEW_ROOT}/${FS_LOCATION}"; cp -a ${ROOT_TREES} "${NEW_ROOT}")
611
612         # Now we do the links.
613         for x in ${ROOT_LINKS}
614         do
615                 if [ -L "${NEW_ROOT}/${FS_LOCATION}/${x}" ]
616                 then
617                         ln -s "`readlink ${NEW_ROOT}/${FS_LOCATION}/${x}`" "${x}" 2>/dev/null
618                 else
619                         # List all subdirectories of x
620                         find "${NEW_ROOT}/${FS_LOCATION}/${x}" -type d 2>/dev/null | while read directory
621                         do
622                                 # Strip the prefix of the FS_LOCATION
623                                 directory="${directory#${NEW_ROOT}/${FS_LOCATION}/}"
624
625                                 # Skip this directory if we already linked a parent directory
626                                 if [ "${curent_parrent}" != '' ]; then
627                                         var=`echo "${directory}" | grep "^${curent_parrent}"`
628                                         if [ "${var}" != '' ]; then
629                                                 continue
630                                         fi
631                                 fi
632                                 # Test if the directory exists already
633                                 if [ -e "/${NEW_ROOT}/${directory}" ]
634                                 then
635                                         # It does exist, link all the individual files
636                                         for file in `ls /${NEW_ROOT}/${FS_LOCATION}/${directory}`
637                                         do
638                                         if [ ! -d "/${NEW_ROOT}/${FS_LOCATION}/${directory}/${file}" ] && [ ! -e "${NEW_ROOT}/${directory}/${file}" ]; then
639                                                         ln -s "/${FS_LOCATION}/${directory}/${file}" "${directory}/${file}" 2> /dev/null
640                                                 fi
641                                         done
642                                 else
643                                         # It does not exist, make a link to the livecd
644                                         ln -s "/${FS_LOCATION}/${directory}" "${directory}" 2>/dev/null
645                                         current_parent="${directory}"
646                                 fi
647                         done
648                 fi
649         done
650
651         if [ "${DO_slowusb}" ] || [ "${FORCE_slowusb}" ]
652         then
653                 sleep 10
654         fi
655         mkdir initramfs proc tmp sys 2>/dev/null
656         chmod 1777 tmp
657
658         fi
659
660         #UML=`cat /proc/cpuinfo|grep UML|sed -e 's|model name.*: ||'`
661         #if [ "${UML}" = 'UML' ]
662         #then
663         #       # UML Fixes
664         #       good_msg 'Updating for uml system'
665         #fi
666
667         # Let Init scripts know that we booted from CD
668         export CDBOOT
669         CDBOOT=1
670         check_slowusb
671         if [ "${DO_slowusb}" ] || [ "${FORCE_slowusb}" ]
672         then
673                 sleep 10
674         fi
675 else
676         if [ "${USE_UNIONFS_NORMAL}" = '1' ]
677         then
678                 mkdir /union_changes
679                 mount -t tmpfs tmpfs /union_changes
680                 setup_unionfs /union_changes ${NEW_ROOT}
681                 mkdir -p ${UNION}/tmp/.initrd
682         fi
683 fi
684
685 # Execute script on the cdrom just before boot to update things if necessary
686 cdupdate
687
688 if [ "${SUBDIR}" != '' -a -e "${CHROOT}/${SUBDIR}" ]
689 then
690         good_msg "Entering ${SUBDIR} to boot"
691         CHROOT="${CHROOT}/${SUBDIR}"
692 fi
693
694 verbose_kmsg
695
696 echo -ne "${GOOD}>>${NORMAL}${BOLD} Booting (initramfs)${NORMAL}"
697 if [ ! -e "${CHROOT}/dev/console" ] || [ ! -e "${CHROOT}/dev/null" ]
698 then
699         echo -ne "${BAD}>>${NORMAL}${BOLD} ERROR: your real /dev is missing files required to boot (console and null)${NORMAL}"
700 elif [ -e /etc/initrd.splash -a ! -e "${CHROOT}/dev/tty1" ]
701 then
702         echo -ne "${BAD}>>${NORMAL}${BOLD} ERROR: your real /dev is missing tty1, which is required for splash${NORMAL}"
703 fi
704
705 cd "${CHROOT}"
706 mkdir "${CHROOT}/proc" "${CHROOT}/sys" 2>/dev/null
707 echo -ne "${BOLD}.${NORMAL}"
708 umount /sys || echo '*: Failed to unmount the ramdisk /sys!'
709 umount /proc || echo '*: Failed to unmount the ramdisk /proc!'
710 echo -e "${BOLD}.${NORMAL}"
711
712 exec /sbin/switch_root -c "/dev/console" "${CHROOT}" "${REAL_INIT:-/sbin/init}" "${INIT_OPTS}"
713
714 # If we get here, something bad has happened
715 splash 'verbose'
716
717 echo 'A fatal error has probably occured since /sbin/init did not'
718 echo 'boot correctly. Trying to open a shell...'
719 echo
720 exec /bin/bash
721 exec /bin/sh
722 exec /bin/ash
723 exec sh