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
43 local _d selinuxfs _t _r
45 while read _d selinuxfs _t _r; do
46 [ "$_t" = "selinuxfs" ] && break
48 echo "*** Warning -- SELinux is active"
49 echo "*** Disabling security enforcement for system recovery."
50 echo "*** Run 'setenforce 1' to reenable."
51 echo "0" > $selinuxfs/enforce
55 local _d selinuxfs _t _r
57 while read _d selinuxfs _t _r; do
58 [ "$_t" = "selinuxfs" ] && break
61 *** Warning -- SELinux relabel is required. ***
62 *** Disabling security enforcement. ***
63 *** Relabeling could take a very long time, ***
64 *** depending on file system size. ***
66 echo "0" > $selinuxfs/enforce
67 /sbin/fixfiles -F relabel > /dev/null 2>&1
69 echo "*** Enabling security enforcement. ***"
70 echo $SELINUX > $selinuxfs/enforce
73 # Remove duplicate entries from mtab (for vserver guest use only)
74 clean_vserver_mtab() {
76 while read device mountpoint line; do
77 grep -qs "$mountpoint" /etc/mtab.clean || \
78 echo "$device $mountpoint $line" >> /etc/mtab.clean
80 cat /etc/mtab.clean > /etc/mtab
84 # Loads modules from /etc/modules, /etc/modules.X.Y and /etc/modules.X.Y.Z
85 load_kernel_modules() {
87 local _x _y _z v v1 old_IFS kernel kerneleq
91 # strip _* or -* from versions like: "2.6.25_vanilla-1", "2.6.25-1"
104 # Loop over every line in modules file
106 grep -hvE '^(#|[[:blank:]]*$)' /etc/$modules_file /etc/$modules_file.$kernel /etc/$modules_file.$kerneleq 2>/dev/null
107 echo '' # make sure there is a LF at the end
108 ) | while read module args; do
109 [ -z "$module" ] && continue
112 show "Loading %s kernel module(s)" "$module"
114 modprobe -s $module -- $args && ok || fail
119 show "Checking root filesystem"; started
120 initlog -c "fsck -C -T -a $fsckoptions /"
123 # A return of 4 or higher means there were serious problems.
124 if [ $rc -gt 3 ]; then
125 [ -e /proc/splash ] && echo "verbose" > /proc/splash
126 # don't use '\n' in nls macro !
129 nls "*** An error occurred during the file system check."
130 nls "*** Dropping you to a shell; the system will reboot"
131 nls "*** when you leave the shell."
134 PS1="$(nls '(Repair filesystem)# ')"; export PS1
135 [ "$SELINUX" = "1" ] && disable_selinux
136 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
142 run_cmd "Unmounting file systems" umount -a
143 mount -n -o remount,ro /
144 run_cmd "Automatic reboot in progress" reboot
145 # A return of 2 or 3 means that filesystem was repaired but we need
147 elif [ "$rc" = "2" -o "$rc" = "3" ]; then
148 [ -e /proc/splash ] && echo "verbose" > /proc/splash
150 nls "*** Filesystem was repaired but system needs to be"
151 nls "*** rebooted before mounting it."
152 nls "*** REBOOTING ***"
155 run_cmd "Unmounting file systems" umount -a
156 mount -n -o remount,ro /
157 run_cmd "Automatic reboot in progress" reboot
158 elif [ "$rc" = "1" ]; then
163 # boot logging to /var/log/boot.log. install showconsole package to get it.
164 if [ -x /sbin/blogd ] && ! is_no "$RC_BOOTLOG"; then
170 if ! is_yes "$VSERVER" ; then
172 is_fsmounted tmpfs /run || mount -n -t tmpfs run /run
175 # we need /proc mounted before everything
176 is_fsmounted proc /proc || mount -n /proc || mount -n -o gid=17,hidepid=2 -t proc /proc /proc
179 sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
181 # Only read this once.
182 cmdline=$(cat /proc/cmdline)
183 if strstr "$cmdline" "pld.no-upstart" ; then
187 # sysfs is also needed before any other things (under kernel > 2.5)
188 if grep -q sysfs /proc/filesystems 2>/dev/null ; then
189 is_fsmounted sysfs /sys || mount -n -o gid=17 -t sysfs sysfs /sys
190 if grep -q securityfs /proc/filesystems 2>/dev/null ; then
191 mount -n -o gid=17 -t securityfs securityfs /sys/kernel/security
196 if grep -q selinuxfs /proc/filesystems 2>/dev/null && ! is_fsmounted selinuxfs /selinux; then
197 mount -n -o gid=17 -t selinuxfs selinuxfs /selinux
200 # PLD Linux LiveCD support
201 if [ -x /etc/rc.d/rc.live ]; then
205 # Choose Hardware profile
206 if [ -f /etc/sysconfig/hwprof ]; then
207 . /etc/sysconfig/hwprof
208 if is_yes "${HWPROFILES}" && [ -x /sbin/hwprofile -a -d /etc/sysconfig/hwprofiles/data ]; then
209 mount -n / -o rw,remount
211 mount -n / -o ro,remount
215 # Disable splash when requested
216 is_no "$BOOT_SPLASH" && [ -e /proc/splash ] && echo "0" > /proc/splash
218 # Check SELinux status
219 selinuxfs=$(awk '/ selinuxfs / { print $2 }' /proc/mounts 2> /dev/null)
221 if [ -n "$selinuxfs" ] && [ "$(cat /proc/self/attr/current)" != "kernel" ]; then
222 if [ -r $selinuxfs/enforce ] ; then
223 SELINUX=$(cat $selinuxfs/enforce)
225 # assume enforcing if you can't read it
230 if [ -x /sbin/restorecon ] && is_fsmounted tmpfs /dev; then
231 /sbin/restorecon -R /dev 2>/dev/null
234 [ -z "${CONSOLETYPE}" ] && CONSOLETYPE="$(/sbin/consoletype)"
236 if [ "$CONSOLETYPE" = "vt" -a -x /sbin/setsysfont ]; then
242 # Print welcome message
243 nls "\t\t\t%sPowered by %sPLD Linux Distribution%s" "$(termput setaf $CPOWEREDBY)" "$(termput setaf $CPLD)" "$(termput op)"
244 if ! is_no "$RC_PROMPT"; then
245 nls -n "\t\t Press %sI%s to enter interactive startup" "$(termput setaf $CI)" "$(termput op)"
250 if [ -z "${HOSTNAME}" ]; then
251 show "$(nls 'Host:') $(hostname)" ; ok
253 run_cmd "$(nls 'Host:') ${HOSTNAME}" hostname ${HOSTNAME}
256 # Set the NIS domain name
257 if [ -n "$NISDOMAIN" ]; then
258 run_cmd "$(nls 'NIS Domain:') ${NISDOMAIN}" domainname $NISDOMAIN
263 if ! is_yes "$VSERVER"; then
264 # Set console loglevel
265 if [ -n "$CONSOLE_LOGLEVEL" ]; then
266 dmesg -n $CONSOLE_LOGLEVEL
269 if ! is_no "$START_UDEV" && [ -x /sbin/start_udev ] && [[ "$container" != lxc* ]]; then
270 is_fsmounted devtmpfs /dev || mount -n -t devtmpfs devtmpfs /dev
271 load_kernel_modules modules.preudev
273 [ -x /sbin/initctl ] && /sbin/initctl -q start udev
274 elif [ -x /lib/firmware/firmware-loader.sh ]; then
275 /sbin/sysctl -e -w kernel.hotplug=/lib/firmware/firmware-loader.sh > /dev/null 2>&1
278 # Unmount the initrd, if necessary
279 if grep -q /initrd /proc/mounts 2>/dev/null && ! grep -q /initrd/loopfs /proc/mounts 2>/dev/null; then
280 umount /initrd/dev 2>/dev/null
282 /sbin/blockdev --flushbufs /dev/ram0 >/dev/null 2>&1
285 # Start logging console output since we have all /dev stuff setup
286 if [ "$RC_BOOTLOG" ]; then
290 # Configure Linux kernel (initial configuration, some required modules still
292 sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
294 # Check if timezone definition is available
295 if [ -e /etc/localtime ] && [ -e /dev/rtc -o -e /dev/rtc0 ] ; then
296 if run_cmd "$(nls 'Setting clock')" hwclock --hctosys; then
297 show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
300 TIME_SETUP_DELAYED=yes
304 if [ -f /etc/crypttab ] && ! is_empty_file /etc/crypttab; then
305 # XXX might need modules dep
306 # Device mapper & related initialization
307 if ! grep -qF device-mapper /proc/devices; then
311 . /etc/rc.d/init.d/cryptsetup
312 show "Starting disk encryption"
315 [ $delay_cryptsetup = 0 ] && ok || fail
319 run_cmd "Activating swap partitions" swapon -a -e
321 # Initialize USB controllers
323 if ! strstr "$cmdline" "nousb" && ! is_fsmounted usbfs /proc/bus/usb ; then
324 aliases=$(/sbin/modprobe -c | awk '/^alias[\t ]+usb-controller/ { print $3 }')
325 if [ -n "$aliases" -a "$aliases" != "off" ] ; then
326 /sbin/modprobe -s usbcore
327 for alias in $aliases ; do
328 [ "$alias" = "off" ] && continue
329 run_cmd "$(nls 'Initializing USB controller') ($alias)" /sbin/modprobe -s $alias
331 [ $? -eq 0 -a -n "$aliases" ] && usb=1
333 if grep -iq "usb" /proc/devices 2>/dev/null ; then
338 if [ "$usb" = "1" ] && ! is_fsmounted usbfs /proc/bus/usb ; then
339 run_cmd "Mounting USB filesystem" mount -n -t usbfs -o devgid=78,devmode=664 usbfs /proc/bus/usb
343 if [ "$usb" = "1" ]; then
344 needusbstorage=$(cat /proc/bus/usb/devices 2>/dev/null | grep -e "^I.*Cls=08" 2>/dev/null)
345 if [ "$(kernelverser)" -lt "002006" ]; then
346 grep -q 'hid' /proc/bus/usb/drivers 2>/dev/null || run_cmd "Initializing USB HID interface" modprobe hid 2> /dev/null
347 mouseoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=02" 2>/dev/null)
348 kbdoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=01" 2>/dev/null)
349 if [ -n "$kbdoutput" ]; then
350 run_cmd "Initializing USB keyboard" modprobe keybdev
352 if [ -n "$mouseoutput" ]; then
353 run_cmd "Initializing USB mouse" modprobe mousedev
358 # Setup hdparm thing (if exists and is needed)
359 if ! strstr "$cmdline" nohdparm; then
360 [ -x /etc/rc.d/rc.hdparm ] && /etc/rc.d/rc.hdparm
363 if [ -f /fastboot ] || strstr "$cmdline" "fastboot"; then
369 if [ -f /fsckoptions ]; then
370 fsckoptions=$(cat /fsckoptions)
375 if [ -f /forcefsck ]; then
376 fsckoptions="-f $fsckoptions"
378 # Obey the fs_passno setting for / (see fstab(5))
380 # - make sure we have at least 6 fields
381 _ROOTFS_PASSNO=$(awk '($1 !~ /^#/ && $2 == "/" && NF >= 6) { print $6}' /etc/fstab)
385 _ROOTFS_DEVICE=$(awk '($1 !~ /^#/ && $2 == "/" && NF >= 6) { print $1}' /etc/fstab)
386 _ROOTFS_TYPE=$(awk '$2 == "/" && $3 != "rootfs" { print $3 }' /proc/mounts 2>/dev/null)
388 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
392 # Check for arguments
393 if strstr "$cmdline" nopnp; then
399 # set up pnp and kernel pnp
400 if [ -n "$PNP" ]; then
401 if ! is_no "$RUN_USERPNP" && [ -x /sbin/isapnp -a -f /etc/isapnp/isapnp.conf ]; then
402 run_cmd "Setting up ISA PNP devices (userspace pnp)" /sbin/isapnp /etc/isapnp/isapnp.conf
404 if ! is_no "$RUN_KERNELPNP"; then
405 /sbin/modprobe isa-pnp 2> /dev/null
406 if [ -e /proc/isapnp -a -f /etc/isapnp/isapnp-kernel.conf ]; then
407 show "Setting up ISA PNP devices (kernelspace pnp)"; busy
408 grep -v "^#" /etc/isapnp/isapnp-kernel.conf 2>/dev/null >/proc/isapnp && (deltext; ok) || (deltext; fail)
413 _ROOTFS_RO=$(awk '($1 !~ /^#/ && $2 == "/" && ($4 == "ro" || $4 ~ /,ro$/ || $4 ~ /^ro,/ || $4 ~ /,ro,/ ) && NF >= 6) { print "ro" }' /etc/fstab)
414 # Remount the root filesystem read-write
415 if [ -z "$_ROOTFS_RO" ]; then
416 run_cmd "Remounting root filesystem in rw mode" mount -n -o remount,rw /
419 # Update quotas if fsck was run on /
420 if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then
421 run_cmd "Checking root filesystem quotas" /sbin/quotacheck -vnug /
424 # Clean up SELinux labels
425 if [ -n "$SELINUX" ]; then
426 for file in /etc/mtab /etc/cryptomtab /etc/ld.so.cache ; do
427 [ -r $file ] && restorecon $file >/dev/null 2>&1
431 if [ "$delay_cryptsetup" != 0 ]; then
432 show "Starting disk encryption using the RNG"
435 [ $delay_cryptsetup = 0 ] && ok || fail
438 # Start logging console output since we have all /dev stuff setup
439 if [ "$RC_BOOTLOG" ]; then
444 # Remove stale backups
445 rm -f /etc/mtab~ /etc/mtab~~ /etc/cryptomtab~ /etc/cryptomtab~~ >/dev/null 2>&1
447 # Remove /etc/nologin when starting system
448 [ -f /etc/nologin.boot ] && rm -f /etc/nologin /etc/nologin.boot
450 if ! is_no "$DELAY_LOGIN" && [ ! -f /etc/nologin ]; then
451 show "Enabling Delay Login"; busy
453 nls "System bootup in progress - please wait" >> /etc/nologin
455 chmod 644 /etc/nologin
456 cp -fp /etc/nologin /etc/nologin.boot
460 # The root filesystem is now read-write, so we can now log via
461 # syslog() directly...
462 if [ -n "$IN_INITLOG" ]; then
466 if ! is_yes "$VSERVER"; then
469 [ -f /etc/cryptomtab ] && :>/etc/cryptomtab
471 # Enter root, /proc, /sys and other into mtab.
472 mount -f / 2> /dev/null
473 mount -f /proc 2> /dev/null
474 if is_fsmounted devtmpfs /dev; then
475 mount -f -t devtmpfs devtmpfs /dev 2> /dev/null
477 if is_fsmounted tmpfs /run; then
478 mount -f -t tmpfs run /run 2> /dev/null
481 if is_fsmounted usbfs /proc/bus/usb; then
482 mount -f -t usbfs -o devgid=78,devmode=664 usbfs /proc/bus/usb 2> /dev/null
485 if is_fsmounted sysfs /sys; then
486 mount -f -t sysfs sysfs /sys 2> /dev/null
487 if is_fsmounted securityfs /sys/kernel/security ; then
488 mount -f -t securityfs securityfs /sys/kernel/security 2> /dev/null
492 if is_fsmounted selinuxfs /selinux; then
493 mount -f -t selinuxfs selinuxfs /selinux 2> /dev/null
496 emit --no-wait root-filesystem
497 emit --no-wait virtual-filesystems
499 if [ ! -f /proc/modules ]; then
501 elif ! strstr "$cmdline" nomodules; then
508 # Adjust symlinks as necessary in /boot to keep system services from
509 # spewing messages about mismatched System maps and so on.
510 if ! is_no "$SET_SLINKS"; then
511 if [ -L /boot/System.map -a -r /boot/System.map-$uname_r ] ; then
512 ln -s -f System.map-$uname_r /boot/System.map
514 if [ ! -e /boot/System.map -a -r /boot/System.map-$uname_r ] ; then
515 ln -s -f System.map-$uname_r /boot/System.map
519 # Run depmod if RUN_DEPMOD != "no" and:
520 # a) user requested or RUN_DEPMOD="";
521 # b) modules.dep is missing
522 if ! is_no "$RUN_DEPMOD" && [ -n "$USEMODULES" ]; then
523 if is_yes "$RUN_DEPMOD" || [ -z "$RUN_DEPMOD" ]; then
524 run_cmd "Finding module dependencies" depmod -a
525 elif [ "$RUN_DEPMOD" = "ifmissing" ] && [ ! -f /lib/modules/$uname_r/modules.dep ]; then
526 run_cmd "Finding module dependencies" depmod -A
531 if [ -f /proc/sys/kernel/modprobe ]; then
532 if [ -n "$USEMODULES" ]; then
533 sysctl -w kernel.modprobe="/sbin/modprobe" >/dev/null 2>&1
535 # We used to set this to NULL, but that causes
536 # 'failed to exec' messages"
537 sysctl -w kernel.modprobe="/bin/true" >/dev/null 2>&1
541 # Load usb storage here, to match most other things
542 if [ -n "$needusbstorage" ]; then
543 modprobe usb-storage >/dev/null 2>&1
546 # Load firewire devices
547 if ! strstr "$cmdline" nofirewire; then
548 aliases=$(/sbin/modprobe -c | awk '/^alias ieee1394-controller/ { print $3 }')
549 if [ -n "$aliases" -a "$aliases" != "off" ] ; then
550 for alias in $aliases ; do
551 [ "$alias" = "off" ] && continue
552 run_cmd "$(nls 'Initializing firewire controller') ($alias)" /sbin/modprobe $alias
554 grep -E "SBP2" /proc/bus/ieee1394/devices 2>/dev/null && /sbin/modprobe -s sbp2 > /dev/null 2>&1
558 # Load sound modules if they need persistent DMA buffers
559 if /sbin/modprobe -c | grep -q "^options sound dmabuf=1"; then
561 alias=$(/sbin/modprobe -c | grep -sE "^alias[[:space:]]+sound[[:space:]]+" 2>/dev/null | awk '{ print $3 }')
562 if [ -n "$alias" -a "$alias" != "off" ] ; then
563 run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias
566 alias=$(/sbin/modprobe -c | grep -sE "^alias[[:space:]]+sound-slot-0[[:space:]]+" 2>/dev/null | awk '{ print $3 }')
567 if [ -n "$alias" -a "$alias" != "off" ] ; then
568 run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias
574 if ! use_upstart; then
575 load_kernel_modules modules
576 for f in /etc/modules-load.d/*.conf ; do
577 [ -r $f ] || continue
578 load_kernel_modules ${f##/etc/}
582 if [ -x /sbin/multipath ] && ! is_no "$DM_MULTIPATH"; then
583 # first make nodes that were discarded due (possible) new /dev mount
585 /sbin/dmsetup mknodes
586 modprobe -s dm-multipath
587 run_cmd "Activating dm-multipath" /sbin/multipath -v 0
588 /sbin/dmsetup ls --target multipath --exec '/sbin/kpartx -a -p p'
591 if [ -x /sbin/dmraid ]; then
592 run_cmd "Activating ATARAID devices" /sbin/dmraid -ay
595 # Find and activate volume groups:
597 if [ -x /sbin/evms_activate ]; then
598 if [ "$(kernelverser)" -lt "002006" ]; then
599 # Linux 2.4 core modules
600 modprobe -s evms > /dev/null 2>&1
601 modprobe -s evms_passthru > /dev/null 2>&1
602 modprobe -s ldev_mgr > /dev/null 2>&1
603 modprobe -s dos_part > /dev/null 2>&1
605 # Linux 2.6 core module
606 modprobe -s evmscore > /dev/null 2>&1
609 is_yes "$EVMS_GUID_PTABLE" && modprobe -s gpt_part >/dev/null 2>&1
610 is_yes "$EVMS_LVM" && modprobe -s lvm_vge >/dev/null 2>&1
611 is_yes "$EVMS_AIX" && modprobe -s AIXlvm_vge >/dev/null 2>&1
612 is_yes "$EVMS_OS2" && modprobe -s os2lvm_vge >/dev/null 2>&1
613 run_cmd "Discovering EVMS volumes" /sbin/evms_activate
614 if is_yes "$EVMS_LVM" && is_yes "$EVMS_LVM_COMPAT_NODES" ; then
615 # Link nodes for compatibility with LVM
616 if [ "$(echo /dev/evms/lvm/*)" != '/dev/evms/lvm/*' ] ; then
617 ln -s /dev/evms/lvm/* /dev
622 # LVM (keep in sync with LVM starting after RAID run!)
623 if ! is_no "$LVM2" && [ -x /sbin/vgscan -a -x /sbin/vgchange ] || is_yes "$EVMS_LVM"; then
624 if is_no "$LVM2"; then
625 lvmversion=$(LC_ALL=C /sbin/vgchange --version 2>/dev/null | awk '/LVM version:/{if ($3 >= 2) print "2"}')
629 if [ "$lvmversion" = "1" ] ; then
630 modprobe -s lvm-mod >/dev/null 2>&1
633 elif [ "$lvmversion" = "2" ] ; then
634 modprobe -s dm-mod >/dev/null 2>&1
635 lvmignorelocking="--ignorelockingfailure"
636 lvmsysinit="--sysinit"
638 modprobe -s lvm-mod >/dev/null 2>&1
639 # device mapper (2.5+ and patched 2.4)
640 modprobe -s dm-mod >/dev/null 2>&1
645 run_cmd "Scanning for LVM volume groups" /sbin/vgscan $lvmignorelocking
646 run_cmd "Activating LVM volume groups" /sbin/vgchange -a y $lvmsysinit
647 if [ "$lvmversion" = "2" ]; then
648 /sbin/vgmknodes $lvmignorelocking
649 # display VG statistics
650 /sbin/vgdisplay -s $lvmignorelocking
654 if [ "$delay_cryptsetup" != 0 ]; then
655 show "Starting disk encryption"
658 [ $delay_cryptsetup = 0 ] && ok || fail
662 if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ] || [ -f /etc/raidtab ]; then
663 modprobe -s md >/dev/null 2>&1
664 if [ -f /proc/mdstat ]; then
668 if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ]; then
669 if (grep -qE "^([[:blank:]]|)ARRAY[[:blank:]]" /etc/mdadm.conf 2>/dev/null); then
670 show "Starting up RAID devices"; busy
671 /sbin/mdadm --assemble --scan --auto=yes
673 if [ "$rc" -eq 0 -o "$rc" -eq 2 ]; then
674 # rc is used later, too so set sane value
686 if [ -f /etc/raidtab -a "$goraidtab" -eq 1 ]; then
687 for i in $(awk '!/^#/ && /raiddev/{print $2}' /etc/raidtab 2>/dev/null); do
689 RAIDDEV=$(basename $i)
690 RAIDSTAT=$(grep "^$RAIDDEV : active" /proc/mdstat 2>/dev/null)
691 show "Starting up RAID device %s" $RAIDDEV
693 if [ -z "$RAIDSTAT" ]; then
694 # Try raidstart first...if that fails then
695 # fall back to raid0run and if that fails too
696 # fall back to raidadd, raidrun.
698 if [ -x /sbin/raidstart ]; then
702 if [ $RESULT -gt 0 -a -x /sbin/raid0run ]; then
706 if [ $RESULT -gt 0 -a -x /sbin/raidadd -a -x /sbin/raidrun ]; then
711 if [ $RESULT -gt 0 ]; then
723 # A non-zero return means there were problems
724 if [ $rc -gt 0 ]; then
725 [ -e /proc/splash ] && echo "verbose" > /proc/splash
726 show "Starting up RAID devices"; fail
729 nls "*** An error occurred during the RAID startup."
730 nls "*** Dropping you to a shell; the system will reboot"
731 nls "*** when you leave the shell."
734 PS1="$(nls '(RAID Repair)# ')"; export PS1
735 [ "$SELINUX" = "1" ] && disable_selinux
736 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
742 run_cmd "Unmounting file systems" umount -a
743 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
744 run_cmd "Automatic reboot in progress" reboot
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" ] && ! strstr "$cmdline" 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
772 nls "*** An error occurred during the file system check."
773 nls "*** Dropping you to a shell; the system will reboot"
774 nls "*** when you leave the shell."
777 PS1="$(nls '(Repair filesystem)# ')"; export PS1
778 [ "$SELINUX" = "1" ] && disable_selinux
779 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
785 run_cmd "Unmounting file systems" umount -a
786 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
787 run_cmd "Automatic reboot in progress" reboot
788 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
791 rc_splash "fsck stop"
794 # Mount all other filesystems (except for NFS and /proc, which is already
795 # mounted). Contrary to standard usage,
796 # filesystems are NOT unmounted in single user mode.
798 run_cmd "Mounting local filesystems" mount -a -t nonfs,nfs4,smbfs,ncpfs,proc,cifs -O no_netdev
800 # now we have /usr mounted, recheck if we have gettext and tput available.
801 if is_no "$TPUT"; then
807 # Now do some workaround - encrypted filesystems couldn't have been fsck-ed
808 # before mount - that's where the password is entered.
809 # mount is buggy - when remounting loopback filesystem, loop=XXX
810 # option is removed from /etc/mtab
811 if [ -z "$fastboot" ] && grep "^[^#].*encryption=" /etc/fstab 2>/dev/null | grep -v -q "noauto" 2>/dev/null; then
812 show "Checking encrypted filesystems"; started
814 FILENAME=="/proc/mounts" {
817 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && /[^a-zA-Z_]ro[^a-zA-Z_]/ {
818 if ($2 in TAB){print TAB[$2];}
820 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ {
821 if ($2 in TAB){print TAB[$2];}
822 sub("loop(=[^,]*)?","loop=" TAB[$2] ",ro",$4);
823 cmd="mount " $2 " -o remount," $4;
826 ' /proc/mounts /etc/fstab)"
827 initlog -c "fsck -T -C -a $fsckoptions $LOOPLIST"
830 # A return of 2 or higher means there were serious problems.
831 if [ $rc -gt 1 ]; then
832 [ -e /proc/splash ] && echo "verbose" > /proc/splash
835 nls "*** An error occurred during the file system check."
836 nls "*** Dropping you to a shell; the system will reboot"
837 nls "*** when you leave the shell."
840 PS1="$(nls '(Repair filesystem)# ')"; export PS1
841 [ "$SELINUX" = "1" ] && disable_selinux
842 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
848 run_cmd "Unmounting file systems" umount -a
849 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
850 run_cmd "Automatic reboot in progress" reboot
851 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
855 show "Remounting encrypted filesystems back in rw mode"; busy
857 FILENAME=="/proc/mounts" {
860 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ {
861 sub("loop(=[^,]*)?","loop=" TAB[$2] ",rw",$4);
862 cmd="mount " $2 " -o remount," $4;
865 ' /proc/mounts /etc/fstab
869 # /var/log should be writable now, so start saving the boot output
870 if [ "$RC_BOOTLOG" ]; then
871 echo > /var/log/boot.log
875 if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then
876 run_cmd "Checking filesystem quotas" /sbin/quotacheck -vnugRa
880 if [ -x /sbin/quotaon ]; then
881 run_cmd "Turning on quotas for local filesystems" /sbin/quotaon -aug
884 emit --no-wait local-filesystems
886 # FIXME: this should be delayed until remote filesystems are mounted,
887 # especialy when /usr or other standard fs is remote
888 emit --no-wait filesystem
890 # Turn on process accounting
891 if [ -x /etc/rc.d/rc.acct ]; then
892 /etc/rc.d/rc.acct start
895 # Set the clock if timezone definition wasn't available (eg. /usr not mounted)
896 if is_yes "$TIME_SETUP_DELAYED" && [ -e /dev/rtc -o -e /dev/rtc0 ]; then
897 if run_cmd "$(nls 'Setting clock')" hwclock --hctosys; then
898 show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
902 # Initialize the serial ports
903 if [ -f /etc/rc.d/rc.serial ]; then
904 . /etc/rc.d/rc.serial
907 if [ -f /proc/sys/kernel/panic -a -n "$PANIC_REBOOT_TIME" -a "$PANIC_REBOOT_TIME" -gt "0" ]; then
908 show 'Setting %s seconds for kernel reboot after panic' "$PANIC_REBOOT_TIME"; busy
909 # NOTE: you should use /etc/sysctl.conf instead
910 if sysctl -w kernel.panic=$PANIC_REBOOT_TIME >/dev/null 2>&1; then ok; else fail; fi
913 # ... and here finish configuring parameters
914 sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
916 emit --no-wait root-filesystem
917 emit --no-wait virtual-filesystems
918 emit --no-wait local-filesystems
919 emit --no-wait filesystem
921 # /var/log should be writable now, so start saving the boot output
922 if [ "$RC_BOOTLOG" ]; then
923 echo > /var/log/boot.log
931 [ -n "$SELINUX" ] && [ -f /.autorelabel ] && relabel_selinux
934 rm -f /fastboot /fsckoptions /forcefsck /halt /poweroff >/dev/null 2>&1
937 # /usr could be still not mounted if it is on NFS.
938 for afile in /var/lock/* /var/run/*; do
940 if [ -d "$afile" ]; then
945 echo $afile/* | xargs rm -rf
949 [ "$bafile" != "hwprofile" -a "$bafile" != "random-seed" ] && rm -f $afile 2> /dev/null
954 rm -f /var/lib/rpm/__db* /var/spool/postoffice/.pid.* /tmp/.X*-lock \
955 /tmp/.lock.* /tmp/.gdm_socket /tmp/.s.PGSQL.*
956 rm -rf /tmp/.X*-unix /tmp/.ICE-unix /tmp/.font-unix /tmp/hsperfdata_* \
957 /tmp/kde-* /tmp/ksocket-* /tmp/mc-* /tmp/mcop-* /tmp/orbit-* \
958 /tmp/scrollkeeper-* /tmp/ssh-*
962 if ! is_no "$NEED_XFILES"; then
965 chown root:utmp /var/run/utmpx /var/log/wtmpx
966 chmod 0664 /var/run/utmpx /var/log/wtmpx
970 chown root:utmp /var/run/utmp /var/log/wtmp
971 chmod 0664 /var/run/utmp /var/log/wtmp
975 if is_yes "$CLEAN_TMP" && ! is_fsmounted tmpfs /tmp; then
976 LC_ALL=C rm -rf /tmp/* /tmp/.[a-zA-Z0-9]*
979 # System protected dirs
980 mkdir -m 1777 -p /tmp/.ICE-unix > /dev/null 2>&1
981 chown root:root /tmp/.ICE-unix
982 [ -n "$SELINUX" ] && restorecon /tmp/.ICE-unix >/dev/null 2>&1
984 if ! is_yes "$VSERVER"; then
985 run_cmd "Enabling swap space" true
986 # Right, now turn on swap in case we swap to files
987 swapon -a >/dev/null 2>&1
988 emit --no-wait all-swaps
990 # If a SCSI tape has been detected, load the st module unconditionally
991 # since many SCSI tapes don't deal well with st being loaded and unloaded
992 if [ -f /proc/scsi/scsi ] && grep -q 'Type: Sequential-Access' /proc/scsi/scsi 2>/dev/null ; then
993 if grep -qv ' 9 st' /proc/devices 2>/dev/null; then
994 if [ -n "$USEMODULES" ] ; then
995 # Try to load the module. If it fails, ignore it...
996 insmod -p st >/dev/null 2>&1 && modprobe -s st >/dev/null 2>&1
1001 # Now that we have all of our basic modules loaded and the kernel going,
1002 # let's dump the syslog ring somewhere so we can find it later
1003 dmesg > /var/log/dmesg
1005 while [ $i -ge 0 ]; do
1006 if [ -f /var/log/dmesg.$i ]; then
1007 chmod 0600 /var/log/dmesg.$i
1008 mv -f /var/log/dmesg.$i /var/log/dmesg.$(($i+1))
1012 cp -f /var/log/dmesg /var/log/dmesg.0
1013 chmod 0600 /var/log/dmesg /var/log/dmesg.0
1015 emit --no-wait all-swaps
1018 if ! is_no "$RC_PROMPT"; then
1020 pid=$(/sbin/pidof getkey)
1021 [ -n "$pid" -o -e /var/run/getkey_done ] && break
1024 [ -n "$pid" ] && kill -TERM "$pid" >/dev/null 2>&1
1028 # /proc extra check if the background process we just spawned is still running,
1029 # as in case of vserver bootup it finishes quite instantly.
1030 if ! is_no "$RC_PROMPT" && [ -d /proc/$! ]; then
1031 /sbin/getkey i && touch /var/run/confirm
1032 touch /var/run/getkey_done
1035 if ! is_no "$RC_PROMPT"; then
1036 rm -f /var/run/getkey_done
1040 emit --no-wait pld.sysinit-done