CONSOLE_LOGLEVEL=1
# Read functions
-. /etc/rc.d/init.d/functions
+. /lib/rc-scripts/functions
disable_selinux() {
local _d selinuxfs _t _r
# Loads modules from /etc/modules, /etc/modules.X.Y and /etc/modules.X.Y.Z
load_kernel_modules() {
+ local modules_file=$1
+ local _x _y _z v v1 old_IFS kernel kerneleq
{
- local _x _y v _z
- read _x _y v _z
+ read _x _y v _z
old_IFS=$IFS
- IFS='.'
+ # strip _* or -* from versions like: "2.6.25_vanilla-1", "2.6.25-1"
+ IFS='_-'
set -- $v
+ v1=${1}
+ IFS='.'
+ set -- $v1
IFS=$old_IFS
+
kernel="$1.$2"
kerneleq="$1.$2.$3"
} < /proc/version
local module args
# Loop over every line in modules file
( \
- grep -hvE '^(#|[[:blank:]]*$)' /etc/modules /etc/modules.$kernel /etc/modules.$kerneleq 2>/dev/null
+ grep -hvE '^(#|[[:blank:]]*$)' /etc/$modules_file /etc/$modules_file.$kernel /etc/$modules_file.$kerneleq 2>/dev/null
echo '' # make sure there is a LF at the end
) | while read module args; do
[ -z "$module" ] && continue
# strip comments
args=${args%%#*}
- modprobe -s $module -- $args
+ show "Loading %s kernel module(s)" "$module"
+ busy
+ modprobe -s $module -- $args && ok || fail
done
}
fi
# we need /proc mounted before everything
- is_fsmounted proc /proc || mount -n -o gid=17 -t proc /proc /proc
+ is_fsmounted proc /proc || mount -n /proc || mount -n -o gid=17,hidepid=2 -t proc /proc /proc
+
+ # Early sysctls
+ sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
# Only read this once.
cmdline=$(cat /proc/cmdline)
dmesg -n $CONSOLE_LOGLEVEL
fi
- if ! is_no "$START_UDEV" && [ -x /sbin/start_udev ]; then
+ if ! is_no "$START_UDEV" && [ -x /sbin/start_udev ] && [[ "$container" != lxc* ]]; then
+ is_fsmounted devtmpfs /dev || mount -n -t devtmpfs devtmpfs /dev
+ load_kernel_modules modules.preudev
/sbin/start_udev
[ -x /sbin/initctl ] && /sbin/initctl -q start udev
elif [ -x /lib/firmware/firmware-loader.sh ]; then
_ROOTFS_DEVICE=$(awk '($1 !~ /^#/ && $2 == "/" && NF >= 6) { print $1}' /etc/fstab)
_ROOTFS_TYPE=$(awk '$2 == "/" && $3 != "rootfs" { print $3 }' /proc/mounts 2>/dev/null)
- 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 ]; then
+ 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
check_root_fs
fi
[ -f /etc/cryptomtab ] && :>/etc/cryptomtab
# Enter root, /proc, /sys and other into mtab.
- mount -f /
- mount -f /proc
+ mount -f / 2> /dev/null
+ mount -f /proc 2> /dev/null
+ if is_fsmounted devtmpfs /dev; then
+ mount -f -t devtmpfs devtmpfs /dev 2> /dev/null
+ fi
if is_fsmounted tmpfs /run; then
- mount -f -t tmpfs run /run
+ mount -f -t tmpfs run /run 2> /dev/null
fi
if is_fsmounted usbfs /proc/bus/usb; then
- mount -f -t usbfs -o devgid=78,devmode=664 usbfs /proc/bus/usb
+ mount -f -t usbfs -o devgid=78,devmode=664 usbfs /proc/bus/usb 2> /dev/null
fi
if is_fsmounted sysfs /sys; then
- mount -f -t sysfs sysfs /sys
+ mount -f -t sysfs sysfs /sys 2> /dev/null
if is_fsmounted securityfs /sys/kernel/security ; then
- mount -f -t securityfs securityfs /sys/kernel/security
+ mount -f -t securityfs securityfs /sys/kernel/security 2> /dev/null
fi
fi
if is_fsmounted selinuxfs /selinux; then
- mount -f -t selinuxfs selinuxfs /selinux
+ mount -f -t selinuxfs selinuxfs /selinux 2> /dev/null
fi
emit --no-wait root-filesystem
fi
# Load modules
- load_kernel_modules
+ if ! use_upstart; then
+ load_kernel_modules modules
+ for f in /etc/modules-load.d/*.conf; do
+ # already loaded by implicit "modules" load
+ [ "${f##*/}" = "modules.conf" ] && continue
+
+ [ -r $f ] || continue
+ load_kernel_modules ${f##/etc/}
+ done
+ fi
- if [ -x /sbin/multipath ]; then
+ if [ -x /sbin/multipath ] && ! is_no "$DM_MULTIPATH"; then
# first make nodes that were discarded due (possible) new /dev mount
modprobe -s dm-mod
/sbin/dmsetup mknodes
fi
# LVM (keep in sync with LVM starting after RAID run!)
- if is_no "$LVM2" || [ -x /sbin/vgscan -a -x /sbin/vgchange ] || is_yes "$EVMS_LVM"; then
+ if ! is_no "$LVM2" && [ -x /sbin/vgscan -a -x /sbin/vgchange ] || is_yes "$EVMS_LVM"; then
if is_no "$LVM2"; then
lvmversion=$(LC_ALL=C /sbin/vgchange --version 2>/dev/null | awk '/LVM version:/{if ($3 >= 2) print "2"}')
else
fi
if [ "$lvmversion" = "1" ] ; then
modprobe -s lvm-mod >/dev/null 2>&1
+ lvmignorelocking=""
lvmsysinit=""
elif [ "$lvmversion" = "2" ] ; then
modprobe -s dm-mod >/dev/null 2>&1
+ lvmignorelocking="--ignorelockingfailure"
lvmsysinit="--sysinit"
else
modprobe -s lvm-mod >/dev/null 2>&1
# device mapper (2.5+ and patched 2.4)
modprobe -s dm-mod >/dev/null 2>&1
+ lvmignorelocking=""
lvmsysinit=""
fi
- run_cmd "Scanning for LVM volume groups" /sbin/vgscan $lvmsysinit
+ run_cmd "Scanning for LVM volume groups" /sbin/vgscan $lvmignorelocking
run_cmd "Activating LVM volume groups" /sbin/vgchange -a y $lvmsysinit
if [ "$lvmversion" = "2" ]; then
- /sbin/vgmknodes $lvmsysinit
+ /sbin/vgmknodes $lvmignorelocking
# display VG statistics
- /sbin/vgdisplay -s $lvmsysinit
+ /sbin/vgdisplay -s $lvmignorelocking
fi
fi
golvm=0
rc=0
if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ]; then
- if (grep -qE "^([[:blank:]]|)ARRAY[[:blank:]]" /etc/mdadm.conf 2>/dev/null); then
+ if grep -qE "^([[:blank:]]|)ARRAY[[:blank:]]" /etc/mdadm.conf 2>/dev/null; then
show "Starting up RAID devices"; busy
- /sbin/mdadm --assemble --scan --auto=yes
+ /sbin/mdadm --assemble --scan --auto=yes
rc=$?
if [ "$rc" -eq 0 -o "$rc" -eq 2 ]; then
# rc is used later, too so set sane value
# LVM on RAID (keep in sync with LVM setting few lines above)
if [ "$golvm" -eq "1" ]; then
if [ -x /sbin/vgscan -a -x /sbin/vgchange ]; then
- run_cmd "Scanning for LVM volume groups (on RAID)" /sbin/vgscan $lvmsysinit
+ run_cmd "Scanning for LVM volume groups (on RAID)" /sbin/vgscan $lvmignorelocking
run_cmd "Activating LVM volume groups (on RAID)" /sbin/vgchange -a y $lvmsysinit
[ "$lvmversion" = "2" ] && /sbin/vgmknodes
fi
# option is removed from /etc/mtab
if [ -z "$fastboot" ] && grep "^[^#].*encryption=" /etc/fstab 2>/dev/null | grep -v -q "noauto" 2>/dev/null; then
show "Checking encrypted filesystems"; started
- LOOPLIST="$(awk '
+ LOOPLIST="$(LC_ALL=C awk '
FILENAME=="/proc/mounts" {
TAB[$2]=$1;
}
fi
show "Remounting encrypted filesystems back in rw mode"; busy
- awk '
+ LC_ALL=C awk '
FILENAME=="/proc/mounts" {
TAB[$2]=$1;
}
fi
# Clean /tmp
-if is_yes "$CLEAN_TMP"; then
- # XXX LC_ALL needed here
- rm -rf /tmp/* /tmp/.[a-zA-Z0-9]*
+if is_yes "$CLEAN_TMP" && ! is_fsmounted tmpfs /tmp; then
+ LC_ALL=C rm -rf /tmp/* /tmp/.[a-zA-Z0-9]*
fi
# System protected dirs
# Now that we have all of our basic modules loaded and the kernel going,
# let's dump the syslog ring somewhere so we can find it later
- dmesg > /var/log/dmesg
+ dmesg --raw > /var/log/dmesg
i=5
while [ $i -ge 0 ]; do
if [ -f /var/log/dmesg.$i ]; then