LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Optimize slack boot process / init scripts ? (https://www.linuxquestions.org/questions/slackware-14/optimize-slack-boot-process-init-scripts-525364/)

H_TeXMeX_H 05-14-2007 11:45 AM

Read the post by gnashley referenced above. Or here:
http://www.linuxquestions.org/questi...60#post2673760

Alien_Hominid 05-14-2007 12:51 PM

He doesn't say that running it manually is bad. You can't run it manually during boot, but there is no problem, if you run ldconfig before shutdown.

pdw_hu 05-14-2007 02:02 PM

Well, he has a point, but I for example haven't had any problems with ldconfig not being run at all (except source installs, ofcourse) for over a year now.

H_TeXMeX_H 05-15-2007 11:02 AM

I know, I didn't have any problems either. But, I figure Pat V. put it to run at startup for more than one reason. Maybe it's best to make it run at startup. Of course, you could simply run it manually when you need it.

Alien_Hominid 05-15-2007 02:49 PM

I believe it was made for those programs or users who don't run ldconfig before being compiled (compiling).

H_TeXMeX_H 06-14-2007 07:43 PM

One more thing that can be done to speed up boot time (as I've seen, this is probably the one biggest slowdown left).

So in '/etc/rc.d/rc.S' you'll see something like:
Code:

# Mount non-root file systems in fstab, but not NFS or SMB
# because TCP/IP is not yet configured, and not proc or sysfs
# because those have already been mounted.  Also check that
# devpts is not already mounted before attempting to mount
# it.  With 2.4.x kernels devpts is mounted from an fstab
# entry while with a 2.6.x or newer kernel udev mounts it.
# We also need to wait a little bit to let USB and other
# hotplugged devices settle (sorry to slow down the boot):
echo "Mounting non-root local filesystems:"
sleep 3
if /bin/grep -wq devpts /proc/mounts ; then
  /sbin/mount -a -v -t nonfs,nosmbfs,nocifs,noproc,nosysfs,nodevpts
else
  /sbin/mount -a -v -t nonfs,nosmbfs,nocifs,noproc,nosysfs
fi

Note that this is run every time you boot, and it is the only such thing that has the 'sleep' command in it ... a delay command. In this case it waits 3 seconds.

Now, I commented out this entire section, because every time I boot, nothing is mounted .... there are no non-root file systems in fstab or any at all ... they don't exist.

So, I propose that is a safe optimization if every time you boot, no non-root file systems in fstab is mounted and you have no non-root filesystems on your system.

Does this seem reasonable ... should I add it to the guide with this notice ?

H_TeXMeX_H 06-15-2007 03:23 PM

There seem to be no problems with doing this, so I'll just add it to the post. Boot time on my desktop is 26 sec (from pressing the power on button, about 20 sec from grub).

H_TeXMeX_H 09-25-2007 10:31 AM

This might as well go here, for Slackware 12.0, the same steps can be used to optimize boot time (and other things concerning speed). However, now the two major slow processes are started with an '&' after them which prevents them from slowing things down, which is great.

So, the same steps can be used, with one possible addition. In '/etc/rc.d/rc.M', I added an '&' to the hal startup script:

Code:

# Start HAL:
if [ -x /etc/rc.d/rc.hald ]; then
  sh /etc/rc.d/rc.hald start &
fi

Now, you cannot do this with d-bus, because d-bus must be started before hal, or hal won't work. But, d-bus loads quickly, so it's not a problem. Hal normally takes a long time to load, so it does slow things down. Also, I don't think this will affect anything, because nothing started after hal really needs hal, except maybe once you start xserver and kde, but I've found it always loads by then. It works fine for me, especially since I don't use kde and don't care too much for the automount features provided by hal. But, I like 'lshal' because it gives a nice list of all the components on the system, and was very useful on a number of occasions where I was trying to make some scripts for a ppp connection.

lyke 10-07-2007 07:36 AM

I don't use PCMCIA cards - can I just comment out that section of rc.M without anything bad happening, or is that service used for something else too?

if [ -x /etc/rc.d/rc.pcmcia ]; then
. /etc/rc.d/rc.pcmcia start
# The cards might need a little extra time here to initialize.
sleep 5
fi

H_TeXMeX_H 10-07-2007 08:27 AM

Unless you have a pcmica card (for laptops), then you can certainly comment it out. Or, you could just make it non-executable 'chmod a-x /etc/rc.d/rc.pcmcia'. To explain why here's an explanation of what this script means (you may already know some of this):

Code:

# if /etc/rc.d/rc.pcmcia is executable (the '-x'), then
if [ -x /etc/rc.d/rc.pcmcia ]; then
# start /etc/rc.d/rc.pcmcia
. /etc/rc.d/rc.pcmcia start
# The cards might need a little extra time here to initialize.
sleep 5
fi


duryodhan 10-07-2007 10:36 AM

Can I comment out the sleep in non root fs part if all my non root fs are actual IDE/SATA HDDs?
I am not mounting anything hot pluggable , so no need to wait for that ?

H_TeXMeX_H 10-07-2007 10:44 AM

You could try, but I don't recommend it, because it was put there for a reason. If you have non-root fs to mount, then don't comment that part out.

gnashley 10-07-2007 01:05 PM

The sleep is there for USB drivers to register. If you are not mounting any USB stuff during bootup you can safely comment out the sleep command.

H_TeXMeX_H 10-12-2007 04:47 AM

Ok, here's what I did for Slackware 12.0, it might as well be a new post:

1. Optimize scripts in '/etc/rc.d':

a) Make un-executable anything that you don't need. For example:
Code:

chmod a-x /etc/rc.d/rc.gpm
b) Modify 'rc.M' as follows:
Code:

136c136
<  sh /etc/rc.d/rc.hald start
---
>  sh /etc/rc.d/rc.hald start &
218,220c218,220
< if [ -x /usr/sbin/atd ]; then
<  /usr/sbin/atd -b 15 -l 1
< fi
---
> #if [ -x /usr/sbin/atd ]; then
> #  /usr/sbin/atd -b 15 -l 1
> #fi

This being the output of diff. So, just add an '&' after the rc.hald start command, and comment out the part about atd if you never use atd.

c) Modify rc.S as follows:
Code:

39a40,43
> # Boost HDD speed with hdparm
> echo "hdparm -c3 -m16 /dev/hda"
> /usr/sbin/hdparm -c3 -m16 /dev/hda
>
296,302c300,306
< echo "Mounting non-root local filesystems:"
< sleep 3
< if /bin/grep -wq devpts /proc/mounts ; then
<  /sbin/mount -a -v -t nonfs,nosmbfs,nocifs,noproc,nosysfs,nodevpts
< else
<  /sbin/mount -a -v -t nonfs,nosmbfs,nocifs,noproc,nosysfs
< fi
---
> #echo "Mounting non-root local filesystems:"
> #sleep 3
> #if /bin/grep -wq devpts /proc/mounts ; then
> #  /sbin/mount -a -v -t nonfs,nosmbfs,nocifs,noproc,nosysfs,nodevpts
> #else
> #  /sbin/mount -a -v -t nonfs,nosmbfs,nocifs,noproc,nosysfs
> #fi

But, first, you need to know what is best for your HDD. I think -c3 should be ok for most HDDs. Read 'man hdparm'.

Also do:
Code:

hdparm -i /dev/hda
you'll get something like:
Code:

/dev/hda:

 Model=ST380023A, FwRev=3.33, SerialNo=3KB1BZNK
 Config={ HardSect NotMFM HdSw>15uSec Fixed DTR>10Mbs RotSpdTol>.5% }
 RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=4
 BuffType=unknown, BuffSize=2048kB, MaxMultSect=16, MultSect=16
 CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=156301488
 IORDY=on/off, tPIO={min:240,w/IORDY:120}, tDMA={min:120,rec:120}
 PIO modes:  pio0 pio1 pio2 pio3 pio4
 DMA modes:  mdma0 mdma1 mdma2
 UDMA modes: udma0 udma1 udma2 udma3 udma4 *udma5
 AdvancedPM=no WriteCache=enabled
 Drive conforms to: ATA/ATAPI-6 T13 1410D revision 2:  ATA/ATAPI-1 ATA/ATAPI-2 ATA/ATAPI-3 ATA/ATAPI-4 ATA/ATAPI-5 ATA/ATAPI-6

 * signifies the current active mode

Check the 'MaxMultSect=16, MultSect=16', MaxMultSect is the maximum setting for '-m' option. Thus I run 'hdparm -c3 -m16 /dev/hda'. Again, read 'man hdparm'.

If know that you have no 'non-root file systems in fstab' to mount, and every time you boot it says "Mounting non-root local filesystems:" and then nothing was mounted, then you can probably also comment the following section out of rc.S:

Code:

# Mount non-root file systems in fstab, but not NFS or SMB
# because TCP/IP is not yet configured, and not proc or sysfs
# because those have already been mounted.  Also check that
# devpts is not already mounted before attempting to mount
# it.  With 2.4.x kernels devpts is mounted from an fstab
# entry while with a 2.6.x or newer kernel udev mounts it.
# We also need to wait a little bit to let USB and other
# hotplugged devices settle (sorry to slow down the boot):
echo "Mounting non-root local filesystems:"
sleep 3
if /bin/grep -wq devpts /proc/mounts ; then
  /sbin/mount -a -v -t nonfs,nosmbfs,nocifs,noproc,nosysfs,nodevpts
else
  /sbin/mount -a -v -t nonfs,nosmbfs,nocifs,noproc,nosysfs
fi

NOTE: the above may not be safe for all setups ... try at your own risk. It works fine for me.

2. Compile a new kernel. Here is a good guide:
http://www.kroah.com/lkn/

a) First, start with the generic kernel, and build from there. Run 'make mrproper', copy in the '.config' from the generic kernel, and then run 'make menuconfig' (or whichever one you prefer).

b) Search for the words 'not', 'found', 'no', and 'error' in 'dmesg', and take appropriate action ... removing what fails anyway.

c) disable 'pcspkr', unless you like annoying beeps every time you make an error. (disable raid/md if you don't use it)

d) make floppy a module rather than built-in (on some machines, this is the only way it will work)

e) Under 'Block layer -> IO Schedulers' read the help on all of them and see which one you think is best. IMO, the best are CFQ for desktop, and deadline for database/server.

f) Under 'Processor type and features':
i. Make sure to select your processor in 'Processor family',
ii. Enable/disable SMP (Symmetric multi-processing) if you have or don't have it
iii. Disable 'Generic x86 support' unless you're making your own distro
iv. Put max # CPUs (for multi-core)
v. Enable/disable hyperthreading for P4
vi. Enable/disable multi-core and/or SMT scheduler suppport
vii. Disable local apic
iix. Read and choose 'Preemption Model' (Voluntary is good for desktop)
ix. Enable/disable high memory support: if you have near 1GB RAM, enable it
x. Set timer frequency acordingly (1000 Hz for desktop)
xi. Maybe try enabling '64-bit memory and IO resources' if you have 64-bit processor
xii. Turn off 'Compat VDSO support' (glibc-2.3.3 or later)

g) Don't forget to fully enable your filesystem

I think those are most important performance-wise, the rest is also important, but harder to get right :) The guide should help with that.

3. Install grub or use lilo 'compact' option. You choose. Grub is slightly faster from what I can tell.


All times are GMT -5. The time now is 02:40 PM.