3 # /etc/rc.d/rc.sysinit - run once at boot time
6 # Taken in part from Miquel van Smoorenburg's bcheckrc.
9 # reasonable start values for bootsplash progress.
15 if [ -r /etc/sysconfig/i18n ]; then
17 [ -n "$LANG" ] && export LANG || unset LANG
18 [ -n "$LC_CTYPE" ] && export LC_CTYPE || unset LC_CTYPE
19 [ -n "$LC_COLLATE" ] && export LC_COLLATE || unset LC_COLLATE
20 [ -n "$LC_MESSAGES" ] && export LC_MESSAGES || unset LC_MESSAGES
21 [ -n "$LC_NUMERIC" ] && export LC_NUMERIC || unset LC_NUMERIC
22 [ -n "$LC_MONETARY" ] && export LC_MONETARY || unset LC_MONETARY
23 [ -n "$LC_TIME" ] && export LC_TIME || unset LC_TIME
24 [ -n "$LC_ALL" ] && export LC_ALL || unset LC_ALL
25 [ -n "$LANGUAGE" ] && export LANGUAGE || unset LANGUAGE
26 [ -n "$LINGUAS" ] && export LINGUAS || unset LINGUAS
29 # Read network config data
30 if [ -r /etc/sysconfig/network ]; then
31 . /etc/sysconfig/network
40 . /lib/rc-scripts/functions
44 if [ "$modprobe_c_cache" ]; then
45 echo "$modprobe_c_cache"
48 modprobe_c_cache=$(modprobe -c)
51 # parse kernel cmdline
54 read cmdline < /proc/cmdline
57 for arg in $cmdline; do
60 # default is set in /etc/sysconfig/system or detected in init.d/functions
64 # default is set in /etc/sysconfig/system
68 # default is set in /etc/sysconfig/system
97 local _d selinuxfs _t _r
99 while read _d selinuxfs _t _r; do
100 [ "$_t" = "selinuxfs" ] && break
102 echo "*** Warning -- SELinux is active"
103 echo "*** Disabling security enforcement for system recovery."
104 echo "*** Run 'setenforce 1' to reenable."
105 echo "0" > $selinuxfs/enforce
109 local _d selinuxfs _t _r
111 while read _d selinuxfs _t _r; do
112 [ "$_t" = "selinuxfs" ] && break
115 *** Warning -- SELinux relabel is required. ***
116 *** Disabling security enforcement. ***
117 *** Relabeling could take a very long time, ***
118 *** depending on file system size. ***
120 echo "0" > $selinuxfs/enforce
121 /sbin/fixfiles -F relabel > /dev/null 2>&1
123 echo "*** Enabling security enforcement. ***"
124 echo $SELINUX > $selinuxfs/enforce
127 # Remove duplicate entries from mtab (for vserver guest use only)
128 clean_vserver_mtab() {
130 while read device mountpoint line; do
131 grep -qs "$mountpoint" /etc/mtab.clean || \
132 echo "$device $mountpoint $line" >> /etc/mtab.clean
134 cat /etc/mtab.clean > /etc/mtab
135 rm -f /etc/mtab.clean
138 # Loads modules from /etc/modules, /etc/modules.X.Y and /etc/modules.X.Y.Z
139 load_kernel_modules() {
140 local modules_file=$1
141 local _x _y _z v v1 old_IFS kernel kerneleq
145 # strip _* or -* from versions like: "2.6.25_vanilla-1", "2.6.25-1"
158 # Loop over every line in modules file
160 grep -hvE '^(#|[[:blank:]]*$)' /etc/$modules_file /etc/$modules_file.$kernel /etc/$modules_file.$kerneleq 2>/dev/null
161 echo '' # make sure there is a LF at the end
162 ) | while read module args; do
163 [ -z "$module" ] && continue
166 show "Loading %s kernel module(s)" "$module"
168 modprobe -s $module -- $args && ok || fail
172 # launch repair shell
173 # which after exiting will reboot
177 # don't use '\n' in nls macro !
181 nls "*** Dropping you to a shell; the system will reboot"
182 nls "*** when you leave the shell."
185 [ "$SELINUX" = "1" ] && disable_selinux
186 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
192 run_cmd "Unmounting file systems" umount -a
193 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
194 run_cmd "Automatic reboot in progress" reboot
198 show "Checking root filesystem"; started
199 initlog -c "fsck -C -T -a $fsckoptions /"
202 # A return of 4 or higher means there were serious problems.
203 if [ $rc -gt 3 ]; then
204 [ -e /proc/splash ] && echo "verbose" > /proc/splash
206 PS1="$(nls '(Repair filesystem)# ')"; export PS1
207 repair_shell "$(nls '*** An error occurred during the file system check.')"
209 # A return of 2 or 3 means that filesystem was repaired but we need
211 elif [ "$rc" = "2" -o "$rc" = "3" ]; then
212 [ -e /proc/splash ] && echo "verbose" > /proc/splash
214 nls "*** Filesystem was repaired but system needs to be"
215 nls "*** rebooted before mounting it."
216 nls "*** REBOOTING ***"
219 run_cmd "Unmounting file systems" umount -a
220 mount -n -o remount,ro /
221 run_cmd "Automatic reboot in progress" reboot
222 elif [ "$rc" = "1" ]; then
227 # boot logging to /var/log/boot.log. install showconsole package to get it.
228 if ! is_no "$RC_BOOTLOG" && [ -x /sbin/blogd ]; then
234 if ! is_yes "$VSERVER"; then
235 # we need /proc mounted before everything
236 is_fsmounted proc /proc || mount -n /proc || mount -n -o gid=17,hidepid=2 -t proc /proc /proc
241 is_fsmounted tmpfs /run || mount -n -t tmpfs run /run
245 sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
247 # sysfs is also needed before any other things (under kernel > 2.5)
248 if grep -q sysfs /proc/filesystems 2>/dev/null; then
249 is_fsmounted sysfs /sys || mount -n -o gid=17 -t sysfs sysfs /sys
250 if grep -q securityfs /proc/filesystems 2>/dev/null; then
251 mount -n -o gid=17 -t securityfs securityfs /sys/kernel/security
256 if grep -q selinuxfs /proc/filesystems 2>/dev/null && ! is_fsmounted selinuxfs /selinux; then
257 mount -n -o gid=17 -t selinuxfs selinuxfs /selinux
260 # PLD Linux LiveCD support
261 if [ -x /etc/rc.d/rc.live ]; then
265 # Choose Hardware profile
266 if [ -f /etc/sysconfig/hwprof ]; then
267 . /etc/sysconfig/hwprof
268 if is_yes "${HWPROFILES}" && [ -x /sbin/hwprofile -a -d /etc/sysconfig/hwprofiles/data ]; then
269 mount -n / -o rw,remount
271 mount -n / -o ro,remount
275 # Disable splash when requested
276 is_no "$BOOT_SPLASH" && [ -e /proc/splash ] && echo "0" > /proc/splash
278 # Check SELinux status
279 selinuxfs=$(awk '/ selinuxfs / { print $2 }' /proc/mounts 2> /dev/null)
281 if [ -n "$selinuxfs" ] && [ "$(cat /proc/self/attr/current)" != "kernel" ]; then
282 if [ -r $selinuxfs/enforce ] ; then
283 SELINUX=$(cat $selinuxfs/enforce)
285 # assume enforcing if you can't read it
290 if [ -x /sbin/restorecon ] && is_fsmounted tmpfs /dev; then
291 /sbin/restorecon -R /dev 2>/dev/null
294 [ -z "${CONSOLETYPE}" ] && CONSOLETYPE="$(/sbin/consoletype)"
296 if [ "$CONSOLETYPE" = "vt" -a -x /sbin/setsysfont ]; then
302 # Print welcome message
303 nls "\t\t\t%sPowered by %sPLD Linux Distribution%s" "$(termput setaf $CPOWEREDBY)" "$(termput setaf $CPLD)" "$(termput op)"
304 if ! is_no "$RC_PROMPT"; then
305 nls -n "\t\t Press %sI%s to enter interactive startup" "$(termput setaf $CI)" "$(termput op)"
310 if [ -z "${HOSTNAME}" ]; then
311 show "$(nls 'Host:') $(hostname)"; ok
313 run_cmd "$(nls 'Host:') ${HOSTNAME}" hostname ${HOSTNAME}
316 # Set the NIS domain name
317 if [ -n "$NISDOMAIN" ]; then
318 run_cmd "$(nls 'NIS Domain:') ${NISDOMAIN}" domainname $NISDOMAIN
323 if ! is_yes "$VSERVER"; then
324 # Set console loglevel
325 if [ -n "$CONSOLE_LOGLEVEL" ]; then
326 dmesg -n $CONSOLE_LOGLEVEL
329 if ! is_no "$START_UDEV" && [ -x /sbin/start_udev ] && [[ "$container" != lxc* ]]; then
330 is_fsmounted devtmpfs /dev || mount -n -t devtmpfs devtmpfs /dev
331 load_kernel_modules modules.preudev
333 use_upstart && [ -x /sbin/initctl ] && /sbin/initctl -q start udev
334 elif [ -x /lib/firmware/firmware-loader.sh ]; then
335 /sbin/sysctl -e -w kernel.hotplug=/lib/firmware/firmware-loader.sh > /dev/null 2>&1
338 # Unmount the initrd, if necessary
339 if grep -q /initrd /proc/mounts 2>/dev/null && ! grep -q /initrd/loopfs /proc/mounts 2>/dev/null; then
340 umount /initrd/dev 2>/dev/null
342 /sbin/blockdev --flushbufs /dev/ram0 >/dev/null 2>&1
345 # Start logging console output since we have all /dev stuff setup
346 if [ "$RC_BOOTLOG" ]; then
350 # Configure Linux kernel (initial configuration, some required modules still
352 sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
354 # Check if timezone definition is available
355 if [ -e /etc/localtime ] && [ -e /dev/rtc -o -e /dev/rtc0 ] ; then
356 if run_cmd "$(nls 'Setting clock')" hwclock --hctosys; then
357 show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
360 TIME_SETUP_DELAYED=yes
364 if [ -f /etc/crypttab ] && ! is_empty_file /etc/crypttab; then
365 # XXX might need modules dep
366 # Device mapper & related initialization
367 if ! grep -qF device-mapper /proc/devices; then
371 . /etc/rc.d/init.d/cryptsetup
372 show "Starting disk encryption"
375 [ $delay_cryptsetup = 0 ] && ok || fail
379 run_cmd "Activating swap partitions" swapon -a -e
381 # Initialize USB controllers
383 if [ -z "$nousb" ] && ! is_fsmounted usbfs /proc/bus/usb; then
384 aliases=$(modprobe_c | awk '/^alias[\t ]+usb-controller/ { print $3 }')
385 if [ -n "$aliases" -a "$aliases" != "off" ] ; then
387 for alias in $aliases ; do
388 [ "$alias" = "off" ] && continue
389 run_cmd "$(nls 'Initializing USB controller') ($alias)" modprobe -s $alias
391 [ $? -eq 0 -a -n "$aliases" ] && usb=1
393 if grep -iq "usb" /proc/devices 2>/dev/null ; then
398 if [ "$usb" = "1" -a -d /proc/bus/usb ] && ! is_fsmounted usbfs /proc/bus/usb ; then
399 run_cmd "Mounting USB filesystem" mount -n -t usbfs -o devgid=78,devmode=664 usbfs /proc/bus/usb
403 if [ "$usb" = "1" ]; then
404 needusbstorage=$(cat /proc/bus/usb/devices 2>/dev/null | grep -e "^I.*Cls=08" 2>/dev/null)
405 if [ "$(kernelverser)" -lt "002006" ]; then
406 grep -Fq 'hid' /proc/bus/usb/drivers 2>/dev/null || run_cmd "Initializing USB HID interface" modprobe -s hid
407 mouseoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=02" 2>/dev/null)
408 kbdoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=01" 2>/dev/null)
409 if [ -n "$kbdoutput" ]; then
410 run_cmd "Initializing USB keyboard" modprobe -s keybdev
412 if [ -n "$mouseoutput" ]; then
413 run_cmd "Initializing USB mouse" modprobe -s mousedev
418 # Setup hdparm thing (if exists and is needed)
419 if [ -z "$nohdparm" ]; then
420 [ -x /etc/rc.d/rc.hdparm ] && /etc/rc.d/rc.hdparm
423 if [ -z "$fastboot" ] && [ -f /fastboot ]; then
427 if [ -f /fsckoptions ]; then
428 fsckoptions=$(cat /fsckoptions)
433 if [ -f /forcefsck ]; then
434 fsckoptions="-f $fsckoptions"
436 # Obey the fs_passno setting for / (see fstab(5))
438 # - make sure we have at least 6 fields
439 _ROOTFS_PASSNO=$(awk '($1 !~ /^#/ && $2 == "/" && NF >= 6) { print $6}' /etc/fstab)
443 _ROOTFS_DEVICE=$(awk '($1 !~ /^#/ && $2 == "/" && NF >= 6) { print $1}' /etc/fstab)
444 _ROOTFS_TYPE=$(awk '$2 == "/" && $3 != "rootfs" { print $3 }' /proc/mounts 2>/dev/null)
446 if [ -z "$fastboot" -a "$_ROOTFS_TYPE" != "aufs" -a "$_ROOTFS_TYPE" != "nfs" -a "$_ROOTFS_TYPE" != "romfs" -a "$_ROOTFS_TYPE" != "squashfs" -a "$_ROOTFS_PASSNO" != 0 -a -e $_ROOTFS_DEVICE ] && [[ "$container" != lxc* ]]; then
450 # set up pnp and kernel pnp
451 if is_yes "$RUN_USERPNP" || is_yes "$RUN_KERNELPNP"; then
452 if [ -z "$nopnp" ] && is_yes "$RUN_USERPNP" && [ -x /sbin/isapnp -a -f /etc/isapnp/isapnp.conf ]; then
453 run_cmd "Setting up ISA PNP devices (userspace pnp)" /sbin/isapnp /etc/isapnp/isapnp.conf
455 if [ -z "$nopnp" ] && is_yes "$RUN_KERNELPNP"; then
457 if [ -e /proc/isapnp -a -f /etc/isapnp/isapnp-kernel.conf ]; then
458 show "Setting up ISA PNP devices (kernelspace pnp)"; busy
459 grep -v "^#" /etc/isapnp/isapnp-kernel.conf 2>/dev/null >/proc/isapnp && (deltext; ok) || (deltext; fail)
464 _ROOTFS_RO=$(awk '($1 !~ /^#/ && $2 == "/" && ($4 == "ro" || $4 ~ /,ro$/ || $4 ~ /^ro,/ || $4 ~ /,ro,/ ) && NF >= 6) { print "ro" }' /etc/fstab)
465 # Remount the root filesystem read-write
466 if [ -z "$_ROOTFS_RO" ]; then
467 run_cmd "Remounting root filesystem in rw mode" mount -n -o remount,rw /
470 # Update quotas if fsck was run on /
471 if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then
472 run_cmd "Checking root filesystem quotas" /sbin/quotacheck -vnug /
475 # Clean up SELinux labels
476 if [ -n "$SELINUX" ]; then
477 for file in /etc/mtab /etc/cryptomtab /etc/ld.so.cache; do
478 [ -r $file ] && restorecon $file >/dev/null 2>&1
482 if [ "$delay_cryptsetup" != 0 ]; then
483 show "Starting disk encryption using the RNG"
486 [ $delay_cryptsetup = 0 ] && ok || fail
489 # Start logging console output since we have all /dev stuff setup
490 if [ "$RC_BOOTLOG" ]; then
495 # Remove stale backups
496 rm -f /etc/mtab~ /etc/mtab~~ /etc/cryptomtab~ /etc/cryptomtab~~ >/dev/null 2>&1
498 # Remove /etc/nologin when starting system
499 [ -f /etc/nologin.boot ] && rm -f /etc/nologin /etc/nologin.boot
501 if ! is_no "$DELAY_LOGIN" && [ ! -f /etc/nologin ]; then
502 show "Enabling Delay Login"; busy
504 nls "System bootup in progress - please wait" >> /etc/nologin
506 chmod 644 /etc/nologin
507 cp -fp /etc/nologin /etc/nologin.boot
511 # The root filesystem is now read-write, so we can now log via
512 # syslog() directly...
513 if [ -n "$IN_INITLOG" ]; then
517 if ! is_yes "$VSERVER"; then
520 [ -f /etc/cryptomtab ] && > /etc/cryptomtab
522 # Enter root, /proc, /sys and other into mtab.
523 mount -f / 2> /dev/null
524 mount -f /proc 2> /dev/null
525 if is_fsmounted devtmpfs /dev; then
526 mount -f -t devtmpfs devtmpfs /dev 2> /dev/null
528 if is_fsmounted tmpfs /run; then
529 mount -f -t tmpfs run /run 2> /dev/null
532 if is_fsmounted usbfs /proc/bus/usb; then
533 mount -f -t usbfs -o devgid=78,devmode=664 usbfs /proc/bus/usb 2> /dev/null
536 if is_fsmounted sysfs /sys; then
537 mount -f -t sysfs sysfs /sys 2> /dev/null
538 if is_fsmounted securityfs /sys/kernel/security ; then
539 mount -f -t securityfs securityfs /sys/kernel/security 2> /dev/null
543 if is_fsmounted selinuxfs /selinux; then
544 mount -f -t selinuxfs selinuxfs /selinux 2> /dev/null
547 emit --no-wait root-filesystem
548 emit --no-wait virtual-filesystems
550 if [ ! -f /proc/modules ]; then
552 elif [ -z "$nomodules" ]; then
559 # Adjust symlinks as necessary in /boot to keep system services from
560 # spewing messages about mismatched System maps and so on.
561 if ! is_no "$SET_SLINKS"; then
562 if [ -L /boot/System.map -a -r /boot/System.map-$uname_r ] ; then
563 ln -s -f System.map-$uname_r /boot/System.map
565 if [ ! -e /boot/System.map -a -r /boot/System.map-$uname_r ] ; then
566 ln -s -f System.map-$uname_r /boot/System.map
570 # Run depmod if RUN_DEPMOD != "no" and:
571 # a) user requested or RUN_DEPMOD="";
572 # b) modules.dep is missing
573 if ! is_no "$RUN_DEPMOD" && [ -n "$USEMODULES" ]; then
574 if is_yes "$RUN_DEPMOD" || [ -z "$RUN_DEPMOD" ]; then
575 run_cmd "Finding module dependencies" depmod -a
576 elif [ "$RUN_DEPMOD" = "ifmissing" ] && [ ! -f /lib/modules/$uname_r/modules.dep ]; then
577 run_cmd "Finding module dependencies" depmod -A
582 if [ -f /proc/sys/kernel/modprobe ]; then
583 if [ -n "$USEMODULES" ]; then
584 sysctl -w kernel.modprobe="/sbin/modprobe" >/dev/null 2>&1
586 # We used to set this to NULL, but that causes
587 # 'failed to exec' messages"
588 sysctl -w kernel.modprobe="/bin/true" >/dev/null 2>&1
592 # Load usb storage here, to match most other things
593 if [ -n "$needusbstorage" ]; then
594 modprobe -s usb-storage
597 # Load firewire devices
598 if [ -z "$nofirewire" ]; then
599 aliases=$(modprobe_c | awk '/^alias ieee1394-controller/ { print $3 }')
600 if [ -n "$aliases" -a "$aliases" != "off" ] ; then
601 for alias in $aliases ; do
602 [ "$alias" = "off" ] && continue
603 run_cmd "$(nls 'Initializing firewire controller') ($alias)" modprobe $alias
605 grep -E "SBP2" /proc/bus/ieee1394/devices 2>/dev/null && modprobe -s sbp2
609 # Load sound modules if they need persistent DMA buffers
610 if modprobe_c | grep -q "^options sound dmabuf=1"; then
612 alias=$(modprobe_c | grep -sE "^alias[[:space:]]+sound[[:space:]]+" 2>/dev/null | awk '{ print $3 }')
613 if [ -n "$alias" -a "$alias" != "off" ] ; then
614 run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias
617 alias=$(modprobe_c | grep -sE "^alias[[:space:]]+sound-slot-0[[:space:]]+" 2>/dev/null | awk '{ print $3 }')
618 if [ -n "$alias" -a "$alias" != "off" ] ; then
619 run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias
625 if ! use_upstart; then
626 load_kernel_modules modules
627 for f in /etc/modules-load.d/*.conf; do
628 # already loaded by implicit "modules" load
629 [ "${f##*/}" = "modules.conf" ] && continue
631 [ -r $f ] || continue
632 load_kernel_modules ${f##/etc/}
636 if ! is_no "$DM_MULTIPATH" [ -x /sbin/multipath ]; then
637 # first make nodes that were discarded due (possible) new /dev mount
639 /sbin/dmsetup mknodes
640 modprobe -s dm-multipath
641 run_cmd "Activating dm-multipath" /sbin/multipath -v 0
642 /sbin/dmsetup ls --target multipath --exec '/sbin/kpartx -a -p p'
645 if ! is_no "$DMRAID" && [ -x /sbin/dmraid ]; then
646 run_cmd "Activating ATARAID devices" /sbin/dmraid -ay
649 # Find and activate volume groups:
651 if is_yes "$EVMS_LVM" && [ -x /sbin/evms_activate ]; then
652 if [ "$(kernelverser)" -lt "002006" ]; then
653 # Linux 2.4 core modules
655 modprobe -s evms_passthru
659 # Linux 2.6 core module
663 is_yes "$EVMS_GUID_PTABLE" && modprobe -s gpt_part
664 is_yes "$EVMS_LVM" && modprobe -s lvm_vge
665 is_yes "$EVMS_AIX" && modprobe -s AIXlvm_vge
666 is_yes "$EVMS_OS2" && modprobe -s os2lvm_vge
667 run_cmd "Discovering EVMS volumes" /sbin/evms_activate
668 if is_yes "$EVMS_LVM" && is_yes "$EVMS_LVM_COMPAT_NODES" ; then
669 # Link nodes for compatibility with LVM
670 if [ "$(echo /dev/evms/lvm/*)" != '/dev/evms/lvm/*' ] ; then
671 ln -s /dev/evms/lvm/* /dev
676 # LVM (keep in sync with LVM starting after RAID run!)
677 if ! is_no "$LVM2" && [ -x /sbin/vgscan -a -x /sbin/vgchange ] || is_yes "$EVMS_LVM"; then
678 if is_no "$LVM2"; then
679 lvmversion=$(LC_ALL=C /sbin/vgchange --version 2>/dev/null | awk '/LVM version:/{if ($3 >= 2) print "2"}')
683 if [ "$lvmversion" = "1" ] ; then
687 elif [ "$lvmversion" = "2" ] ; then
689 lvmignorelocking="--ignorelockingfailure"
690 lvmsysinit="--sysinit"
693 # device mapper (2.5+ and patched 2.4)
699 run_cmd "Scanning for LVM volume groups" /sbin/vgscan $lvmignorelocking
700 run_cmd "Activating LVM volume groups" /sbin/vgchange -a y $lvmsysinit
701 if [ "$lvmversion" = "2" ]; then
702 /sbin/vgmknodes $lvmignorelocking
703 # display VG statistics
704 /sbin/vgdisplay -s $lvmignorelocking
708 if [ "$delay_cryptsetup" != 0 ]; then
709 show "Starting disk encryption"
712 [ $delay_cryptsetup = 0 ] && ok || fail
716 if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ]; then
718 if [ -f /proc/mdstat ]; then
721 if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ]; then
722 if grep -qE "^([[:blank:]]|)ARRAY[[:blank:]]" /etc/mdadm.conf 2>/dev/null; then
723 show "Starting up RAID devices"; busy
724 /sbin/mdadm --assemble --scan --auto=yes
726 if [ "$rc" -eq 0 -o "$rc" -eq 2 ]; then
727 # rc is used later, too so set sane value
738 # A non-zero return means there were problems
739 if [ $rc -gt 0 ]; then
740 [ -e /proc/splash ] && echo "verbose" > /proc/splash
741 show "Starting up RAID devices"; fail
743 PS1="$(nls '(RAID Repair)# ')"; export PS1
744 repair_shell "$(nls '*** An error occurred during the RAID startup.')"
746 # LVM on RAID (keep in sync with LVM setting few lines above)
747 if [ "$golvm" -eq "1" ]; then
748 if [ -x /sbin/vgscan -a -x /sbin/vgchange ]; then
749 run_cmd "Scanning for LVM volume groups (on RAID)" /sbin/vgscan $lvmignorelocking
750 run_cmd "Activating LVM volume groups (on RAID)" /sbin/vgchange -a y $lvmsysinit
751 [ "$lvmversion" = "2" ] && /sbin/vgmknodes
754 show "Starting up RAID devices"; ok
760 if [ -z "$fastboot" ] && [ -z "$nofsck" ]; then
761 rc_splash "fsck start"
762 show "Checking filesystems"; started
763 initlog -c "fsck -C -T -R -A -a -P $fsckoptions"
767 # A return of 2 or higher means there were serious problems
768 if [ $rc -gt 1 ]; then
769 [ -e /proc/splash ] && echo "verbose" > /proc/splash
771 PS1="$(nls '(Repair filesystem)# ')"; export PS1
772 repair_shell "$(nls '*** An error occurred during the file system check.')"
774 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
777 rc_splash "fsck stop"
780 # Mount all other filesystems (except for NFS and /proc, which is already
781 # mounted). Contrary to standard usage,
782 # filesystems are NOT unmounted in single user mode.
784 run_cmd "Mounting local filesystems" mount -a -t nonfs,nfs4,smbfs,ncpfs,proc,cifs -O no_netdev
786 # now we have /usr mounted, recheck if we have gettext and tput available.
787 if is_no "$TPUT"; then
793 # Now do some workaround - encrypted filesystems couldn't have been fsck-ed
794 # before mount - that's where the password is entered.
795 # mount is buggy - when remounting loopback filesystem, loop=XXX
796 # option is removed from /etc/mtab
797 if [ -z "$fastboot" ] && grep "^[^#].*encryption=" /etc/fstab 2>/dev/null | grep -v -q "noauto" 2>/dev/null; then
798 show "Checking encrypted filesystems"; started
799 LOOPLIST="$(LC_ALL=C awk '
800 FILENAME=="/proc/mounts" {
803 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && /[^a-zA-Z_]ro[^a-zA-Z_]/ {
804 if ($2 in TAB){print TAB[$2];}
806 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ {
807 if ($2 in TAB){print TAB[$2];}
808 sub("loop(=[^,]*)?","loop=" TAB[$2] ",ro",$4);
809 cmd="mount " $2 " -o remount," $4;
812 ' /proc/mounts /etc/fstab)"
813 initlog -c "fsck -T -C -a $fsckoptions $LOOPLIST"
816 # A return of 2 or higher means there were serious problems.
817 if [ $rc -gt 1 ]; then
818 [ -e /proc/splash ] && echo "verbose" > /proc/splash
820 PS1="$(nls '(Repair filesystem)# ')"; export PS1
821 repair_shell "$(nls '*** An error occurred during the file system check.')"
823 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
827 show "Remounting encrypted filesystems back in rw mode"; busy
829 FILENAME=="/proc/mounts" {
832 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ {
833 sub("loop(=[^,]*)?","loop=" TAB[$2] ",rw",$4);
834 cmd="mount " $2 " -o remount," $4;
837 ' /proc/mounts /etc/fstab
841 # /var/log should be writable now, so start saving the boot output
842 if [ "$RC_BOOTLOG" ]; then
843 echo > /var/log/boot.log
847 if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then
848 run_cmd "Checking filesystem quotas" /sbin/quotacheck -vnugRa
852 if [ -x /sbin/quotaon ]; then
853 run_cmd "Turning on quotas for local filesystems" /sbin/quotaon -aug
856 emit --no-wait local-filesystems
858 # FIXME: this should be delayed until remote filesystems are mounted,
859 # especialy when /usr or other standard fs is remote
860 emit --no-wait filesystem
862 # Turn on process accounting
863 if [ -x /etc/rc.d/rc.acct ]; then
864 /etc/rc.d/rc.acct start
867 # Set the clock if timezone definition wasn't available (eg. /usr not mounted)
868 if is_yes "$TIME_SETUP_DELAYED" && [ -e /dev/rtc -o -e /dev/rtc0 ]; then
869 if run_cmd "$(nls 'Setting clock')" hwclock --hctosys; then
870 show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
874 # Initialize the serial ports
875 if [ -f /etc/rc.d/rc.serial ]; then
876 . /etc/rc.d/rc.serial
879 if [ -n "$PANIC_REBOOT_TIME" -a "$PANIC_REBOOT_TIME" -gt "0" -a -f /proc/sys/kernel/panic ]; then
880 show 'Setting %s seconds for kernel reboot after panic' "$PANIC_REBOOT_TIME"; busy
881 # NOTE: you should use /etc/sysctl.conf instead
882 if sysctl -w kernel.panic=$PANIC_REBOOT_TIME >/dev/null 2>&1; then ok; else fail; fi
885 # ... and here finish configuring parameters
886 sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
888 emit --no-wait root-filesystem
889 emit --no-wait virtual-filesystems
890 emit --no-wait local-filesystems
891 emit --no-wait filesystem
893 # /var/log should be writable now, so start saving the boot output
894 if [ "$RC_BOOTLOG" ]; then
895 echo > /var/log/boot.log
903 [ -n "$SELINUX" ] && [ -f /.autorelabel ] && relabel_selinux
906 rm -f /fastboot /fsckoptions /forcefsck /halt /poweroff >/dev/null 2>&1
909 # /usr could be still not mounted if it is on NFS.
910 for afile in /var/lock/* /var/run/*; do
912 if [ -d "$afile" ]; then
917 echo $afile/* | xargs rm -rf
921 [ "$bafile" != "hwprofile" -a "$bafile" != "random-seed" ] && rm -f $afile 2> /dev/null
926 rm -f /var/lib/rpm/__db* /var/spool/postoffice/.pid.* /tmp/.X*-lock \
927 /tmp/.lock.* /tmp/.gdm_socket /tmp/.s.PGSQL.*
928 rm -rf /tmp/.X*-unix /tmp/.ICE-unix /tmp/.font-unix /tmp/hsperfdata_* \
929 /tmp/kde-* /tmp/ksocket-* /tmp/mc-* /tmp/mcop-* /tmp/orbit-* \
930 /tmp/scrollkeeper-* /tmp/ssh-*
934 if ! is_no "$NEED_XFILES"; then
937 chown root:utmp /var/run/utmpx /var/log/wtmpx
938 chmod 0664 /var/run/utmpx /var/log/wtmpx
942 chown root:utmp /var/run/utmp /var/log/wtmp
943 chmod 0664 /var/run/utmp /var/log/wtmp
947 if is_yes "$CLEAN_TMP" && ! is_fsmounted tmpfs /tmp; then
948 LC_ALL=C rm -rf /tmp/* /tmp/.[a-zA-Z0-9]*
951 # System protected dirs
952 mkdir -m 1777 -p /tmp/.ICE-unix > /dev/null 2>&1
953 chown root:root /tmp/.ICE-unix
954 [ -n "$SELINUX" ] && restorecon /tmp/.ICE-unix >/dev/null 2>&1
956 if ! is_yes "$VSERVER"; then
957 run_cmd "Enabling swap space" true
958 # Right, now turn on swap in case we swap to files
959 swapon -a >/dev/null 2>&1
960 emit --no-wait all-swaps
962 # If a SCSI tape has been detected, load the st module unconditionally
963 # since many SCSI tapes don't deal well with st being loaded and unloaded
964 if [ -f /proc/scsi/scsi ] && grep -q 'Type: Sequential-Access' /proc/scsi/scsi 2>/dev/null ; then
965 if grep -qv ' 9 st' /proc/devices 2>/dev/null; then
966 if [ -n "$USEMODULES" ] ; then
967 # Try to load the module. If it fails, ignore it...
968 insmod -p st >/dev/null 2>&1 && modprobe -s st
973 # Now that we have all of our basic modules loaded and the kernel going,
974 # let's dump the syslog ring somewhere so we can find it later
975 dmesg --raw > /var/log/dmesg
977 while [ $i -ge 0 ]; do
978 if [ -f /var/log/dmesg.$i ]; then
979 chmod 0600 /var/log/dmesg.$i
980 mv -f /var/log/dmesg.$i /var/log/dmesg.$(($i+1))
984 cp -f /var/log/dmesg /var/log/dmesg.0
985 chmod 0600 /var/log/dmesg /var/log/dmesg.0
987 emit --no-wait all-swaps
990 if ! is_no "$RC_PROMPT"; then
992 pid=$(/sbin/pidof getkey)
993 [ -n "$pid" -o -e /var/run/getkey_done ] && break
996 [ -n "$pid" ] && kill -TERM "$pid" >/dev/null 2>&1
1000 # /proc extra check if the background process we just spawned is still running,
1001 # as in case of vserver bootup it finishes quite instantly.
1002 if ! is_no "$RC_PROMPT" && [ -d /proc/$! ]; then
1003 /sbin/getkey i && touch /var/run/confirm
1004 touch /var/run/getkey_done
1007 if ! is_no "$RC_PROMPT"; then
1008 rm -f /var/run/getkey_done
1012 emit --no-wait pld.sysinit-done