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