I tried to install a new kernel, and the chflags failed. How do I get around this?
Short answer: You are probably at security level greater than 0. Reboot directly to single user mode to install the kernel.
Long answer: FreeBSD disallows changing system flags at security levels greater than 0. You can check your security level with the command:
# sysctl kern.securelevel
You cannot lower the security level; you have to boot to single mode to install the kernel, or change the security level in /etc/rc.conf then reboot. See the init(8) man page for details on securelevel, and see /etc/defaults/rc.conf and the rc.conf(5) man page for more information on rc.conf.