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