FreeBSD
Table of contents
Homepage
http://www.freebsd.orgKernel config
Enable httpready / accf_http for use in Apache
Notes: Tested on FreeBSD 5.x, 6.x, and 7.xFrom 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_httpTo 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-STABLEHints: 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-p6Hints: 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 confoptions 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 kerneloptions 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-p6cd /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 script /root/buildworld.log # Use this to keep track of progress in another screen or after a crash make -j16 buildworld exit script /root/buildkernel.log make -j16 buildkernel # KERNCONF=MYKERNEL for a custom kernel, see above. exit script /root/installkernel.log 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 script /root/installworld.log make installworld mergemaster shutdown -r now
PS: If running ezjails, please remember to update these, too!
How to mount ISO files virtually
Creationmdconfig -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
devfs
How to mount devfs in FreeBSD
mount -t devfs devfs /dev
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.htmlMake FreeBSD reboot on kernel panic
Put this into /etc/sysctl.confdebug.debugger_on_panic=0
This will only work if you do not have KDB compiled into your kernel.
If you have KDB compiled into your kernel, also compile KDB_UNATTENDED into the kernel. This will make it reboot anyhow.
