FreeBSD
On a freshly installed FreeBSD 10.1 system, we have to configure a few things first.
Network
For a dynamic network configuration (read: Template:WP), we'd use something like this in /etc/rc.conf:
hostname="len" ifconfig_bge0="DHCP" ifconfig_bge0_ipv6="inet6 accept_rtadv"
If we need a static network configuration, use:
ifconfig_bge0="inet 10.0.0.3 netmask 255.255.255.0" defaultrouter=10.0.0.1 hostname=len.example.net
Restart the network configuration:
/etc/rc.d/netif restart /etc/rc.d/routing restart
Packages
Install missing packages:
pkg update pkg install bash bash-completion curl gnupg1 lsof pv rsync screen sudo vnstat
- Change a user's shell via chsh[1]
- Add vnstat_enable="YES" in /etc/rc.conf.
Update
Update package repository catalogues, then update the installed packages:
pkg update pkg upgrade
To update[2] the base system:
$ freebsd-update fetch Looking up update.FreeBSD.org mirrors... 5 mirrors found. Fetching metadata signature for 9.3-RELEASE from update5.freebsd.org... done. Fetching metadata index... done. Inspecting system... Preparing to download files... done. [...] The following files will be added as part of updating to 9.3-RELEASE-p16: The following files will be updated as part of updating to 9.3-RELEASE-p16: $ freebsd-update install Installing updates....done.
Upgrade
To upgrade[3] to another release, use:
$ uname -r Template:Color $ freebsd-update -r Template:Color upgrade Looking up update.FreeBSD.org mirrors... 5 mirrors found. Fetching metadata signature for 9.3-RELEASE from update2.freebsd.org... done. Fetching metadata index... done. Inspecting system... done. [...] Fetching metadata signature for 10.1-RELEASE from update2.freebsd.org... done. Fetching metadata index... done. Fetching 1 metadata patches. done. Applying metadata patches... done. Fetching 1 metadata files... done. Inspecting system... Fetching files from 9.3-RELEASE for merging... done. Preparing to download files... To install the downloaded upgrades, run "/usr/sbin/freebsd-update install". $ freebsd-update install Installing updates... Kernel updates have been installed. Please reboot and run "/usr/sbin/freebsd-update install" again to finish installing updates.
Note: since the kernel has already been updated, we may have to boot the old (9.3-RELEASE) kernel and continue with:
$ freebsd-update install Installing updates... Completing this upgrade requires removing old shared object files. Please rebuild all installed 3rd party software (e.g., programs installed from the ports tree) and then run "/usr/sbin/freebsd-update install" again to finish installing updates.
Update userland tools:
pkg update pkg upgrade
Continue with:
$ freebsd-update install Installing updates... done.
Now the updated kernel should be bootable and the upgrade should now be completed.
If all is well, and no freebsd-update rollback is required, /var/db/freebsd-update/files can be emptied:[4]
$ du -sh /var/db/freebsd-update/files; find /var/db/freebsd-update/files | wc -l
781M /var/db/freebsd-update/files
29428
$ find /var/db/freebsd-update/files/ -type f -exec rm -v '{}' +
Postinstall
Encrypted swap
Linux compatibility
Mount linuxprocfs and install linux-f10-procps[5]:
$ grep ^lin /etc/fstab
linprocfs /compat/linux/proc linprocfs rw 0 0
linsys /compat/linux/sys linsysfs rw 0 0
$ sudo mkdir -p /compat/linux/{proc,sys}
$ sudo mount /compat/linux/proc && sudo mount /compat/linux/sys
$ sudo pkg install linux-f10-procps
Set linux_enable="YES" in /etc/rc.conf.
Screensaver
On this laptop I wanted to have the LCD shut off when the (text) console was idle[6][7]
$ cat /etc/rc.conf [...] apm_enable="YES" blanktime="60" saver="blank"
Enable APM[8] in device.hints[9]
$ grep apm.0.disabled /boot/device.hints hint.apm.0.disabled="0"
SMART
To enable Template:WP, use smartmontools:[10][11]
pkg install smartmontools echo 'smartd_enable="YES"' >> /etc/rc.conf cp -i /usr/local/etc/smartd.conf.sample /usr/local/etc/smartd.conf
Start smartd and
/usr/local/etc/rc.d/smartd start
The installation package should have created /usr/local/etc/periodic/daily/smart to check on monitored devices periodically.
Memory
FreeBSD memory notation is quite different, let's explain it in short:[12]
$ top -b -d 1 | grep -A1 ^Mem Mem: 112M Active, 687M Inact, 158M Wired, 8268K Cache, 87M Buf, 12M Free Swap: 1024M Total, 41M Used, 983M Free, 3% Inuse
- Active: Memory currently being used by a process
- Inactive: Memory that has been freed but is still cached since it may be used again.
- Wired: Memory in use by the Kernel. This memory cannot be swapped out
- Cache: Memory being used to cache data, can be freed immediately if required
- Buffers: Disk cache
- Free: Memory that is completely free and ready to use.
Build a Kernel
Checkout the kernel source[13][14] to /usr/src via SVN:
svn checkout https://svn.freebsd.org/Template:Color/Template:Color /usr/src ARCH=$(uname -m) cd /usr/src/sys/$ARCH/conf/ cp GENERIC MYCONF
Edit MYCONF, if needed and we're ready to compile:
cd /usr/src/ make -j4 buildkernel KERNCONF=MYCONF sudo make installkernel KERNCONF=MYCONF
Reboot - and if all goes well, our new kernel should be running:
$ sysctl kern.conftxt | grep ident ident MYCONF
Note: compiling the kernel needs quite a bit of disk space, in our FreeBSD-10.2 installation:
1.1 GB /usr/obj/usr/src/sys/MYCONF 1.5 GB /usr/src/
Links
References
- ↑ chpass(1)
- ↑ Applying Security Patches
- ↑ Performing Major and Minor Version Upgrades
- ↑ can /var/db/freebsd-update/ be safely deleted?
- ↑ Linux® Binary Compatibility
- ↑ green_saver does not switch DVI monitor power off
- ↑ Should green_saver.ko shut off a laptop's backlight?
- ↑ FreeBSD on Laptops: APM
- ↑ 13.4. Device Hints
- ↑ smartmontools
- ↑ Monitoring your HDD using SMART and Nagios
- ↑ What do the different memory counters in FreeBSD mean?
- ↑ Appendix A. Obtaining FreeBSD: Running Subversion
- ↑ How To Customize and Recompile Your Kernel on FreeBSD 10.1