sslug-teknik team mailing list archive
-
sslug-teknik team
-
Mailing list archive
-
Message #70150
Re: sys.init
Frank Damgaard skrev:
On Sat, Jan 17, 2004 at 11:10:46 +0100, Leif Lende wrote:
....
Med lidt helt bør du kunne finde hvor alle mount anvendes
til at mounte filsystemerne under opstart.
Og med kendskab til hvordan /etc/init.d/ og /etc/rc.?.d/ virker
bør du kunne finde ud af om dette script kaldes før eller efter
modulerne er på plads.
Det gør de fra /etc/rc.sysinit
meget tidligt.
Dvs. mount sker i rc.sysinit før moduler startes ?
og der er i scriptet ikke noget der åbner for kald af egne scripts
før "mount" ?
Det er sku svært at svare på, men der kaldes jo diverse scripts undervejs.
Her er et lille udkast af rc.sysinit hvor mount og fstab nevnes:
####################################################################
# Load modules (for backward compatibility with VARs)
if [ -x /etc/rc.d/rc.modules ]; then
/etc/rc.d/rc.modules
fi
# If they asked for ide-scsi, load it
# This must come before hdparm call because if hdd=ide-scsi
# /dev/hdd is inaccessible until ide-scsi is loaded
if grep -q "ide-scsi" /proc/cmdline ; then
modprobe ide-cd >/dev/null 2>&1
modprobe ide-scsi >/dev/null 2>&1
fi
if [ -f /etc/raidtab ]; then
# Add raid devices
[ -f /proc/mdstat ] || modprobe md >/dev/null 2>&1
fi
if [ -f /etc/raidtab -a -f /proc/mdstat ]; then
gprintf "Starting up RAID devices: "
rc=0
for i in `awk '{if ($1=="raiddev") print $2}' /etc/raidtab`
do
RAIDDEV=`basename $i`
RAIDSTAT=`LC_ALL=C grep "^$RAIDDEV : active" /proc/mdstat`
if [ -z "$RAIDSTAT" ]; then
# First scan the /etc/fstab for the "noauto"-flag
# for this device. If found, skip the initialization
# for it to avoid dropping to a shell on errors.
# If not, try raidstart...if that fails then
# fall back to raidadd, raidrun. If that
# also fails, then we drop to a shell
RESULT=1
INFSTAB=`LC_ALL=C grep -c "^$i" /etc/fstab`
if [ $INFSTAB -eq 0 ] ; then
RESULT=0
RAIDDEV="$RAIDDEV(skipped)"
fi
NOAUTO=`LC_ALL=C grep "^$i" /etc/fstab | LC_ALL=C grep -c "noauto"`
if [ $NOAUTO -gt 0 ]; then
RESULT=0
RAIDDEV="$RAIDDEV(skipped)"
fi
if [ $RESULT -gt 0 -a -x /sbin/raidstart ]; then
/sbin/raidstart $i
RESULT=$?
fi
if [ $RESULT -gt 0 -a -x /sbin/raid0run ]; then
/sbin/raid0run $i
RESULT=$?
fi
if [ $RESULT -gt 0 -a -x /sbin/raidadd -a -x /sbin/raidrun ]; then
/sbin/raidadd $i
/sbin/raidrun $i
RESULT=$?
fi
if [ $RESULT -gt 0 ]; then
rc=1
fi
echo -n "$RAIDDEV "
else
echo -n "$RAIDDEV "
fi
done
echo
# A non-zero return means there were problems.
if [ $rc -gt 0 ]; then
local str=
echo
echo
gprintf "*** An error occurred during the RAID startup\n"
gprintf "*** Dropping you to a shell; the system will reboot\n"
gprintf "*** when you leave the shell.\n"
str=`gprintf "(RAID Repair)"`
PS1="$str \# # "; export PS1
sulogin
gprintf "Unmounting file systems\n"
umount -a
mount -n -o remount,ro /
gprintf "Automatic reboot in progress.\n"
reboot -f
fi
fi
# LVM initialization, take 2 (it could be on top of RAID)
if [ -x /sbin/vgchange -a -f /etc/lvmtab ]; then
action "Setting up Logical Volume Management:" /sbin/vgscan &&
/sbin/vgchange -a y
fi
if [ -x /sbin/devlabel ]; then
/sbin/devlabel restart
fi
_RUN_QUOTACHECK=0
# Check filesystems
# (pixel) do not check loopback files, will be done later (aren't
available yet)
if [ -z "$fastboot" ]; then
gprintf "Checking filesystems\n"
Fsck -T -R -A -a -t noopts=loop $fsckoptions
fi
# (stew) since we're defaulting to ext3 now, and kernel22 doesn't
# support it yet - mount ext3 partitions as ext2 for kernel22
# mkinitrd covers the case for rootfs as ext3
IS22=$(/bin/uname -r | /bin/grep '^2\.2')
if [ -n "$IS22" ]; then
for i in `grep ext3 /etc/fstab | grep defaults | awk '{print $1}'`
do
mntpt=`grep "^$i" /etc/fstab | awk '{print $2}'`
if [ "$mntpt" != "/" ]; then
gprintf "Mount $i on $mntpt as ext2 for kernel22"
mount $i $mntpt -text2
if [ "$rc" = "0" ]; then
echo_success
echo
elif [ "$rc" = "1" ]; then
echo_passed
echo
fi
fi
done
fi
# Mount all other filesystems (except for NFS and /proc, which is already
# mounted). Contrary to standard usage,
# filesystems are NOT unmounted in single user mode.
# (pixel) also do not mount loopback, will be done later
action "Mounting local filesystems: " mount -a -t nonfs,smbfs,ncpfs -O
no_netdev,noloop,noencrypted
rc_splash mount 6
[[ -z $AUTOFSCK_CRYPTO_TIMEOUT ]] && AUTOFSCK_CRYPTO_TIMEOUT=15
#Mounting Encrypted filesystem
encrypted_swap=
if [[ ! -f /fastboot ]];then
encrypted=
while read -a entry;do
device=${entry[0]}
mountpoint=${entry[1]}
options=${entry[3]}
type=${entry[2]}
if [[ $options == *encryption=* || $options == *encrypted* ]];then
[[ $options == *noauto* ]] && continue
if [[ $type == *swap* ]];then
encrypted_swap="$encrypted_swap $device"
continue
fi
encrypted="$encrypted $mountpoint"
fi
done < /etc/fstab
#####################################################################################
Det er en ordentlig smøre af en fil med 1113 linier.
Follow ups
References