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
72 # default is set in /etc/sysconfig/system
101 local _d selinuxfs _t _r
103 while read _d selinuxfs _t _r; do
104 [ "$_t" = "selinuxfs" ] && break
106 echo "*** Warning -- SELinux is active"
107 echo "*** Disabling security enforcement for system recovery."
108 echo "*** Run 'setenforce 1' to reenable."
109 echo "0" > $selinuxfs/enforce
113 local _d selinuxfs _t _r
115 while read _d selinuxfs _t _r; do
116 [ "$_t" = "selinuxfs" ] && break
119 *** Warning -- SELinux relabel is required. ***
120 *** Disabling security enforcement. ***
121 *** Relabeling could take a very long time, ***
122 *** depending on file system size. ***
124 echo "0" > $selinuxfs/enforce
125 /sbin/fixfiles -F relabel > /dev/null 2>&1
127 echo "*** Enabling security enforcement. ***"
128 echo $SELINUX > $selinuxfs/enforce
131 # Remove duplicate entries from mtab (for vserver guest use only)
132 clean_vserver_mtab() {
134 while read device mountpoint line; do
135 grep -qs "$mountpoint" /etc/mtab.clean || \
136 echo "$device $mountpoint $line" >> /etc/mtab.clean
138 cat /etc/mtab.clean > /etc/mtab
139 rm -f /etc/mtab.clean
142 # Loads modules from /etc/modules, /etc/modules.X.Y and /etc/modules.X.Y.Z
143 load_kernel_modules() {
144 local modules_file=$1
145 local _x _y _z v v1 old_IFS kernel kerneleq
149 # strip _* or -* from versions like: "2.6.25_vanilla-1", "2.6.25-1"
162 # Loop over every line in modules file
164 grep -hvE '^(#|[[:blank:]]*$)' /etc/$modules_file /etc/$modules_file.$kernel /etc/$modules_file.$kerneleq 2>/dev/null
165 echo '' # make sure there is a LF at the end
166 ) | while read module args; do
167 [ -z "$module" ] && continue
170 show "Loading %s kernel module(s)" "$module"
172 modprobe -s $module -- $args && ok || fail
176 # launch repair shell
177 # which after exiting will reboot
181 # don't use '\n' in nls macro !
185 nls "*** Dropping you to a shell; the system will reboot"
186 nls "*** when you leave the shell."
189 [ "$SELINUX" = "1" ] && disable_selinux
190 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
196 run_cmd "Unmounting file systems" umount -a
197 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
198 run_cmd "Automatic reboot in progress" reboot
202 show "Checking root filesystem"; started
203 initlog -c "fsck -C -T -a $fsckoptions /"
206 # A return of 4 or higher means there were serious problems.
207 if [ $rc -gt 3 ]; then
208 [ -e /proc/splash ] && echo "verbose" > /proc/splash
210 PS1="$(nls '(Repair filesystem)# ')"; export PS1
211 repair_shell "$(nls '*** An error occurred during the file system check.')"
213 # A return of 2 or 3 means that filesystem was repaired but we need
215 elif [ "$rc" = "2" -o "$rc" = "3" ]; then
216 [ -e /proc/splash ] && echo "verbose" > /proc/splash
218 nls "*** Filesystem was repaired but system needs to be"
219 nls "*** rebooted before mounting it."
220 nls "*** REBOOTING ***"
223 run_cmd "Unmounting file systems" umount -a
224 mount -n -o remount,ro /
225 run_cmd "Automatic reboot in progress" reboot
226 elif [ "$rc" = "1" ]; then
233 if [ ! -x /sbin/mdadm -o ! -f /etc/mdadm.conf ]; then
239 if [ -f /proc/mdstat ]; then
242 if grep -qE "^([[:blank:]]|)ARRAY[[:blank:]]" /etc/mdadm.conf; then
243 show "Starting up RAID devices"; busy
244 /sbin/mdadm --assemble --scan --auto=yes
246 if [ "$rc" -eq 0 -o "$rc" -eq 2 ]; then
247 # rc is used later, too so set sane value
257 # A non-zero return means there were problems
258 if [ $rc -gt 0 ]; then
259 [ -e /proc/splash ] && echo "verbose" > /proc/splash
260 show "Starting up RAID devices"; fail
262 PS1="$(nls '(RAID Repair)# ')"; export PS1
263 repair_shell "$(nls '*** An error occurred during the RAID startup.')"
266 # LVM on RAID (keep in sync with LVM init)
267 if [ "$golvm" -eq "1" ]; then
268 if [ -x /sbin/vgscan -a -x /sbin/vgchange ]; then
269 run_cmd "Scanning for LVM volume groups (on RAID)" /sbin/vgscan $lvmignorelocking
270 run_cmd "Activating LVM volume groups (on RAID)" /sbin/vgchange -a y $lvmsysinit
271 [ "$lvmversion" = "2" ] && /sbin/vgmknodes
274 show "Starting up RAID devices"; ok
281 if [ ! -x /sbin/vgscan -o ! -x /sbin/vgchange ] && ! is_yes "$EVMS_LVM"; then
285 if is_no "$LVM2"; then
286 lvmversion=$(LC_ALL=C /sbin/vgchange --version 2>/dev/null | awk '/LVM version:/{if ($3 >= 2) print "2"}')
291 if [ "$lvmversion" = "1" ] ; then
295 elif [ "$lvmversion" = "2" ] ; then
297 lvmignorelocking="--ignorelockingfailure"
298 lvmsysinit="--sysinit"
301 # device mapper (2.5+ and patched 2.4)
307 run_cmd "Scanning for LVM volume groups" /sbin/vgscan $lvmignorelocking
308 run_cmd "Activating LVM volume groups" /sbin/vgchange -a y $lvmsysinit
309 if [ "$lvmversion" = "2" ]; then
310 /sbin/vgmknodes $lvmignorelocking
311 # display VG statistics
312 /sbin/vgdisplay -s $lvmignorelocking
316 # boot logging to /var/log/boot.log. install showconsole package to get it.
317 if ! is_no "$RC_BOOTLOG" && [ -x /sbin/blogd ]; then
323 if ! is_yes "$VSERVER"; then
324 # we need /proc mounted before everything
325 is_fsmounted proc /proc || mount -n /proc || mount -n -o gid=17,hidepid=2 -t proc /proc /proc
330 is_fsmounted tmpfs /run || mount -n -t tmpfs run /run
334 sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
336 # sysfs is also needed before any other things (under kernel > 2.5)
337 if grep -q sysfs /proc/filesystems 2>/dev/null; then
338 is_fsmounted sysfs /sys || mount -n -o gid=17 -t sysfs sysfs /sys
339 if grep -q securityfs /proc/filesystems 2>/dev/null; then
340 mount -n -o gid=17 -t securityfs securityfs /sys/kernel/security
345 if grep -q selinuxfs /proc/filesystems 2>/dev/null && ! is_fsmounted selinuxfs /selinux; then
346 mount -n -o gid=17 -t selinuxfs selinuxfs /selinux
349 # PLD Linux LiveCD support
350 if [ -x /etc/rc.d/rc.live ]; then
354 # Choose Hardware profile
355 if [ -f /etc/sysconfig/hwprof ]; then
356 . /etc/sysconfig/hwprof
357 if is_yes "${HWPROFILES}" && [ -x /sbin/hwprofile -a -d /etc/sysconfig/hwprofiles/data ]; then
358 mount -n / -o rw,remount
360 mount -n / -o ro,remount
364 # Disable splash when requested
365 is_no "$BOOT_SPLASH" && [ -e /proc/splash ] && echo "0" > /proc/splash
367 # Check SELinux status
368 selinuxfs=$(awk '/ selinuxfs / { print $2 }' /proc/mounts 2> /dev/null)
370 if [ -n "$selinuxfs" ] && [ "$(cat /proc/self/attr/current)" != "kernel" ]; then
371 if [ -r $selinuxfs/enforce ] ; then
372 SELINUX=$(cat $selinuxfs/enforce)
374 # assume enforcing if you can't read it
379 if [ -x /sbin/restorecon ] && is_fsmounted tmpfs /dev; then
380 /sbin/restorecon -R /dev 2>/dev/null
383 [ -z "${CONSOLETYPE}" ] && CONSOLETYPE="$(/sbin/consoletype)"
385 if [ "$CONSOLETYPE" = "vt" -a -x /sbin/setsysfont ]; then
391 # Print welcome message
392 nls "\t\t\t%sPowered by %sPLD Linux Distribution%s" "$(termput setaf $CPOWEREDBY)" "$(termput setaf $CPLD)" "$(termput op)"
393 if ! is_no "$RC_PROMPT"; then
394 nls -n "\t\t Press %sI%s to enter interactive startup" "$(termput setaf $CI)" "$(termput op)"
399 if [ -z "${HOSTNAME}" ]; then
400 show "$(nls 'Host:') $(hostname)"; ok
402 run_cmd "$(nls 'Host:') ${HOSTNAME}" hostname ${HOSTNAME}
405 # Set the NIS domain name
406 if [ -n "$NISDOMAIN" ]; then
407 run_cmd "$(nls 'NIS Domain:') ${NISDOMAIN}" domainname $NISDOMAIN
412 if ! is_yes "$VSERVER"; then
413 # Set console loglevel
414 if [ -n "$CONSOLE_LOGLEVEL" ]; then
415 dmesg -n $CONSOLE_LOGLEVEL
418 if ! is_no "$START_UDEV" && [ -x /sbin/start_udev ] && [[ "$container" != lxc* ]]; then
419 is_fsmounted devtmpfs /dev || mount -n -t devtmpfs devtmpfs /dev
420 load_kernel_modules modules.preudev
422 use_upstart && [ -x /sbin/initctl ] && /sbin/initctl -q start udev
423 elif [ -x /lib/firmware/firmware-loader.sh ]; then
424 /sbin/sysctl -e -w kernel.hotplug=/lib/firmware/firmware-loader.sh > /dev/null 2>&1
427 # Unmount the initrd, if necessary
428 if grep -q /initrd /proc/mounts 2>/dev/null && ! grep -q /initrd/loopfs /proc/mounts 2>/dev/null; then
429 umount /initrd/dev 2>/dev/null
431 /sbin/blockdev --flushbufs /dev/ram0 >/dev/null 2>&1
434 # Start logging console output since we have all /dev stuff setup
435 if [ "$RC_BOOTLOG" ]; then
439 # Configure Linux kernel (initial configuration, some required modules still
441 sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
443 # Check if timezone definition is available
444 if [ -e /etc/localtime ] && [ -e /dev/rtc -o -e /dev/rtc0 ] ; then
445 if run_cmd "$(nls 'Setting clock')" hwclock --hctosys; then
446 show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
449 TIME_SETUP_DELAYED=yes
453 if [ -f /etc/crypttab ] && ! is_empty_file /etc/crypttab; then
454 # XXX might need modules dep
455 # Device mapper & related initialization
456 if ! grep -qF device-mapper /proc/devices; then
460 . /etc/rc.d/init.d/cryptsetup
461 show "Starting disk encryption"
464 [ $delay_cryptsetup = 0 ] && ok || fail
468 run_cmd "Activating swap partitions" swapon -a -e
470 # Initialize USB controllers
472 if [ -z "$nousb" ] && ! is_fsmounted usbfs /proc/bus/usb; then
473 aliases=$(modprobe_c | awk '/^alias[\t ]+usb-controller/ { print $3 }')
474 if [ -n "$aliases" -a "$aliases" != "off" ] ; then
476 for alias in $aliases ; do
477 [ "$alias" = "off" ] && continue
478 run_cmd "$(nls 'Initializing USB controller') ($alias)" modprobe -s $alias
480 [ $? -eq 0 -a -n "$aliases" ] && usb=1
482 if grep -iq "usb" /proc/devices 2>/dev/null ; then
487 if [ "$usb" = "1" -a -d /proc/bus/usb ] && ! is_fsmounted usbfs /proc/bus/usb ; then
488 run_cmd "Mounting USB filesystem" mount -n -t usbfs -o devgid=78,devmode=664 usbfs /proc/bus/usb
492 if [ "$usb" = "1" ]; then
493 needusbstorage=$(cat /proc/bus/usb/devices 2>/dev/null | grep -e "^I.*Cls=08" 2>/dev/null)
494 if [ "$(kernelverser)" -lt "002006" ]; then
495 grep -Fq 'hid' /proc/bus/usb/drivers 2>/dev/null || run_cmd "Initializing USB HID interface" modprobe -s hid
496 mouseoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=02" 2>/dev/null)
497 kbdoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=01" 2>/dev/null)
498 if [ -n "$kbdoutput" ]; then
499 run_cmd "Initializing USB keyboard" modprobe -s keybdev
501 if [ -n "$mouseoutput" ]; then
502 run_cmd "Initializing USB mouse" modprobe -s mousedev
507 # Setup hdparm thing (if exists and is needed)
508 if [ -z "$nohdparm" ]; then
509 [ -x /etc/rc.d/rc.hdparm ] && /etc/rc.d/rc.hdparm
512 if [ -z "$fastboot" ] && [ -f /fastboot ]; then
516 if [ -f /fsckoptions ]; then
517 fsckoptions=$(cat /fsckoptions)
522 if [ -f /forcefsck ]; then
523 fsckoptions="-f $fsckoptions"
525 # Obey the fs_passno setting for / (see fstab(5))
527 # - make sure we have at least 6 fields
528 _ROOTFS_PASSNO=$(awk '($1 !~ /^#/ && $2 == "/" && NF >= 6) { print $6}' /etc/fstab)
532 _ROOTFS_DEVICE=$(awk '($1 !~ /^#/ && $2 == "/" && NF >= 6) { print $1}' /etc/fstab)
533 _ROOTFS_TYPE=$(awk '$2 == "/" && $3 != "rootfs" { print $3 }' /proc/mounts 2>/dev/null)
535 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
539 # set up pnp and kernel pnp
540 if is_yes "$RUN_USERPNP" || is_yes "$RUN_KERNELPNP"; then
541 if [ -z "$nopnp" ] && is_yes "$RUN_USERPNP" && [ -x /sbin/isapnp -a -f /etc/isapnp/isapnp.conf ]; then
542 run_cmd "Setting up ISA PNP devices (userspace pnp)" /sbin/isapnp /etc/isapnp/isapnp.conf
544 if [ -z "$nopnp" ] && is_yes "$RUN_KERNELPNP"; then
546 if [ -e /proc/isapnp -a -f /etc/isapnp/isapnp-kernel.conf ]; then
547 show "Setting up ISA PNP devices (kernelspace pnp)"; busy
548 grep -v "^#" /etc/isapnp/isapnp-kernel.conf 2>/dev/null >/proc/isapnp && (deltext; ok) || (deltext; fail)
553 _ROOTFS_RO=$(awk '($1 !~ /^#/ && $2 == "/" && ($4 == "ro" || $4 ~ /,ro$/ || $4 ~ /^ro,/ || $4 ~ /,ro,/ ) && NF >= 6) { print "ro" }' /etc/fstab)
554 # Remount the root filesystem read-write
555 if [ -z "$_ROOTFS_RO" ]; then
556 run_cmd "Remounting root filesystem in rw mode" mount -n -o remount,rw /
559 # Update quotas if fsck was run on /
560 if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then
561 run_cmd "Checking root filesystem quotas" /sbin/quotacheck -vnug /
564 # Clean up SELinux labels
565 if [ -n "$SELINUX" ]; then
566 for file in /etc/mtab /etc/cryptomtab /etc/ld.so.cache; do
567 [ -r $file ] && restorecon $file >/dev/null 2>&1
571 if [ "$delay_cryptsetup" != 0 ]; then
572 show "Starting disk encryption using the RNG"
575 [ $delay_cryptsetup = 0 ] && ok || fail
578 # Start logging console output since we have all /dev stuff setup
579 if [ "$RC_BOOTLOG" ]; then
584 # Remove stale backups
585 rm -f /etc/mtab~ /etc/mtab~~ /etc/cryptomtab~ /etc/cryptomtab~~ >/dev/null 2>&1
587 # Remove /etc/nologin when starting system
588 [ -f /etc/nologin.boot ] && rm -f /etc/nologin /etc/nologin.boot
590 if ! is_no "$DELAY_LOGIN" && [ ! -f /etc/nologin ]; then
591 show "Enabling Delay Login"; busy
593 nls "System bootup in progress - please wait" >> /etc/nologin
595 chmod 644 /etc/nologin
596 cp -fp /etc/nologin /etc/nologin.boot
600 # The root filesystem is now read-write, so we can now log via
601 # syslog() directly...
602 if [ -n "$IN_INITLOG" ]; then
606 if ! is_yes "$VSERVER"; then
609 [ -f /etc/cryptomtab ] && > /etc/cryptomtab
611 # Enter root, /proc, /sys and other into mtab.
612 mount -f / 2> /dev/null
613 mount -f /proc 2> /dev/null
614 if is_fsmounted devtmpfs /dev; then
615 mount -f -t devtmpfs devtmpfs /dev 2> /dev/null
617 if is_fsmounted tmpfs /run; then
618 mount -f -t tmpfs run /run 2> /dev/null
621 if is_fsmounted usbfs /proc/bus/usb; then
622 mount -f -t usbfs -o devgid=78,devmode=664 usbfs /proc/bus/usb 2> /dev/null
625 if is_fsmounted sysfs /sys; then
626 mount -f -t sysfs sysfs /sys 2> /dev/null
627 if is_fsmounted securityfs /sys/kernel/security ; then
628 mount -f -t securityfs securityfs /sys/kernel/security 2> /dev/null
632 if is_fsmounted selinuxfs /selinux; then
633 mount -f -t selinuxfs selinuxfs /selinux 2> /dev/null
636 emit --no-wait root-filesystem
637 emit --no-wait virtual-filesystems
639 if [ ! -f /proc/modules ]; then
641 elif [ -z "$nomodules" ]; then
648 # Adjust symlinks as necessary in /boot to keep system services from
649 # spewing messages about mismatched System maps and so on.
650 if ! is_no "$SET_SLINKS"; then
651 if [ -L /boot/System.map -a -r /boot/System.map-$uname_r ] ; then
652 ln -s -f System.map-$uname_r /boot/System.map
654 if [ ! -e /boot/System.map -a -r /boot/System.map-$uname_r ] ; then
655 ln -s -f System.map-$uname_r /boot/System.map
659 # Run depmod if RUN_DEPMOD != "no" and:
660 # a) user requested or RUN_DEPMOD="";
661 # b) modules.dep is missing
662 if ! is_no "$RUN_DEPMOD" && [ -n "$USEMODULES" ]; then
663 if is_yes "$RUN_DEPMOD" || [ -z "$RUN_DEPMOD" ]; then
664 run_cmd "Finding module dependencies" depmod -a
665 elif [ "$RUN_DEPMOD" = "ifmissing" ] && [ ! -f /lib/modules/$uname_r/modules.dep ]; then
666 run_cmd "Finding module dependencies" depmod -A
671 if [ -f /proc/sys/kernel/modprobe ]; then
672 if [ -n "$USEMODULES" ]; then
673 sysctl -w kernel.modprobe="/sbin/modprobe" >/dev/null 2>&1
675 # We used to set this to NULL, but that causes
676 # 'failed to exec' messages"
677 sysctl -w kernel.modprobe="/bin/true" >/dev/null 2>&1
681 # Load usb storage here, to match most other things
682 if [ -n "$needusbstorage" ]; then
683 modprobe -s usb-storage
686 # Load firewire devices
687 if [ -z "$nofirewire" ]; then
688 aliases=$(modprobe_c | awk '/^alias ieee1394-controller/ { print $3 }')
689 if [ -n "$aliases" -a "$aliases" != "off" ] ; then
690 for alias in $aliases ; do
691 [ "$alias" = "off" ] && continue
692 run_cmd "$(nls 'Initializing firewire controller') ($alias)" modprobe $alias
694 grep -E "SBP2" /proc/bus/ieee1394/devices 2>/dev/null && modprobe -s sbp2
698 # Load sound modules if they need persistent DMA buffers
699 if modprobe_c | grep -q "^options sound dmabuf=1"; then
701 alias=$(modprobe_c | grep -sE "^alias[[:space:]]+sound[[:space:]]+" 2>/dev/null | awk '{ print $3 }')
702 if [ -n "$alias" -a "$alias" != "off" ] ; then
703 run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias
706 alias=$(modprobe_c | grep -sE "^alias[[:space:]]+sound-slot-0[[:space:]]+" 2>/dev/null | awk '{ print $3 }')
707 if [ -n "$alias" -a "$alias" != "off" ] ; then
708 run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias
714 if ! use_upstart; then
715 load_kernel_modules modules
716 for f in /etc/modules-load.d/*.conf; do
717 # already loaded by implicit "modules" load
718 [ "${f##*/}" = "modules.conf" ] && continue
720 [ -r $f ] || continue
721 load_kernel_modules ${f##/etc/}
725 if ! is_no "$DM_MULTIPATH" [ -x /sbin/multipath ]; then
726 # first make nodes that were discarded due (possible) new /dev mount
728 /sbin/dmsetup mknodes
729 modprobe -s dm-multipath
730 run_cmd "Activating dm-multipath" /sbin/multipath -v 0
731 /sbin/dmsetup ls --target multipath --exec '/sbin/kpartx -a -p p'
734 if ! is_no "$DMRAID" && [ -x /sbin/dmraid ]; then
735 run_cmd "Activating ATARAID devices" /sbin/dmraid -ay
738 # Find and activate volume groups:
740 if is_yes "$EVMS_LVM" && [ -x /sbin/evms_activate ]; then
741 if [ "$(kernelverser)" -lt "002006" ]; then
742 # Linux 2.4 core modules
744 modprobe -s evms_passthru
748 # Linux 2.6 core module
752 is_yes "$EVMS_GUID_PTABLE" && modprobe -s gpt_part
753 is_yes "$EVMS_LVM" && modprobe -s lvm_vge
754 is_yes "$EVMS_AIX" && modprobe -s AIXlvm_vge
755 is_yes "$EVMS_OS2" && modprobe -s os2lvm_vge
756 run_cmd "Discovering EVMS volumes" /sbin/evms_activate
757 if is_yes "$EVMS_LVM" && is_yes "$EVMS_LVM_COMPAT_NODES" ; then
758 # Link nodes for compatibility with LVM
759 if [ "$(echo /dev/evms/lvm/*)" != '/dev/evms/lvm/*' ] ; then
760 ln -s /dev/evms/lvm/* /dev
766 if ! is_no "$LVM2"; then
770 if [ "$delay_cryptsetup" != 0 ]; then
771 show "Starting disk encryption"
774 [ $delay_cryptsetup = 0 ] && ok || fail
777 if ! is_no "$MDADM"; then
783 if [ -z "$fastboot" ] && [ -z "$nofsck" ]; then
784 rc_splash "fsck start"
785 show "Checking filesystems"; started
786 initlog -c "fsck -C -T -R -A -a -P $fsckoptions"
790 # A return of 2 or higher means there were serious problems
791 if [ $rc -gt 1 ]; then
792 [ -e /proc/splash ] && echo "verbose" > /proc/splash
794 PS1="$(nls '(Repair filesystem)# ')"; export PS1
795 repair_shell "$(nls '*** An error occurred during the file system check.')"
797 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
800 rc_splash "fsck stop"
803 # Mount all other filesystems (except for NFS and /proc, which is already
804 # mounted). Contrary to standard usage,
805 # filesystems are NOT unmounted in single user mode.
806 run_cmd "Mounting local filesystems" mount -a -t nonfs,nfs4,smbfs,ncpfs,proc,cifs -O no_netdev
808 # now we have /usr mounted, recheck if we have gettext and tput available.
809 if is_no "$TPUT"; then
815 # Now do some workaround - encrypted filesystems couldn't have been fsck-ed
816 # before mount - that's where the password is entered.
817 # mount is buggy - when remounting loopback filesystem, loop=XXX
818 # option is removed from /etc/mtab
819 if [ -z "$fastboot" ] && grep "^[^#].*encryption=" /etc/fstab 2>/dev/null | grep -v -q "noauto" 2>/dev/null; then
820 show "Checking encrypted filesystems"; started
821 LOOPLIST="$(LC_ALL=C awk '
822 FILENAME=="/proc/mounts" {
825 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && /[^a-zA-Z_]ro[^a-zA-Z_]/ {
826 if ($2 in TAB){print TAB[$2];}
828 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ {
829 if ($2 in TAB){print TAB[$2];}
830 sub("loop(=[^,]*)?","loop=" TAB[$2] ",ro",$4);
831 cmd="mount " $2 " -o remount," $4;
834 ' /proc/mounts /etc/fstab)"
835 initlog -c "fsck -T -C -a $fsckoptions $LOOPLIST"
838 # A return of 2 or higher means there were serious problems.
839 if [ $rc -gt 1 ]; then
840 [ -e /proc/splash ] && echo "verbose" > /proc/splash
842 PS1="$(nls '(Repair filesystem)# ')"; export PS1
843 repair_shell "$(nls '*** An error occurred during the file system check.')"
845 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
849 show "Remounting encrypted filesystems back in rw mode"; busy
851 FILENAME=="/proc/mounts" {
854 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ {
855 sub("loop(=[^,]*)?","loop=" TAB[$2] ",rw",$4);
856 cmd="mount " $2 " -o remount," $4;
859 ' /proc/mounts /etc/fstab
863 # /var/log should be writable now, so start saving the boot output
864 if [ "$RC_BOOTLOG" ]; then
865 echo > /var/log/boot.log
869 if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then
870 run_cmd "Checking filesystem quotas" /sbin/quotacheck -vnugRa
874 if [ -x /sbin/quotaon ]; then
875 run_cmd "Turning on quotas for local filesystems" /sbin/quotaon -aug
878 emit --no-wait local-filesystems
880 # FIXME: this should be delayed until remote filesystems are mounted,
881 # especialy when /usr or other standard fs is remote
882 emit --no-wait filesystem
884 # Turn on process accounting
885 if [ -x /etc/rc.d/rc.acct ]; then
886 /etc/rc.d/rc.acct start
889 # Set the clock if timezone definition wasn't available (eg. /usr not mounted)
890 if is_yes "$TIME_SETUP_DELAYED" && [ -e /dev/rtc -o -e /dev/rtc0 ]; then
891 if run_cmd "$(nls 'Setting clock')" hwclock --hctosys; then
892 show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
896 # Initialize the serial ports
897 if [ -f /etc/rc.d/rc.serial ]; then
898 . /etc/rc.d/rc.serial
901 if [ -n "$PANIC_REBOOT_TIME" -a "$PANIC_REBOOT_TIME" -gt "0" -a -f /proc/sys/kernel/panic ]; then
902 show 'Setting %s seconds for kernel reboot after panic' "$PANIC_REBOOT_TIME"; busy
903 # NOTE: you should use /etc/sysctl.conf instead
904 if sysctl -w kernel.panic=$PANIC_REBOOT_TIME >/dev/null 2>&1; then ok; else fail; fi
907 # ... and here finish configuring parameters
908 sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
910 emit --no-wait root-filesystem
911 emit --no-wait virtual-filesystems
912 emit --no-wait local-filesystems
913 emit --no-wait filesystem
915 # /var/log should be writable now, so start saving the boot output
916 if [ "$RC_BOOTLOG" ]; then
917 echo > /var/log/boot.log
925 [ -n "$SELINUX" ] && [ -f /.autorelabel ] && relabel_selinux
928 rm -f /fastboot /fsckoptions /forcefsck /halt /poweroff >/dev/null 2>&1
931 # /usr could be still not mounted if it is on NFS.
932 for afile in /var/lock/* /var/run/*; do
934 if [ -d "$afile" ]; then
939 echo $afile/* | xargs rm -rf
943 [ "$bafile" != "hwprofile" -a "$bafile" != "random-seed" ] && rm -f $afile 2> /dev/null
948 rm -f /var/lib/rpm/__db* /var/spool/postoffice/.pid.* /tmp/.X*-lock \
949 /tmp/.lock.* /tmp/.gdm_socket /tmp/.s.PGSQL.*
950 rm -rf /tmp/.X*-unix /tmp/.ICE-unix /tmp/.font-unix /tmp/hsperfdata_* \
951 /tmp/kde-* /tmp/ksocket-* /tmp/mc-* /tmp/mcop-* /tmp/orbit-* \
952 /tmp/scrollkeeper-* /tmp/ssh-*
956 if ! is_no "$NEED_XFILES"; then
959 chown root:utmp /var/run/utmpx /var/log/wtmpx
960 chmod 0664 /var/run/utmpx /var/log/wtmpx
964 chown root:utmp /var/run/utmp /var/log/wtmp
965 chmod 0664 /var/run/utmp /var/log/wtmp
969 if is_yes "$CLEAN_TMP" && ! is_fsmounted tmpfs /tmp; then
970 LC_ALL=C rm -rf /tmp/* /tmp/.[a-zA-Z0-9]*
973 # System protected dirs
974 mkdir -m 1777 -p /tmp/.ICE-unix > /dev/null 2>&1
975 chown root:root /tmp/.ICE-unix
976 [ -n "$SELINUX" ] && restorecon /tmp/.ICE-unix >/dev/null 2>&1
978 if ! is_yes "$VSERVER"; then
979 run_cmd "Enabling swap space" true
980 # Right, now turn on swap in case we swap to files
981 swapon -a >/dev/null 2>&1
982 emit --no-wait all-swaps
984 # If a SCSI tape has been detected, load the st module unconditionally
985 # since many SCSI tapes don't deal well with st being loaded and unloaded
986 if [ -f /proc/scsi/scsi ] && grep -q 'Type: Sequential-Access' /proc/scsi/scsi 2>/dev/null ; then
987 if grep -qv ' 9 st' /proc/devices 2>/dev/null; then
988 if [ -n "$USEMODULES" ] ; then
989 # Try to load the module. If it fails, ignore it...
990 insmod -p st >/dev/null 2>&1 && modprobe -s st
995 # Now that we have all of our basic modules loaded and the kernel going,
996 # let's dump the syslog ring somewhere so we can find it later
997 dmesg --raw > /var/log/dmesg
999 while [ $i -ge 0 ]; do
1000 if [ -f /var/log/dmesg.$i ]; then
1001 chmod 0600 /var/log/dmesg.$i
1002 mv -f /var/log/dmesg.$i /var/log/dmesg.$(($i+1))
1006 cp -f /var/log/dmesg /var/log/dmesg.0
1007 chmod 0600 /var/log/dmesg /var/log/dmesg.0
1009 emit --no-wait all-swaps
1012 if ! is_no "$RC_PROMPT"; then
1014 pid=$(/sbin/pidof getkey)
1015 [ -n "$pid" -o -e /var/run/getkey_done ] && break
1018 [ -n "$pid" ] && kill -TERM "$pid" >/dev/null 2>&1
1022 # /proc extra check if the background process we just spawned is still running,
1023 # as in case of vserver bootup it finishes quite instantly.
1024 if ! is_no "$RC_PROMPT" && [ -d /proc/$! ]; then
1025 /sbin/getkey i && touch /var/run/confirm
1026 touch /var/run/getkey_done
1029 if ! is_no "$RC_PROMPT"; then
1030 rm -f /var/run/getkey_done
1034 emit --no-wait pld.sysinit-done