Send a link

FreeBSD

Table of contents



Homepage

http://www.freebsd.org (external link) (cache)

Kernel config


Enable httpready / accf_http for use in Apache

Notes: Tested on FreeBSD 5.x, 6.x, and 7.x

From the man page of accf_http:
(used for Apache 2.2.x with "httpready" function call)
NAME
     accf_http -- buffer incoming connections until a certain complete HTTP
     requests arrive

SYNOPSIS
     options INET
     options ACCEPT_FILTER_HTTP
     kldload accf_http


To load it on boot - without the kernel option, put the following in /boot/loader.conf:
accf_data_load="YES" # Wait for data accept filter
accf_http_load="YES" # Wait for full HTTP request accept filter

NOTE: See the Apache page for configure options for Apache 2.2.x.

Device polling

Notes: Tested on FreeBSD 7.0-RELEASE-p6, 7.0-STABLE
Hints: DEVICE_POLLING, HZ=1000, ifconfig, polling

To enabled device polling you have to put the following 2 lines in your kernel config:
options DEVICE_POLLING
options HZ=1000

Now you can set polling for the devices needed (this only works on NICs/network interface cards so far).

The following line is an example of a valid entry in /etc/rc.conf:
ifconfig_em0="inet 10.0.0.110 netmask 255.255.255.0 polling"

Alternatively, you can set an OID in /boot/loader.conf:
kern.polling.enable=1

However - this OID is deprecated since Oct. 1st 2005 - but still works.

Controlling next boot

Notes: Tested on FreeBSD 7.0-RELEASE-p6
Hints: nextboot, nextboot_conf

Put the following in /boot/loader.conf
nextboot_enable="YES"

This will consequently set the boot environment from the file /boot/nextboot.conf

Once executed, this file (/boot/nextboot.conf) is deleted - so back it up, should you need it again.

This is perfect for testing kernel settings on remote sites, like:
hint.acpi.0.disabled="1"

That line can kill your box if certain drivers/devices do not load without ACPI. On the other hand, having ACPI enabled can make interrupt storms on your device IRQs - hence - you want to be able to fallback on a good known configuration should this fail to boot.

When things work like you want them to - put these settings into /boot/loader.conf to make them permanent. Some settings might also be worth putting into the actual kernel to gain performance.

How to get rid of interrupt storm (atapci0 and others)

Add the following to your kernel conf
options         KDB
options         KDB_UNATTENDED
options         DDB

Then re-compile, install, and reboot.

For some reason this made all my interrupt storms go away. My system is amd64 with a Microstar motherboard (MS-7368, V1.5B2). The controller is "IXP SB600 Serial ATA Controller".

Also see "Device_polling" in this article.

Disable Ctrl+Alt+Delete

Add this to your kernel
options SC_DISABLE_REBOOT


Binary update

Since FreeBSD 6.3 the tool freebsd-update has been bundled with FreeBSD.

When updating inside same version, say, from 7.0-RELEASE to 7.0-RELEASE-p7 all you need to do is:

freebsd-update fetch
freebsd-update install
shutdown -r now


This will investigate your system and identify what needs to be updated - including mergemaster issues. If more questions should appear - use common sense.

If you up to a new major version, you might need to do more, like freebsd-update upgrade. Read man page for details ;)

Recompile kernel

Notes: Tested on FreeBSD 7.0-RELEASE-p6
cd /usr/src
make buildkernel KERNCONF=MYKERNEL
make installkernel KERNCONF=MYKERNEL
shutdown -r now


Recompile world

First, update your source tree:
cd /root
cp /usr/share/examples/cvsup/stable-supfile ./
chmod 644 stable-supfile
vi stable-supfile # Find CHANGE_THIS and insert "cvsup.dk" or your preferred mirror.
csup stable-supfile

Next - recompile
cd /usr/src
make -j4 buildworld
make buildkernel   # KERNCONF=MYKERNEL for a custom kernel, see above.
make installkernel # KERNCONF=MYKERNEL for a custom kernel, see above.
shutdown -r now

If you have the option to do this in single user mode, do it!
# mount -a -t ufs

Then continue:
mergemaster -p
cd /usr/src
make installworld
mergemaster
shutdown -r now

PS: If running ezjails, please remember to update these, too!

How to mount ISO files virtually

Creation
mdconfig -a -t vnode -f image.iso -u 0
mount -t cd9660 /dev/md0 /mnt/cdimage

Destruction
mdconfig -d -u 0


How to create more PTYs

Need more ptys? Just run...
cd /dev
sh MAKEDEV pty1
sh MAKEDEV pty2
sh MAKEDEV pty3

...which will make you 128 ptys.

Also check "man MAKEDEV" for hints. Your "screen" will be much happier now ;)

PS: For FreeBSD 4.x you also need to recompile with "pseudo-device pty 128" or what number you fancy.

Need disks/partitions larger than 2 TB?

Disks are getting bigger and bigger, but bsdlabel (which sysinstall uses) does not like a partition larger than 2^32-1 sectors per disk.

To circumvent this "problem" you need to finish installing FreeBSD and run the gpt utility afterwards.

It goes something like this:
gpt create -f /dev/da0
gpt add -t ufs /dev/da0
newfs -n /dev/da0p1


Miscellaneous

source routing
multihomed isp


procfs

How to show procfs in FreeBSD

mount -t procfs procfs /proc


How to hide procfs in FreeBSD

umount /proc


How to mirror your boot disk with geom

Read this article: http://www.freebsd.org/doc/en/books/handbook/geom-mirror.html (external link)


  • + : A leading plus sign indicates that this word must be present in every object returned.
  • - : A leading minus sign indicates that this word must not be present in any row returned.
  • By default (when neither plus nor minus is specified) the word is optional, but the object that contain it will be rated higher.
  • < > : These two operators are used to change a word's contribution to the relevance value that is assigned to a row.
  • ( ) : Parentheses are used to group words into subexpressions.
  • ~ : A leading tilde acts as a negation operator, causing the word's contribution to the object relevance to be negative. It's useful for marking noise words. An object that contains such a word will be rated lower than others, but will not be excluded altogether, as it would be with the - operator.
  • * : An asterisk is the truncation operator. Unlike the other operators, it should be appended to the word, not prepended.
  • " : The phrase, that is enclosed in double quotes ", matches only objects that contain this phrase literally, as it was typed.

Menu