You’ll find everything you need in
/var/run/dmesg.boot or in the
sysctl -a. Some examples:
# Memory grep memory /var/run/dmesg.boot # No. of CPUs grep CPU /var/run/dmesg.boot
*kldstat* shows all loaded modules.
*kldload* loads a
*kldunload* unloads a module.
I used the venerable IPFW. In
/etc/rc.conf enable the firewall and
provide a script:
Then reboot. I used my own simple script at
git://git.example.com/it.firewall.ipfw. However, given that this is
exactly what OS X 10.6 (and below) use for a firewall, you’ll find
either WaterRoof or NoobProof
pretty awesome for some complicated rules. You’ll have to modify their
outputs to script format.
Can do one of the following
# For SCSI disks  cat /var/run/dmesg.boot | grep da # or gpart show
You’ll need to install
bsnmp to get this working.
kldload xfs mount -t xfs -o ro /dev/da15p1 /mnt
If you get an “Operation not permitted” error, check your filesystem.
For XFS, these packages might be helpful
pkg_add -r xfs xfsprogs xfsinfo
The backspace ‘problem’ in
echo 'set backspace+=start,eol,indent' >> ~/.vimrc
A note on
If you screw up this file, you’re screwed in turn. A single missing
quote and you’ll boot into a read-only system. Be careful, and use
sysinstall if you can.
The Ports Tree
See the “Obtaining the Ports
section of the manual if you forgot to install the tree. To update, just
# Update ports tree and system packages portsnap fetch extract update freebsd-update fetch freebsd-update install # This installs pkg pkg install bash \ bash-completion \ chromium \ inconsolata-ttf \ numix-theme rsync \ sudo \ tree \ vim \ xfce \ xorg \ git \ # Get the kernel source for VirtualBox Guest Additions if applicable # Configure proxy in ~/.subversion/servers if needed svnlite checkout http://svn.freebsd.org/base/head /usr/src svnlite up /usr/src cd /usr/src make clean
No packages matching xxx available in the repository
rm /var/db/pkg/repo-* pkg upgrade
Quicker alternative to ye olde
cd /usr/ports/sysutils/mkfile; make install clean
Use the packages system.
pkg_add -r vim
cd /usr/ports make search name=<package>
Here’s the pertinent
page from the
FreeBSD manual that describes how to set these up.
- Make sure that you issue
/etc/rc.d/mountd onereloadand observe
the output of
/var/log/messagesfor any errors.
- You should then verify your mounts by issuing
You will need to increase
kmem to prevent panics. Check
If the values look appropriate, skip the “Loader
section of the manual.
Now start ZFS with:
echo 'zfs_enable="YES"' >> /etc/rc.conf /etc/rc.d/zfs start
Creating a zpool
I had twelve 3TB disks I wanted in a RAID6. Sun calls it “RAIDZ2”, since
it averts the RAID write
hole. I wanted to call
my pool “data”:
zpool create data raidz2 da1 da2 da3 da4 da5 da6 da7 da8 da9 da10 da11 da12
I also had a 256GB solid-state cache drive to speed up performance using
device name is
zpool add data cache da16
Using an existing pool
I had to reinstall FreeBSD after some XFS weirdness. I was able to get
my old pool back with
This scans all drives and lists any available pools. Then actually
import the pool with
zpool import data
# On the old server, export the pool ("zpool export -f data" to force) zpool export data # You've now moved the disks to a new server and are on it right now # Scan for zpools zpool import # Import the zpool (use "-f" if necessary) zpool import -f data
It’s magical: zpool will also tell you the host that the drives were on,
which ones are missing, etc.
It’s possible to mount and use zpools. But you will miss out on awesome
things that ZFS is known for. So create a filesystem:
zfs create data/users # Set compression on zfs set compression=gzip data/users
You may want to think twice before you set compression and
deduplication. They take a heavy toll on memory and performance. Here
are some resources:
date +%Y-%m-%dT%k:%M:%S for a nice ISO-8601 formatted date:
# Take a snapshot zfs snapshot tank/data@2012-09-09T18:06:49 # DIsplay snapshots zfs list -t snapshot
ZFS is awesome with NFS. Here, I share a filesystem with my trusted
network, after setting up my NFS server according to the FreeBSD
zfs sharenfs='-network 10.212.8.0 -mask 255.255.255.0 -maproot root' tank/home
Export data is not written to
/etc/exports (as you would expect) but
/etc/zfs/exports. Check your mounts with the usual:
[root@lucifer ~]# showmount -e Exports list on localhost: /tank/home 10.212.8.0
Unlike traditional NFS, you don’t have to restart
mountd every time
you redefine your mount points.
Here are further resources:
See all the
rcvars for each service with this
grep rcvar /usr/local/etc/rc.d/*
This is the stuff that would go into