You are not logged in.
Hello,
Recently I've been playing around with getting Arch to boot as fast as possible. Most of the changes I made make the boot process specific to my machine (turning off autodetect, loading modules manually...etc). But there was one change that I believe introduced no instability and I wonder why its not included by default.
In /etc/rc.sysinit starting on line 119 of a vanilla file
/sbin/udevadm trigger
/sbin/udevadm settle
These lines occur many lines after the udev daemon has been loaded. My question is why not move the trigger line to right after the udev deamon is loaded and run it in the background by default?
So the settle line stays in the same spot it is, but move the trigger line up and make make it run in the background:
(line 77)
/sbin/udevd --daemon
/sbin/udevadm trigger &
This sped my system up by about 5 seconds and there doesn't seem to be any instability ( I don't see why there would be). So is it possible this could be made the default?
Last edited by vh22 (2009-01-07 22:50:52)
Offline
Submit a feature request on the bugtracker.
Offline
Thanks for the suggestion. I just submitted the request.
Offline
What do you mean by reduce the time by 5 seconds? Because on my system the udev load time that's displayed during startup is apparently reduced, but the overall boot time (checked with bootchart) remains exactly the same.
Offline
Yes the the udev load time is definitely reduced, but it slows down the loading of the modules since udevadm trigger is running in the background now. I suppose on your system, they balanced out. On my system, I got a net -5 seconds on the boot time. I haven't tested this out on many systems (don't have that many systems to test it on) but I would be happy if other people could try it and see if it helps them.
If it turns out not to help people, I could always retract the request.
Offline
It took down my udev processing time from 700ms to 1ms !
Offline
Your time was already fast to begin with. My udev processing time was originally 4000-5000ms.
Offline
It took down my udev processing time from 700ms to 1ms !
It does that, but on two different systems here it gives no improvement as far as overall boot time is concerned.
@vh22: Don't let my results discourage you -- if it makes a difference on some systems then it should definitely be considered by the devs. Both systems I've tried this tweak on boot pretty fast as is -- 22 and 15 seconds -- so I'm not sure how much more room for improvement there is in my case.
Offline
I'm using vh22 suggestion for a few months already and included in my latest installation too: see here
I think there are more modifications possible to /etc/rc.sysinit to speed it up, also for any system.
vh22, Can you post your /etc/rc.sysinit, just to compare.
Offline
I haven't been using Linux for that long so I probably didn't make as many modifications as you. All I really did was rip most of the stuff I didn't need out.
#!/bin/bash
#
# /etc/rc.sysinit
#
. /etc/rc.conf
. /etc/rc.d/functions
echo " "
printhl "Arch Linux\n"
printhl "${C_H2}http://www.archlinux.org"
printhl "Copyright 2002-2007 Judd Vinet"
printhl "Copyright 2007-2008 Aaron Griffin"
printhl "Distributed under the GNU General Public License (GPL)"
printsep
# mount /proc, /sys and our RAM /dev
/bin/mount -n -t ramfs none /dev
/bin/mount -n -t proc none /proc
/bin/mount -n -t sysfs none /sys
# Create our default nodes that minilogd may need
/bin/mknod /dev/null c 1 3
/bin/mknod /dev/zero c 1 5
/bin/mknod /dev/console c 5 1
# More initial /dev setup that udev doesn't do
/bin/ln -snf /proc/self/fd /dev/fd
/bin/ln -snf /proc/self/fd/0 /dev/stdin
/bin/ln -snf /proc/self/fd/1 /dev/stdout
/bin/ln -snf /proc/self/fd/2 /dev/stderr
/bin/ln -snf /proc/kcore /dev/core
/bin/mkdir /dev/pts
/bin/mkdir /dev/shm
# start up our mini logger until syslog takes over
/sbin/minilogd
# anything more serious than KERN_WARNING goes to the console
# 'verbose' cmdline parameter enables more messages
if /bin/grep -q " verbose" /proc/cmdline; then
/bin/dmesg -n 8
else
/bin/dmesg -n 3
fi
# enable rtc access
/sbin/modprobe rtc-cmos >/dev/null 2>&1
RTC_MAJOR=$(/bin/grep -w rtc /proc/devices 2>/dev/null); RTC_MAJOR="${RTC_MAJOR%% *}"
if [ -n "$RTC_MAJOR" ]; then
/bin/mkdir /dev/misc/
/bin/mknod /dev/misc/rtc0 c $RTC_MAJOR 0
/bin/ln -s /dev/misc/rtc0 /dev/rtc
fi
HWCLOCK_PARAMS="--hctosys"
# Set clock early to fix some bugs with filesystem checks
# Clock is set again later to match rc.conf
if [ -f /etc/localtime ]; then
/sbin/hwclock $HWCLOCK_PARAMS --noadjfile
fi
echo > /proc/sys/kernel/hotplug
if [ -x /sbin/udevadm -a -d /sys/block ]; then
# We have udev and /sys appears to be mounted, use UDev
stat_busy "Starting UDev Daemon"
/sbin/udevd --daemon
/sbin/udevadm trigger &
stat_done
else
# Static /dev, our last resort
status "Using static /dev filesystem" true
fi
# Load modules from the MODULES array defined in rc.conf
if ! [ "$load_modules" = "off" ]; then
if [ -f /proc/modules ]; then
stat_busy "Loading Modules"
for mod in "${MODULES[@]}"; do
if [ "$mod" = "${mod#!}" ]; then
/sbin/modprobe $mod
fi
done
stat_done
fi
if [ -d /proc/acpi ]; then
stat_busy "Loading standard ACPI modules"
ACPI_MODULES="ac battery button fan processor thermal"
k="$(echo $BLACKLIST ${MOD_BLACKLIST[@]} | /bin/sed 's|-|_|g')"
j="$(echo ${MODULES[@]} | /bin/sed 's|-|_|g')"
#add disabled MODULES (!) to blacklist - much requested feature
for m in ${j}; do
[ "$m" != "${m#!}" ] && k="${k} ${m#!}"
done
# add disablemodules= from commandline to blacklist
k="${k} $(echo ${disablemodules} | /bin/sed 's|-|_|g' | /bin/sed 's|,| |g')"
for n in ${ACPI_MODULES}; do
if ! echo ${k} | /bin/grep "\<$n\>" 2>&1 >/dev/null; then
/sbin/modprobe $n > /dev/null 2>&1
fi
done
stat_done
fi
fi
# run udev uevents
if /bin/pidof -o %PPID /sbin/udevd >/dev/null; then
stat_busy "Loading UDev uevents"
udevstart="$(/bin/date +%s%0N)"
/sbin/udevadm settle
stat_done
udevend="$(/bin/date +%s%0N)"
printhl " UDev uevent processing time: $((($udevend-$udevstart)/1000000))ms"
fi
# bring up the loopback interface
if [ -d /sys/class/net/lo ]; then
stat_busy "Bringing up loopback interface"
/sbin/ifconfig lo 127.0.0.1 up
if [ $? -ne 0 ]; then
stat_fail
else
stat_done
fi
fi
status "Mounting Root Read-only" /bin/mount -n -o remount,ro /
FORCEFSCK=
[ -f /forcefsck ] && FORCEFSCK="-- -f"
NETFS="nonfs,nonfs4,nosmbfs,nocifs,nocodafs,noncpfs,nosysfs,noshfs,nofuse,nofuseblk"
if [ -x /sbin/fsck ]; then
stat_busy "Checking Filesystems"
if /bin/grep -qw quiet /proc/cmdline; then
/sbin/fsck -A -T -C -a -t $NETFS $FORCEFSCK >/dev/null 2>&1
else
/sbin/fsck -A -T -C -a -t $NETFS $FORCEFSCK 2>/dev/null
fi
fsckret=$?
if [ ${fsckret} -gt 1 ]; then
stat_fail
if [ $((${fsckret}&2)) -eq 2 ]; then
echo
echo "********************** REBOOT REQUIRED *********************"
echo "* *"
echo "* The system will be rebooted automatically in 15 seconds. *"
echo "* *"
echo "************************************************************"
echo
/bin/sleep 15
else
echo
echo "***************** FILESYSTEM CHECK FAILED ****************"
echo "* *"
echo "* Please repair manually and reboot. Note that the root *"
echo "* file system is currently mounted read-only. To remount *"
echo "* it read-write type: mount -n -o remount,rw / *"
echo "* When you exit the maintenance shell the system will *"
echo "* reboot automatically. *"
echo "* *"
echo "************************************************************"
echo
/sbin/sulogin -p
fi
echo "Automatic reboot in progress..."
/bin/umount -a
/bin/mount -n -o remount,ro /
/sbin/reboot -f
exit 0
fi
stat_done
fi
stat_busy "Mounting Local Filesystems"
/bin/mount -F -n -o remount,rw /
/bin/rm -f /etc/mtab*
# make sure / gets written to /etc/mtab
/bin/mount -o remount,rw /
# Write /proc, /sys and /dev to /etc/mtab
if [ -e /proc/mounts ]; then
/bin/grep -e "/proc " -e "/sys " -e "/dev " /proc/mounts >> /etc/mtab
fi
# now mount all the local filesystems
/bin/mount -a -t $NETFS
stat_done
status "Activating Swap" /sbin/swapon -a
stat_busy "Configuring System Clock"
if [ ! -f /var/lib/hwclock/adjtime ]; then
echo "0.0 0 0.0" > /var/lib/hwclock/adjtime
fi
if [ "$TIMEZONE" != "" -a -e "/usr/share/zoneinfo/$TIMEZONE" ]; then
/bin/rm -f /etc/localtime
/bin/cp "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime
fi
/sbin/hwclock $HWCLOCK_PARAMS
stat_done
if [ -f /var/run/random-seed ]; then
stat_busy "Initializing Random Seed"
/bin/cat /var/run/random-seed >/dev/urandom
stat_done
fi
stat_busy "Removing Leftover Files"
/bin/rm -f /etc/nologin &>/dev/null &
/bin/rm -f /etc/shutdownpid &>/dev/null &
/bin/rm -f /var/lock/* &>/dev/null &
/bin/rm -rf /tmp/* /tmp/.* &>/dev/null &
/bin/rm -f /forcefsck &>/dev/null &
(cd /var/run && /usr/bin/find . ! -type d -exec /bin/rm -f -- {} \; )
: > /var/run/utmp &
# Keep {x,k,g}dm happy with xorg
/bin/mkdir /tmp/.ICE-unix && /bin/chmod 1777 /tmp/.ICE-unix
/bin/mkdir /tmp/.X11-unix && /bin/chmod 1777 /tmp/.X11-unix
stat_done
#status "Updating Shared Library Links" /sbin/ldconfig
if [ "$HOSTNAME" != "" ]; then
status "Setting Hostname: $HOSTNAME" /bin/hostname $HOSTNAME
fi
# Set the NIS domain name, if necessary
[ -f /etc/conf.d/nisdomainname ] && . /etc/conf.d/nisdomainname
if [ "$NISDOMAINNAME" != "" ]; then
status "Setting NIS Domain Name: $NISDOMAINNAME" /bin/nisdomainname $NISDOMAINNAME
fi
status "Updating Module Dependencies" /sbin/depmod -A
# Flush old locale settings
: >/etc/profile.d/locale.sh
/bin/chmod 755 /etc/profile.d/locale.sh
# Set user defined locale
[ -z "$LOCALE" ] && LOCALE="en_US"
stat_busy "Setting Locale: $LOCALE"
echo "export LANG=$LOCALE" >>/etc/profile.d/locale.sh
stat_done
if [ -n "$CONSOLEFONT" ]; then
stat_busy "Loading Console Font: $CONSOLEFONT"
#CONSOLEMAP in UTF-8 shouldn't be used
if [ -n "$CONSOLEMAP" ] && echo "$LOCALE" | /bin/grep -qi utf ; then
CONSOLEMAP=""
fi
for i in $(/usr/bin/seq 0 63); do
if [ -n "$CONSOLEMAP" ]; then
/usr/bin/setfont -m $CONSOLEMAP $CONSOLEFONT -C /dev/vc/${i} >/dev/null 2>&1
else
/usr/bin/setfont $CONSOLEFONT -C /dev/vc/${i} >/dev/null 2>&1
fi
done
if [ $? -ne 0 ]; then
stat_fail
else
for i in $(/usr/bin/seq 0 63); do
printf "\e(K" > /dev/vc/${i}
done
# the $CONSOLE check helps us avoid this when running scripts from cron
echo 'if [ "$CONSOLE" = "" -a "$TERM" = "linux" -a -t 1 ]; then printf "\e(K"; fi' >>/etc/profile.d/locale.sh
stat_done
fi
fi
# Adding persistent network/cdrom generated rules
if [ -f "/dev/.udev/tmp-rules--70-persistent-cd.rules" ]; then
stat_busy "Adding persistent cdrom udev rules"
/bin/cat /dev/.udev/tmp-rules--70-persistent-cd.rules >> /etc/udev/rules.d/70-persistent-cd.rules
stat_done
fi
if [ -f "/dev/.udev/tmp-rules--70-persistent-net.rules" ]; then
stat_busy "Adding persistent network udev rules"
/bin/cat /dev/.udev/tmp-rules--70-persistent-net.rules >> /etc/udev/rules.d/70-persistent-net.rules
stat_done
fi
# Save our dmesg output from this boot
if [ -f /var/log/dmesg.log ]; then
/bin/rm /var/log/dmesg.log
fi
/bin/dmesg > /var/log/dmesg.log
# End of file
Offline
I gues putting following in background would help a bit too. It didn't gave me any problems.
And yes you can strip out some other stuff but not that it would make a signicantly difference, just for the kick :-D
/sbin/modprobe $mod &
/sbin/modprobe $n > /dev/null 2>&1 &
/sbin/udevadm settle &
status "Activating Swap" /sbin/swapon -a &
Although, I got one thing, but only 2 times or so, that my filesystems didn't mount.
Someone an idea? Did I put too much into background?
Offline
You have to take the background off of the settle command. If you don't a race condition is formed and the crashes will only happen if settle is not done before the filesystem check.
As for those modifications you just posted, right after I posted my file above, I looked through the file again and made those changes. It didn't speed it up past 15 seconds though.
Offline
uhm, first I thought strange that it didn't go faster but than I reminded that you load modules manualy.
I removed the ampersand of '/sbin/udevadm settled', I didn't slow my boot off, so that's a keep! Thanks.
Offline
This was a great suggestion! It decreased my udev event time by 2 seconds from 2*** down to 6**.
Offline
Thanks for the tip. Not that I care too much about boot times, but I've nothing against booting ~5sec faster as my old thinkpad does now. No problems here so far.
Offline
is this really completely safe or are there possible problems like race conditions or whatnot?
Offline
As fwojciec said, this will show you much smaller number in ms, however real time is the same
Look at Duologic's topic, where he disables LVM, RAID, encrypted filesystems detection, cosnsole font etc. (he doesn't use these), which really speeds boot.
Last edited by EVRAMP (2009-01-10 13:49:41)
Offline
is this really completely safe or are there possible problems like race conditions or whatnot?
There is no race condition. If you had set settle to the background to, then a race condition would be there, but since settle is still in the foreground, the boot process will wait for the queue to clear before proceeding so it is really no different than a regular boot from there on.
As fwojciec said, this will show you much smaller number in ms, however real time is the same smile
Look at Duologic's topic, where he disables LVM, RAID, encrypted filesystems detection, cosnsole font etc. (he doesn't use these), which really speeds boot.
Yes this will definately increase your udev processing time, but it may or may not increase overall boot time. Your best bet is to time it before and after to see if you gained anything. But I don't think removing the LVM, RAID and encrypted filesystem from the rc.sysinit really speeds up boot. It removes at most 3 if checks, which, if you don't need those parts anyway, will always fail so its pretty quick already. i could be wrong about this though.
Offline
Removing RAID, LVM and Encrypted does speed up, At least 3 instructions are kept from sending to the processor. And lesser lines means lesser reading/writing and memory usage.
Offline
The question isn't if it speeds up, but if it's perceptible.
(lambda ())
Offline
Thank you so much! Boot up was perceptibly faster. 23 seconds instead of 28
Correction: 22s! And I haven't even done anything else to improve boot speed, other than booting straight into X (without having to startx from the console) and using a lightweight install of Openbox
Last edited by sfauzia (2009-01-23 02:58:19)
Offline
compile all modules into kernel for < 1ms udev !
Offline
Hi guy,
It could be very helpfull to create a WIKI page on tuning archlinux to boot faster.
With this kind of advice and link to fastboot project and so on.
vh22, Duologic, everyone else, you find a new job
Edit:
Woops, I didn't see http://wiki.archlinux.org/index.php/Twe … _boot_time
Good job!
Next steep: a 5sec boot + get a SSD
http://www.youtube.com/watch?v=s7NxCM8ryF8
Last edited by krum (2009-01-25 13:15:55)
Offline
Removing RAID, LVM and Encrypted does speed up, At least 3 instructions are kept from sending to the processor. And lesser lines means lesser reading/writing and memory usage.
Just tested it with bootchart and bootspeed remained exactly 18 seconds before and after changing rc.sysinit
flack 2.0.6: menu-driven BASH script to easily tag FLAC files (AUR)
knock-once 1.2: BASH script to easily create/send one-time sequences for knockd (forum/AUR)
Offline
I tried this and had problems! I do network with wicd, which is started as daemon. On standard configuration it connects to my wireless and wired networks without any problems. When I did this change, the boot was really a bit faster, but no internet at all, even restarting wicd daemon didn't help. So in my opinion this shouldn't become standard in Archlinux!!!
I'll try it again, maybe something else was the culprit, but I'm 98,54% sure
Offline