{"id":272,"date":"2022-12-06T10:35:00","date_gmt":"2022-12-06T15:35:00","guid":{"rendered":"http:\/\/sycured.127.0.0.1.sslip.io\/?p=272"},"modified":"2024-01-14T12:33:06","modified_gmt":"2024-01-14T17:33:06","slug":"compile-deploy-freebsd-kernel","status":"publish","type":"post","link":"http:\/\/10.42.0.68:8080\/blog\/compile-deploy-freebsd-kernel","title":{"rendered":"Compile and deploy FreeBSD kernel"},"content":{"rendered":"\n
Sometimes it’s necessary to build a new kernel to add some modules. In my case, it’s adding RACK TCP Stack.<\/p>\n\n\n\n
Requirements:<\/p>\n\n\n\n
First, a little check that sources are available:<\/p>\n\n\n\n
ls \/usr\/src\/sys\/amd64\/conf\/<\/code><\/pre>\n\n\n\nif it’s not the case, you need a few steps (for example with FreeBSD 13.1-RELEASE on AMD64):<\/p>\n\n\n\n
cd \/tmp\nfetch http:\/\/ftp.freebsd.org\/pub\/FreeBSD\/releases\/amd64\/13.1-RELEASE\/src.txz\ntar -zxf -C \/ src.txz\nrm src.txz\nfreebsd-update fetch install<\/code><\/pre>\n\n\n\nNew kernel: RACK<\/h3>\n\n\n\n
Sources are available so it’s time to create the configuration file, build the kernel, and install it.<\/p>\n\n\n\n
Create the configuration file<\/p>\n\n\n\n
cat > \/usr\/src\/sys\/amd64\/conf\/RACK <<EOF\ninclude GENERIC\nident RACK\nmakeoptions WITH_EXTRA_TCP_STACKS=1\noptions RATELIMIT\noptions TCPHPTS\nEOF<\/code><\/pre>\n\n\n\nTime to build and install it<\/p>\n\n\n\n
make -j 8 KERNCONF=RACK buildkernel\nmake installkernel KERNCONF=RACK KODIR=\/boot\/kernel.rack<\/code><\/pre>\n\n\n\nDeployment<\/h2>\n\n\n\nlocal node<\/h3>\n\n\n\nrsync -avz --progress -h \/boot\/kernel.rack REMOTE_NODE:\/tmp<\/code><\/pre>\n\n\n\nremote node<\/h3>\n\n\n\n
As root:<\/p>\n\n\n\n
mv \/tmp\/kernel.rack \/boot\/\nchown -R root:root \/boot\/kernel.rack<\/code><\/pre>\n\n\n\nConfigure \/boot\/loader.conf<\/strong> like:<\/p>\n\n\n\nkernel=\"kernel.rack\"\nbootfile=\"kernel.rack\"\nmodule_path=\"\/boot\/kernel.rack\"\nautoboot_wait=\"0\"\nautoboot_delay=\"0\"\nbeastie_disable=\"YES\"\nboot_serial=\"YES\"\nloader_logo=\"none\"\ncryptodev_load=\"YES\"\ncc_htcp_load=\"YES\"<\/code><\/pre>\n\n\n\nNew lines added from the configuration in my previous post: Install FreeBSD 13.1 on Oracle Cloud<\/a>:<\/p>\n\n\n\n\n- kernel=”kernel.rack”<\/li>\n\n\n\n
- bootfile=”kernel.rack”<\/li>\n\n\n\n
- module_path=”\/boot\/kernel.rack”<\/li>\n\n\n\n
- cc_htcp_load=”YES”<\/li>\n<\/ul>\n\n\n\n
Add at the top of \/etc\/rc.conf<\/strong><\/p>\n\n\n\nkld_list=\"${kld_list} \/boot\/kernel.rack\/tcp_bbr.ko\"<\/code><\/pre>\n\n\n\nNow, a little sysctl configuration to use the new stack<\/p>\n\n\n\n
cat >> \/etc\/sysctl.conf <<EOF\nnet.inet.tcp.cc.algorithm=htcp\nnet.inet.tcp.functions_default=bbr\nnet.inet.tcp.functions_inherit_listen_socket_stack=0\nEOF<\/code><\/pre>\n\n\n\nReboot on the new kernel<\/p>\n\n\n\n
reboot<\/code><\/pre>\n\n\n\nConclusion<\/h2>\n\n\n\n
It’s not very complicated to build and deploy this kernel including RACK stack (HTCP<\/a> and BBR<\/a>)<\/p>\n\n\n\nAt scale, it’s needed to build a pkg and use an internal repository.<\/p>\n","protected":false},"excerpt":{"rendered":"
Sometimes it’s necessary to build a new kernel to add some modules. In my case, it’s adding RACK TCP Stack. Requirements: Compile the new kernel Check sources First, a little check that sources are available: if it’s not the case, you need a few steps (for example with FreeBSD 13.1-RELEASE on AMD64): New kernel: RACK […]<\/p>\n","protected":false},"author":1,"featured_media":84,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"saved_in_kubio":false,"footnotes":""},"categories":[28],"tags":[34,32],"_links":{"self":[{"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/posts\/272"}],"collection":[{"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/comments?post=272"}],"version-history":[{"count":1,"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/posts\/272\/revisions"}],"predecessor-version":[{"id":273,"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/posts\/272\/revisions\/273"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/media\/84"}],"wp:attachment":[{"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/media?parent=272"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/categories?post=272"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/tags?post=272"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}