3 # /etc/rc.d/rc.sysinit - run once at boot time
6 # Taken in part from Miquel van Smoorenburg's bcheckrc.
7 # Changes: Arkadiusz Mi¶kiewicz <misiek@pld-linux.org>
11 PATH=/bin:/sbin:/usr/bin:/usr/sbin
14 # reasonable start values for bootsplash progress.
19 # we need /proc mounted before everything
20 mount -n -o gid=17 -t proc /proc /proc
23 if [ -r /etc/sysconfig/i18n ]; then
25 [ -n "$LANG" ] && export LANG || unset LANG
26 [ -n "$LC_CTYPE" ] && export LC_CTYPE || unset LC_CTYPE
27 [ -n "$LC_COLLATE" ] && export LC_COLLATE || unset LC_COLLATE
28 [ -n "$LC_MESSAGES" ] && export LC_MESSAGES || unset LC_MESSAGES
29 [ -n "$LC_NUMERIC" ] && export LC_NUMERIC || unset LC_NUMERIC
30 [ -n "$LC_MONETARY" ] && export LC_MONETARY || unset LC_MONETARY
31 [ -n "$LC_TIME" ] && export LC_TIME || unset LC_TIME
32 [ -n "$LC_ALL" ] && export LC_ALL || unset LC_ALL
33 [ -n "$LANGUAGE" ] && export LANGUAGE || unset LANGUAGE
34 [ -n "$LINGUAS" ] && export LINGUAS || unset LINGUAS
37 # Read network config data
38 if [ -r /etc/sysconfig/network ]; then
39 . /etc/sysconfig/network
45 # Read system config data
46 if [ -r /etc/sysconfig/system ]; then
47 . /etc/sysconfig/system
49 RUN_SULOGIN_ON_ERR=yes
61 . /etc/rc.d/init.d/functions
63 # sysfs is also needed before any other things (under kernel > 2.5)
64 if ! is_yes "$VSERVER" && grep -q sysfs /proc/filesystems 2>/dev/null ; then
65 mount -n -o gid=17 -t sysfs sysfs /sys
66 if [ "$(kernelver)" -ge "002006014" ] && \
67 grep -q securityfs /proc/filesystems 2>/dev/null ; then
68 mount -n -o gid=17 -t securityfs securityfs /sys/kernel/security
74 if ! is_yes "$VSERVER" && grep -q selinuxfs /proc/filesystems 2>/dev/null && ! grep -q selinuxfs /proc/mounts 2>/dev/null; then
75 mount -n -o gid=17 -t selinuxfs selinuxfs /selinux
78 if [ $(kernelverser) = "002006" ]; then
79 MODULES_CONF=/etc/modprobe.conf
80 elif [ -r /etc/modules.conf ]; then
81 MODULES_CONF=/etc/modules.conf
83 MODULES_CONF=/etc/conf.modules
87 if [ -x /etc/rc.d/rc.live ]; then
91 # Choose Hardware profile
92 if [ -f /etc/sysconfig/hwprof ]; then
93 . /etc/sysconfig/hwprof
94 if is_yes "${HWPROFILES}" && [ -x /sbin/hwprofile -a -d /etc/sysconfig/hwprofiles/data ]; then
95 mount -n / -o rw,remount
97 mount -n / -o ro,remount
101 # Disable splash when requested
102 [ -e /proc/splash ] && is_no "$BOOT_SPLASH" && echo "0" > /proc/splash
104 # Check SELinux status
105 selinuxfs=$(awk '/ selinuxfs / { print $2 }' /proc/mounts)
107 if [ -n "$selinuxfs" ] && [ "$(cat /proc/self/attr/current)" != "kernel" ]; then
108 if [ -r $selinuxfs/enforce ] ; then
109 SELINUX=$(cat $selinuxfs/enforce)
111 # assume enforcing if you can't read it
116 if [ -x /sbin/restorecon ] && LC_ALL=C fgrep -q " /dev " /proc/mounts 2>/dev/null ; then
117 /sbin/restorecon -R /dev 2>/dev/null
121 if [ "$CONSOLETYPE" = "vt" -a -x /sbin/setsysfont ]; then
125 # Print welcome message
126 nls "\t\t\t%sPowered by %sPLD Linux Distribution%s" "$(termput setaf $CPOWEREDBY)" "$(termput setaf $CPLD)" "$(termput op)"
127 if is_yes "$PROMPT"; then
128 nls -n "\t\t Press %sI%s to enter interactive startup" "$(termput setaf $CI)" "$(termput op)"
134 run_cmd "$(nls 'Host:') ${HOSTNAME}" hostname ${HOSTNAME}
136 # Set the NIS domain name
137 if [ -n "$NISDOMAIN" ]; then
138 run_cmd "$(nls 'NIS Domain:') ${NISDOMAIN}" domainname $NISDOMAIN
143 if ! is_yes "$VSERVER"; then
144 # Set console loglevel
145 if [ -n "$CONSOLE_LOGLEVEL" ]; then
146 /bin/dmesg -n $CONSOLE_LOGLEVEL
149 if [ -f /etc/udev/udev.conf ];then
150 . /etc/udev/udev.conf
153 [ -x /sbin/start_udev ] && run_cmd "Starting udev" /sbin/start_udev
155 # /dev must be also mounted before everything but only if we want use them ;-)
156 if is_yes "$MOUNT_DEVFS"; then
157 run_cmd "Mounting Device Filesystem" mount -n -t devfs /dev /dev
161 if [ -e /dev/.devfsd -a -x /sbin/devfsd ]; then
162 run_cmd "Starting Device Filesystem Daemon" /sbin/devfsd /dev
165 # cpuset support (mounted unconditionally, shouldn't be a problem)
166 if grep -q cpuset /proc/filesystems 2>/dev/null ; then
167 mount -n -t cpuset none /dev/cpuset
170 # Configure Linux kernel (initial configuration, some required modules still
172 /sbin/sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
174 # Set the system clock.
179 if [ -f /etc/sysconfig/clock ]; then
180 . /etc/sysconfig/clock
182 # convert old style clock config to new values
183 if [ "${CLOCKMODE}" = "GMT" ]; then
185 elif [ "${CLOCKMODE}" = "ARC" ]; then
190 if grep "system serial" /proc/cpuinfo 2>/dev/null | grep -q MILO 2>/dev/null ; then
195 CLOCKFLAGS="--hctosys"
197 if is_yes "$UTC" ; then
198 CLOCKFLAGS="$CLOCKFLAGS --utc"
199 CLOCKDEF="$CLOCKDEF (utc)"
201 CLOCKFLAGS="$CLOCKFLAGS --localtime"
202 CLOCKDEF="$CLOCKDEF (local)"
205 if is_yes "$ARC" ; then
206 CLOCKFLAGS="$CLOCKFLAGS -A"
207 CLOCKDEF="$CLOCKDEF (arc)"
210 if is_yes "$SRM" ; then
211 CLOCKFLAGS="$CLOCKFLAGS -S"
212 CLOCKDEF="$CLOCKDEF (srm)"
215 # Check if timezone definition is available
216 if [ -e /etc/localtime ] ; then
217 if run_cmd "$(nls 'Setting clock')$CLOCKDEF" /sbin/hwclock $CLOCKFLAGS; then
218 show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
221 TIME_SETUP_DELAYED=yes
225 run_cmd "Activating swap partitions" swapon -a -e
227 # Initialize USB controllers
229 if ! grep -iq "nousb" /proc/cmdline 2>/dev/null && ! grep -q "/proc/bus/usb" /proc/mounts 2>/dev/null ; then
230 aliases=$(/sbin/modprobe -c | awk '/^alias usb-controller/ { print $3 }')
231 if [ -n "$aliases" -a "$aliases" != "off" ] ; then
232 /sbin/modprobe -s -k usbcore
233 for alias in $aliases ; do
234 [ "$alias" = "off" ] && continue
235 run_cmd "$(nls 'Initializing USB controller') ($alias)" /sbin/modprobe -s $alias
237 [ $? -eq 0 -a -n "$aliases" ] && usb=1
239 if grep -iq "usb" /proc/devices 2>/dev/null ; then
244 if [ "$usb" = "1" -a ! -f /proc/bus/usb/devices ]; then
245 run_cmd "Mounting USB filesystem" mount -t usbfs usbfs /proc/bus/usb
249 if [ "$usb" = "1" ]; then
250 needusbstorage=$(LC_ALL=C cat /proc/bus/usb/devices 2>/dev/null|grep -e "^I.*Cls=08" 2>/dev/null)
251 if [ "$(kernelverser)" -lt "002006" ]; then
252 LC_ALL=C grep -q 'hid' /proc/bus/usb/drivers 2>/dev/null || run_cmd "Initializing USB HID interface" modprobe hid 2> /dev/null
253 mouseoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=02" 2>/dev/null)
254 kbdoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=01" 2>/dev/null)
255 if [ -n "$kbdoutput" ]; then
256 run_cmd "Initializing USB keyboard" modprobe keybdev
258 if [ -n "$mouseoutput" ]; then
259 run_cmd "Initializing USB mouse" modprobe mousedev
264 # Setup hdparm thing (if exists and is needed)
265 if ! grep -iq nohdparm /proc/cmdline 2>/dev/null; then
266 [ -x /etc/rc.d/rc.hdparm ] && /etc/rc.d/rc.hdparm
269 if [ -f /fastboot ] || grep -iq "fastboot" /proc/cmdline 2>/dev/null ; then
275 if [ -f /fsckoptions ]; then
276 fsckoptions=$(cat /fsckoptions)
281 if [ -f /forcefsck ]; then
282 fsckoptions="-f $fsckoptions"
286 _ROOTFS_TYPE=$(grep " / " /proc/mounts 2>/dev/null | awk '{ print $3 }')
288 if [ -z "$fastboot" -a "$_ROOTFS_TYPE" != "nfs" -a "$_ROOTFS_TYPE" != "romfs" ]; then
289 show "Checking root filesystem"; started
290 initlog -c "fsck -C -T -a $fsckoptions /"
294 # A return of 4 or higher means there were serious problems.
295 if [ $rc -gt 3 ]; then
296 [ -e /proc/splash ] && echo "verbose" > /proc/splash
297 # don't use '\n' in nls macro !
300 nls "*** An error occurred during the file system check."
301 nls "*** Dropping you to a shell; the system will reboot"
302 nls "*** when you leave the shell."
305 PS1="$(nls '(Repair filesystem)# ')"; export PS1
306 [ "$SELINUX" = "1" ] && disable_selinux
307 if is_yes "$RUN_SULOGIN_ON_ERR"; then
313 run_cmd "Unmounting file systems" umount -a
314 mount -n -o remount,ro /
315 run_cmd "Automatic reboot in progress" reboot
316 # A return of 2 or 3 means that filesystem was repaired but we need
318 elif [ "$rc" = "2" -o "$rc" = "3" ]; then
319 [ -e /proc/splash ] && echo "verbose" > /proc/splash
321 nls "*** Filesystem was repaired but system needs to be"
322 nls "*** rebooted before mounting it."
323 nls "*** REBOOTING ***"
326 run_cmd "Unmounting file systems" umount -a
327 mount -n -o remount,ro /
328 run_cmd "Automatic reboot in progress" reboot
329 elif [ "$rc" = "1" ]; then
334 # Unmount the initrd, if necessary
335 if LC_ALL=C grep -q /initrd /proc/mounts 2>/dev/null && ! LC_ALL=C grep -q /initrd/loopfs /proc/mounts 2>/dev/null ; then
336 if [ -e /initrd/dev/.devfsd ]; then
340 /sbin/blockdev --flushbufs /dev/ram0 >/dev/null 2>&1
343 # Check for arguments
344 if grep -iq nopnp /proc/cmdline 2>/dev/null; then
350 # set up pnp and kernel pnp
351 if [ -n "$PNP" ]; then
352 if is_yes "$RUN_USERPNP" && [ -x /sbin/isapnp -a -f /etc/isapnp/isapnp.conf ]; then
353 run_cmd "Setting up ISA PNP devices (userspace pnp)" /sbin/isapnp /etc/isapnp/isapnp.conf
355 if is_yes "$RUN_KERNELPNP"; then
356 /sbin/modprobe -k isa-pnp 2> /dev/null
357 if [ -e /proc/isapnp -a -f /etc/isapnp/isapnp-kernel.conf ]; then
358 show "Setting up ISA PNP devices (kernelspace pnp)"; busy
359 grep -v "^#" /etc/isapnp/isapnp-kernel.conf 2>/dev/null >/proc/isapnp && (deltext; ok) || (deltext; fail)
364 # Remount the root filesystem read-write
365 run_cmd "Remounting root filesystem in rw mode" mount -n -o remount,rw /
367 # Update quotas if fsck was run on /
368 if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then
369 run_cmd "Checking root filesystem quotas" /sbin/quotacheck -vnug /
373 # Clean up SELinux labels
374 if [ -n "$SELINUX" ]; then
375 for file in /etc/mtab /etc/cryptomtab /etc/ld.so.cache ; do
376 [ -r $file ] && restorecon $file >/dev/null 2>&1
380 # Remove stale backups
381 rm -f /etc/mtab~ /etc/mtab~~ /etc/cryptomtab~ /etc/cryptomtab~~
383 if ! is_yes "$VSERVER"; then
386 [ -f /etc/cryptomtab ] && :>/etc/cryptomtab
388 # Enter root, /proc, /sys, devfs and other into mtab.
391 [ -f /proc/bus/usb/devices ] && mount -f -t usbfs usbfs /proc/bus/usb
392 [ -e /dev/.devfsd ] && mount -f -t devfs devfs /dev
394 if grep -q sysfs /proc/filesystems 2>/dev/null ; then
395 mount -f -t sysfs sysfs /sys
396 if [ "$(kernelver)" -ge "002006014" ] && \
397 grep -q securityfs /proc/filesystems 2>/dev/null ; then
398 mount -f -t securityfs securityfs /sys/kernel/security
402 if grep -q selinuxfs /proc/filesystems 2>/dev/null ; then
403 mount -f -t selinuxfs selinuxfs /selinux
406 if grep -q cpuset /proc/filesystems 2>/dev/null ; then
407 mount -n -t cpuset none /dev/cpuset
413 # Remove /etc/nologin when starting system
414 [ -f /etc/nologin.boot ] && rm -f /etc/nologin /etc/nologin.boot
416 if is_yes "$DELAY_LOGIN" && [ ! -f /etc/nologin ]; then
417 show "Enabling Delay Login"; busy
419 nls "System bootup in progress - please wait" >> /etc/nologin
421 chmod 644 /etc/nologin
422 cp -fp /etc/nologin /etc/nologin.boot
426 # The root filesystem is now read-write, so we can now log via
427 # syslog() directly...
428 if [ -n "$IN_INITLOG" ]; then
432 if ! is_yes "$VSERVER"; then
433 if [ ! -f /proc/modules ]; then
435 elif ! grep -iq nomodules /proc/cmdline 2>/dev/null; then
441 # Adjust symlinks as necessary in /boot to keep system services from
442 # spewing messages about mismatched System maps and so on.
443 if is_yes "$SET_SLINKS"; then
444 if [ -L /boot/System.map -a -r /boot/System.map-`uname -r` ] ; then
445 ln -s -f System.map-`uname -r` /boot/System.map
447 if [ ! -e /boot/System.map -a -r /boot/System.map-`uname -r` ] ; then
448 ln -s -f System.map-`uname -r` /boot/System.map
452 # Run depmod if RUN_DEPMOD != "no" and:
453 # a) user requested or RUN_DEPMOD="";
454 # b) modules.dep is missing
455 # c) modules.dep is older than /etc/modules.conf or /lib/modules/`uname -r`
456 if ! is_no "$RUN_DEPMOD" && [ -n "$USEMODULES" ]; then
457 if is_yes "$RUN_DEPMOD" || [ -z "$RUN_DEPMOD" ]; then
458 run_cmd "Finding module dependencies" depmod -a
459 elif [ "$RUN_DEPMOD" = "ifmissing" ]; then
460 run_cmd "Finding module dependencies" depmod -A
464 if [ -f /proc/sys/kernel/modprobe ]; then
465 if [ -n "$USEMODULES" ]; then
466 sysctl -w kernel.modprobe="/sbin/modprobe" >/dev/null 2>&1
468 # We used to set this to NULL, but that causes
469 # 'failed to exec' messages"
470 sysctl -w kernel.modprobe="/bin/true" >/dev/null 2>&1
474 # Load usb storage here, to match most other things
475 if [ -n "$needusbstorage" ]; then
476 modprobe -k usb-storage >/dev/null 2>&1
479 # Load firewire devices
480 if ! grep -iq "nofirewire" /proc/cmdline 2>/dev/null ; then
481 aliases=$(/sbin/modprobe -c | awk '/^alias ieee1394-controller/ { print $3 }')
482 if [ -n "$aliases" -a "$aliases" != "off" ] ; then
483 for alias in $aliases ; do
484 [ "$alias" = "off" ] && continue
485 run_cmd "$(nls 'Initializing firewire controller') ($alias)" /sbin/modprobe $alias
487 LC_ALL=C grep -E "SBP2" /proc/bus/ieee1394/devices 2>/dev/null && /sbin/modprobe -s sbp2 > /dev/null 2>&1
491 # Load sound modules if they need persistent DMA buffers
492 if grep -q "^options sound dmabuf=1" "$MODULES_CONF" 2>/dev/null ; then
494 alias=$(/sbin/modprobe -c | egrep -s "^alias[[:space:]]+sound[[:space:]]+" 2>/dev/null | awk '{ print $3 }')
495 if [ -n "$alias" -a "$alias" != "off" ] ; then
496 run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias
499 alias=$(/sbin/modprobe -c | egrep -s "^alias[[:space:]]+sound-slot-0[[:space:]]+" 2>/dev/null | awk '{ print $3 }')
500 if [ -n "$alias" -a "$alias" != "off" ] ; then
501 run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias
507 if [ -x /etc/rc.d/rc.modules ]; then
511 # Find and activate volume groups:
513 if [ -x /sbin/evms_activate ]; then
514 if [ "$(kernelverser)" -lt "002006" ]; then
515 # Linux 2.4 core modules
516 modprobe -s -k evms > /dev/null 2>&1
517 modprobe -s -k evms_passthru > /dev/null 2>&1
518 modprobe -s -k ldev_mgr > /dev/null 2>&1
519 modprobe -s -k dos_part > /dev/null 2>&1
521 # Linux 2.6 core module
522 modprobe -s -k evmscore > /dev/null 2>&1
525 is_yes "$EVMS_GUID_PTABLE" && modprobe -s -k gpt_part >/dev/null 2>&1
526 is_yes "$EVMS_LVM" && modprobe -s -k lvm_vge >/dev/null 2>&1
527 is_yes "$EVMS_AIX" && modprobe -s -k AIXlvm_vge >/dev/null 2>&1
528 is_yes "$EVMS_OS2" && modprobe -s -k os2lvm_vge >/dev/null 2>&1
529 run_cmd "Discovering EVMS volumes" /sbin/evms_activate
530 if is_yes "$EVMS_LVM" && is_yes "$EVMS_LVM_COMPAT_NODES" ; then
531 # Link nodes for compatibility with LVM
532 if [ "echo /dev/evms/lvm/*" != '/dev/evms/lvm/*' ] ; then
533 ln -s /dev/evms/lvm/* /dev/
537 # LVM (keep in sync with LVM starting after RAID run!)
538 if is_yes "$EVMS_LVM" || [ -x /sbin/vgscan -a -x /sbin/vgchange ]; then
539 lvmversion=$(/sbin/vgchange --version 2>/dev/null | awk '{gsub("vgchange: Logical Volume Manager ",""); gsub("LVM version: ",""); gsub(/\..*/,"");print $1; exit}')
540 if [ "$lvmversion" = "1" ] ; then
541 modprobe -s -k lvm-mod >/dev/null 2>&1
543 elif [ "$lvmversion" = "2" ] ; then
544 modprobe -s -k dm-mod >/dev/null 2>&1
545 lvmignorelock="--ignorelockingfailure"
547 modprobe -s -k lvm-mod >/dev/null 2>&1
548 # device mapper (2.5+ and patched 2.4)
549 modprobe -s -k dm-mod >/dev/null 2>&1
553 run_cmd "Scanning for LVM volume groups" /sbin/vgscan $lvmignorelock && \
554 run_cmd "Activating LVM volume groups" /sbin/vgchange -a y $lvmignorelock
555 [ "$lvmversion" = "2" ] && /sbin/vgscan --mknodes $lvmignorelock > /dev/null 2>&1
560 if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ] || [ -f /etc/raidtab ]; then
561 modprobe -s md >/dev/null 2>&1
562 if [ -f /proc/mdstat ]; then
566 if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ]; then
567 if (grep -qE "^([[:blank:]]|)ARRAY[[:blank:]]" /etc/mdadm.conf 2>/dev/null); then
568 run_cmd "Starting up RAID devices" /sbin/mdadm --assemble --scan
570 [ "$rc" -eq 0 ] && goraidtab=0 && golvm=1
574 if [ -f /etc/raidtab -a "$goraidtab" -eq 1 ]; then
575 for i in $(grep -v "^#" /etc/raidtab 2>/dev/null | grep "raiddev" 2>/dev/null | awk '{print $2}') ; do
577 RAIDDEV=$(basename $i)
578 RAIDSTAT=$(grep "^$RAIDDEV : active" /proc/mdstat 2>/dev/null)
579 show "Starting up RAID device %s" $RAIDDEV
581 if [ -z "$RAIDSTAT" ]; then
582 # Try raidstart first...if that fails then
583 # fall back to raid0run and if that fails too
584 # fall back to raidadd, raidrun.
586 if [ -x /sbin/raidstart ]; then
590 if [ $RESULT -gt 0 -a -x /sbin/raid0run ]; then
594 if [ $RESULT -gt 0 -a -x /sbin/raidadd -a -x /sbin/raidrun ]; then
599 if [ $RESULT -gt 0 ]; then
611 # A non-zero return means there were problems
612 if [ $rc -gt 0 ]; then
613 [ -e /proc/splash ] && echo "verbose" > /proc/splash
614 show "Starting up RAID devices"; fail
617 nls "*** An error occurred during the RAID startup."
618 nls "*** Dropping you to a shell; the system will reboot"
619 nls "*** when you leave the shell."
622 PS1="$(nls '(RAID Repair)# ')"; export PS1
623 [ "$SELINUX" = "1" ] && disable_selinux
624 if is_yes "$RUN_SULOGIN_ON_ERR"; then
630 run_cmd "Unmounting file systems" umount -a
631 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
632 run_cmd "Automatic reboot in progress" reboot
634 # LVM on RAID (keep in sync with LVM setting few lines above)
635 if [ "$golvm" -eq "1" ]; then
636 if is_yes "$EVMS_LVM" || [ -x /sbin/vgscan -a -x /sbin/vgchange ]; then
637 run_cmd "Scanning for LVM volume groups (on RAID)" /sbin/vgscan $lvmignorelock && \
638 run_cmd "Activating LVM volume groups (on RAID)" /sbin/vgchange -a y $lvmignorelock
639 [ "$lvmversion" = "2" ] && /sbin/vgscan --mknodes $lvmignorelock > /dev/null 2>&1
642 show "Starting up RAID devices"; ok
648 if [ -z "$fastboot" ] && ! grep -q nofsck /proc/cmdline 2>/dev/null; then
649 rc_splash "fsck start"
650 show "Checking filesystems"; started
651 initlog -c "fsck -C -T -R -A -a $fsckoptions"
655 # A return of 2 or higher means there were serious problems
656 if [ $rc -gt 1 ]; then
657 [ -e /proc/splash ] && echo "verbose" > /proc/splash
660 nls "*** An error occurred during the file system check."
661 nls "*** Dropping you to a shell; the system will reboot"
662 nls "*** when you leave the shell."
665 PS1="$(nls '(Repair filesystem)# ')"; export PS1
666 [ "$SELINUX" = "1" ] && disable_selinux
667 if is_yes "$RUN_SULOGIN_ON_ERR"; then
673 run_cmd "Unmounting file systems" umount -a
674 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
675 run_cmd "Automatic reboot in progress" reboot
676 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
679 rc_splash "fsck stop"
682 # Mount all other filesystems (except for NFS and /proc, which is already
683 # mounted). Contrary to standard usage,
684 # filesystems are NOT unmounted in single user mode.
686 run_cmd "Mounting local filesystems" mount -a -t nonfs,smbfs,ncpfs,proc,cifs -O no_netdev
688 # Now do some workaround - encrypted filesystems couldn't have been fsck-ed
689 # before mount - that's where the password is entered.
690 # mount is buggy - when remounting loopback filesystem, loop=XXX
691 # option is removed from /etc/mtab
692 if [ -z "$fastboot" ] && grep "^[^#].*encryption=" /etc/fstab 2>/dev/null | grep -v -q "noauto" 2>/dev/null; then
693 show "Checking encrypted filesystems"; started
695 FILENAME=="/proc/mounts" {
698 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && /[^a-zA-Z_]ro[^a-zA-Z_]/ {
699 if ($2 in TAB){print TAB[$2];}
701 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ {
702 if ($2 in TAB){print TAB[$2];}
703 sub("loop(=[^,]*)?","loop=" TAB[$2] ",ro",$4);
704 cmd="mount " $2 " -o remount," $4;
707 ' /proc/mounts /etc/fstab)"
708 initlog -c "fsck -T -C -a $fsckoptions $LOOPLIST"
711 # A return of 2 or higher means there were serious problems.
712 if [ $rc -gt 1 ]; then
713 [ -e /proc/splash ] && echo "verbose" > /proc/splash
716 nls "*** An error occurred during the file system check."
717 nls "*** Dropping you to a shell; the system will reboot"
718 nls "*** when you leave the shell."
721 PS1="`nls '(Repair filesystem)# '`"; export PS1
722 [ "$SELINUX" = "1" ] && disable_selinux
723 if is_yes "$RUN_SULOGIN_ON_ERR"; then
729 run_cmd "Unmounting file systems" umount -a
730 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
731 run_cmd "Automatic reboot in progress" reboot
732 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
736 show "Remounting encrypted filesystems back in rw mode"; busy
738 FILENAME=="/proc/mounts" {
741 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ {
742 sub("loop(=[^,]*)?","loop=" TAB[$2] ",rw",$4);
743 cmd="mount " $2 " -o remount," $4;
746 ' /proc/mounts /etc/fstab
751 if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then
752 run_cmd "Checking filesystem quotas" /sbin/quotacheck -vnugRa
756 if [ -x /sbin/quotaon ]; then
757 run_cmd "Turning on quotas for local filesystems" /sbin/quotaon -aug
760 [ -n "$SELINUX" ] && [ -f /.autorelabel ] && relabel_selinux
762 # Turn on process accounting
763 if [ -x /etc/rc.d/rc.acct ]; then
764 /etc/rc.d/rc.acct start
767 if ! is_yes "$VSERVER"; then
768 # Set the clock if timezone definition wasn't available (eg. /usr not mounted)
769 if is_yes "$TIME_SETUP_DELAYED"; then
770 if run_cmd "$(nls 'Setting clock')$CLOCKDEF" /sbin/hwclock $CLOCKFLAGS; then
771 show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
775 # Initialize the serial ports
776 if [ -f /etc/rc.d/rc.serial ]; then
777 . /etc/rc.d/rc.serial
780 if [ -f /proc/sys/kernel/panic -a "$PANIC_REBOOT_TIME" -gt "0" ]; then
781 show 'Setting %s seconds for kernel reboot after panic' "$PANIC_REBOOT_TIME"; busy
782 if (sysctl -w kernel.panic=$PANIC_REBOOT_TIME >/dev/null 2>&1); then ok; else fail; fi
785 # ... and here finish configuring parameters
786 /sbin/sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
790 rm -f /fastboot /fsckoptions /forcefsck /halt /poweroff
793 # I'd use find, but /usr may not be mounted.
794 for afile in /var/lock/* /var/run/*; do
795 bafile=$(basename $afile)
796 if [ -d "$afile" ]; then
797 [ "$bafile" != "news" -a "$bafile" != "sudo" -a "$bafile" != "mon" ] && rm -rf $afile/*
799 [ "$bafile" != "hwprofile" ] && rm -f $afile 2> /dev/null
803 rm -f /var/lib/rpm/__db* /var/spool/postoffice/.pid.* /tmp/.X*-lock \
804 /tmp/.lock.* /tmp/.gdm_socket /tmp/.s.PGSQL.*
805 rm -rf /tmp/.X*-unix /tmp/.ICE-unix /tmp/.font-unix /tmp/hsperfdata_* \
806 /tmp/kde-* /tmp/ksocket-* /tmp/mc-* /tmp/mcop-* /tmp/orbit-* \
807 /tmp/scrollkeeper-* /tmp/ssh-*
811 if ! is_no "$NEED_XFILES" ; then
814 chown root.utmp /var/run/utmpx /var/log/wtmpx
815 chmod 0664 /var/run/utmpx /var/log/wtmpx
819 chown root.utmp /var/run/utmp /var/log/wtmp
820 chmod 0664 /var/run/utmp /var/log/wtmp
824 if is_yes "$CLEAN_TMP"; then
825 rm -rf /tmp/* /tmp/.[a-zA-Z0-9]*
828 # System protected dirs
829 mkdir -m 1777 -p /tmp/.ICE-unix > /dev/null 2>&1
830 chown root:root /tmp/.ICE-unix
831 [ -n "$SELINUX" ] && restorecon /tmp/.ICE-unix >/dev/null 2>&1
833 # Right, now turn on swap in case we swap to files
834 swapon -a >/dev/null 2>&1
835 run_cmd "Enabling swap space" /bin/true
837 # If a SCSI tape has been detected, load the st module unconditionally
838 # since many SCSI tapes don't deal well with st being loaded and unloaded
839 if [ -f /proc/scsi/scsi ] && grep -q 'Type: Sequential-Access' /proc/scsi/scsi 2>/dev/null ; then
840 if grep -qv ' 9 st' /proc/devices 2>/dev/null; then
841 if [ -n "$USEMODULES" ] ; then
842 # Try to load the module. If it fails, ignore it...
843 insmod -p st >/dev/null 2>&1 && modprobe -s st >/dev/null 2>&1
848 # There could be a new kernel version. Remove old psdevtab database
851 if ! is_yes "$VSERVER"; then
852 # Now that we have all of our basic modules loaded and the kernel going,
853 # let's dump the syslog ring somewhere so we can find it later
854 dmesg -s 131072 > /var/log/dmesg
856 while [ $i -ge 0 ]; do
857 if [ -f /var/log/dmesg.$i ]; then
858 chmod 0600 /var/log/dmesg.$i
859 mv -f /var/log/dmesg.$i /var/log/dmesg.$(($i+1))
863 cp -f /var/log/dmesg /var/log/dmesg.0
864 chmod 0600 /var/log/dmesg /var/log/dmesg.0
867 kill -TERM $(/sbin/pidof getkey) >/dev/null 2>&1
869 if is_yes "$PROMPT"; then
870 /sbin/getkey i && touch /var/run/confirm
875 # This must be last line !