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