Monday, September 04, 2006

Faster booting FreeBSD

Time when system is fully usable depends on:

  1. How long POST will end it's self tests

  2. When bootloader begin loading system

  3. How long system will be loading (kernel and modules load up)

  4. How long various services will be starting


Good router/gateway should be usable as fast as possible after turning it on.
The first point depends on hardware and BIOS. Some BIOSES have features defining type of POST for example fast, full, etc. We won't discuss it this time.
Kernel and modules - it's clear that smaller kernel and fewer modules make all system faster, not only when it's booting. This is story for another time. Similar to kernel, fewer services - faster booting.
The bootloader, especially boot0 can be easily tuned using boot0cfg:
boot0cfg -Bv -b /boot/boot0 -t ticks /dev/ad0
Ticks means quantity of impulses in RTC clock, it's about 18.2/s
Next thing wich can delay booting process is so called "beastie menu" or loader. It's next piece of code run after boot0. Loader directly loads kernel with selected parameters. Configuration file /boot/loader.conf includes many options, but we change only one value:
autoboot_delay="10"
It's in seconds let's change it to smaller piece of time. We can also disable beastie menu by setting this value:
beastie_disable="YES"

Saturday, September 02, 2006

Silent system: No beeping boot0 and console

Beeping can be stressful. Starting computer emits couple of beeps, some of them can be avoided. In fact computer working as router/gateway don't need to inform everyone that it is starting. The first beep we will deactivate, appears when boot0 loads. Let's look into one interesting file /usr/src/sys/boot/i386/boot0/boot0.S. There are two key lines of code:
204: movb $ASCII_BEL,%al # Signal
205: callw putchr # beep

We can remove them without any fear that something will gone wrong.
Next compile the source using make command:
# make
In order Copy the 512 byte long file (boot0) to /boot
And install on disk using boot0cfg as follows:
# boot0cfg -Bv -b /boot/boot0 /dev/ad0
Where ad0 means disk where the changed bootloader will be installed.
boot0cfg manual warns about problems with geom when installing on mounted drive, I didn't have such problems and I don't have to temporarily disable this geom feature as described in manual.

Next beeping thing in FreeBSD is console. Personally I don't like when it beeps, so I removed this feature permanently.
Let's add one line in /etc/rc.conf:
allscreens_kbdflags="-b off"
Next time system is started console will not beep anymore. We can disable beeping temporarily by using this command:
# kbdcontrol -b off

Labels: , ,

Friday, September 01, 2006

How to change files in /usr/local/etc on nanoBSD

This is a major problem when we install software from packages or ports on nanobsd system. Root partition is readonly. Third party software keep their configuration files under /usr/local/etc Only /etc can be changed during runtime.
This custom function used after installing ports/packages during build solve this problem:

#
# Create symlinks in /usr/local/etc to /etc due to readonly filesystem in
# /usr
#
cust_fix_usr_local() (
mkdir ${NANO_WORLDDIR}/etc/uletc
cp -R ${NANO_WORLDDIR}/usr/local/etc/* ${NANO_WORLDDIR}/etc/uletc
rm -r ${NANO_WORLDDIR}/usr/local/etc
#rmdir ${NANO_WORLDDIR}/usr/locla/etc
chroot ${NANO_WORLDDIR} sh -c 'ln -s /etc/uletc /usr/local/etc'
)