# Full custom kernel/base/release process



## FabricioGuzzy (Mar 31, 2019)

Hello,
I am now creating a full customized ISO/IMG with some kernel additions also, a BASE system without several parts.
Here is my process so far:

- Cloned Freebsd 12 "Releng/12.0" Source to  /usr/src using:

```
git clone -b releng/12.0 https://github.com/freebsd/freebsd.git
```

- I have created my custom Kernel config file named "MYKERNEL" under  /usr/src/sys/amd64/conf/MYKERNEL with the following:

```
include        GENERIC
nooptions    KDB_TRACE
options        DDB

ident        MYKERNEL

nooptions    MAC        # TrustedBSD MAC Framework
nooptions    COMPAT_FREEBSD4    # Compatible with FreeBSD4
nooptions    COMPAT_FREEBSD5    # Compatible with FreeBSD5
nooptions    COMPAT_FREEBSD6    # Compatible with FreeBSD6
nooptions    COMPAT_FREEBSD7    # Compatible with FreeBSD7

options        GEOM_MIRROR
options        GEOM_UZIP
options        GEOM_ELI
options        GEOM_BDE

options        TMPFS
options        UNIONFS
options        NULLFS
options        PPS_SYNC

# USB support
nooptions    USB_DEBUG    # enable debug msgs
device        uhid        # "Human Interface Devices"

# addons
device        tap
device        gre
device        if_bridge
device        carp
device        lagg
device        vte

# IP/IPFW
options        IPFIREWALL_DEFAULT_TO_ACCEPT
options        IPFIREWALL_VERBOSE
options        IPSTEALTH

# Netgraph
options        NETGRAPH        #netgraph(4) system
options        NETGRAPH_VLAN
options        NETGRAPH_L2TP
options        NETGRAPH_BPF
options        NETGRAPH_ETHER
options        NETGRAPH_IFACE
options        NETGRAPH_EIFACE
options        NETGRAPH_PPP
options        NETGRAPH_PPPOE
options        NETGRAPH_PPTPGRE
options        NETGRAPH_RFC1490
options        NETGRAPH_SOCKET
options        NETGRAPH_TTY
options        NETGRAPH_MPPC_ENCRYPTION
options        NETGRAPH_UI
options        NETGRAPH_VJC
options        NETGRAPH_KSOCKET
options        NETGRAPH_LMI
options        NETGRAPH_ONE2MANY
options        NETGRAPH_BRIDGE
options        NETGRAPH_CISCO
options        NETGRAPH_ECHO
options        NETGRAPH_ASYNC
options        NETGRAPH_FRAME_RELAY
options        NETGRAPH_HOLE
options        NETGRAPH_TEE
options        NETGRAPH_TCPMSS
options        NETGRAPH_PIPE
options        NETGRAPH_CAR
options        NETGRAPH_DEFLATE
options        NETGRAPH_PRED1

# IPSEC
options        TCP_SIGNATURE
device        enc

# ALTQ
options        ALTQ
options        ALTQ_CBQ
options        ALTQ_RED
options        ALTQ_RIO
options        ALTQ_HFSC
options        ALTQ_PRIQ
options        ALTQ_FAIRQ
options        ALTQ_NOPCC
options        ALTQ_CODEL

# Squid related settings
options        MSGMNB=8192    # max # of bytes in a queue
options        MSGMNI=40    # number of message queue identifiers
options        MSGSEG=512    # number of message segments per queue
options        MSGSSZ=32    # size of a message segment
options        MSGTQL=2048    # max messages in system

device        pf
device        pflog
device        pfsync

device        rndtest        # FIPS 140-2 entropy tester
device        hifn        # Hifn 7951, 7781, etc.
options        HIFN_DEBUG    # enable debugging support: hw.hifn.debug
options        HIFN_RNDTEST    # enable rndtest support
device        ubsec        # Broadcom 5501, 5601, 58xx
device        safe        # safe -- SafeNet crypto accelerator
device        padlock

device        speaker

options        DEVICE_POLLING
options        MROUTING

# Default serial speed
options        CONSPEED=115200

#Enable uchcom - MYKERNEL
device    uchcom
```

- I have also created 2 other custom files named "MYKERNEL_make.conf" and "MYKERNEL_src.conf", both under /usr/src/release/conf/  

- Here is the "MYKERNEL_make.conf"


```
# Default serial console speed
BOOT_COMCONSOLE_SPEED=115200
BOOT_BOOT0_COMCONSOLE_SPEED=0
```

- and Here is the "MYKERNEL_src.conf"


```
WITHOUT_AMD=YES
WITHOUT_ASSERT_DEBUG=YES
WITHOUT_ATM=YES
WITHOUT_AUDIT=YES
WITHOUT_AUTHPF=YES
WITHOUT_BLACKLIST=YES
WITHOUT_BLUETOOTH=YES
WITHOUT_CALENDAR=YES
WITHOUT_CAPSICUM=YES
WITHOUT_CASPER=YES
WITHOUT_CCD=YES
WITHOUT_CTM=YES
WITHOUT_CUSE=YES
WITHOUT_DICT=YES
WITHOUT_EXAMPLES=YES
WITHOUT_FINGER=YES
WITHOUT_FLOPPY=YES
WITHOUT_FREEBSD_UPDATE=YES
WITHOUT_GAMES=YES
WITHOUT_GCOV=YES
WITHOUT_GROFF=YES
WITHOUT_HAST=YES
WITHOUT_HTML=YES
WITHOUT_INETD=YES
WITHOUT_IPFILTER=YES
WITHOUT_JAIL=YES
WITHOUT_LIB32=YES
WITHOUT_LOCALES=YES
WITHOUT_LOCATE=YES
WITHOUT_LPR=YES
WITHOUT_MAIL=YES
WITHOUT_MAN=YES
WITHOUT_NLS=YES
WITHOUT_NLS_CATALOGS=YES
WITHOUT_NS_CACHING=YES
WITHOUT_NTP=YES
WITHOUT_PC_SYSINSTALL=yes
WITHOUT_PORTSNAP=yes
WITHOUT_PROFILE=YES
WITHOUT_QUOTAS=YES
WITHOUT_RCMDS=YES
WITHOUT_RCS=YES
WITHOUT_SETUID_LOGIN=YES
WITHOUT_SHAREDOCS=YES
WITHOUT_SVNLITE=YES
WITHOUT_TALK=YES
WITHOUT_TESTS=yes
WITHOUT_TOOLCHAIN=YES
WITHOUT_UNBOUND=YES
```

-To compile the Kernel with the options, I have used the following command:


```
make -j22 KERNCONF=MYKERNEL __MAKE_CONF="/usr/src/release/conf/MYKERNEL_make.conf" buildkernel
```

- Everything went fine with the Kernel compilation - No  errors

- Then I have compiled the BASE system, with the following command:


```
make -j22 KERNCONF=MYKERNEL buildworld
```

- It also compiled successfully - No Errors.

-That´s when the problems started - When I start the "release" process, some errors come up.

- I have used the following command to start the "Release" process:


```
make -j22 KERNCONF=MYKERNEL SRCCONF="/usr/src/release/conf/MYKERNEL_src.conf" __MAKE_CONF="/usr/src/release/conf/MYKERNEL_make.conf" -DNOPORTS -DNODOC -DNOSRC release
```

-Which results in this Error message:


```
--- distributeworld ---
mkdir -p /tmp/install.pfVLtAKz
progs=$(for prog in [ awk cap_mkdb cat chflags chmod chown cmp cp  date echo egrep find grep id install   ln make mkdir mtree mv pwd_mkdb  rm sed services_mkdb sh sort strip sysctl test true uname wc zic tzsetup  ; do  if progpath=`which $prog`; then  echo $progpath;  else  echo "Required tool $prog not found in PATH." >&2;  exit 1;  fi;  done);  libs=$(ldd -f "%o %p\n" -f "%o %p\n" $progs 2>/dev/null | sort -u |  while read line; do  $line;  if [ "$2 $3" != "not found" ]; then  echo $2;  else  echo "Required library $1 not found." >&2;  exit 1;  fi;  done);  cp $libs $progs /tmp/install.pfVLtAKz
--- kernel.txz ---
--- packagekernel ---
cd //usr/obj/usr/src/amd64.amd64/release/dist/kernel;  tar cvf - --exclude '*.debug' . |  xz -T 0 > //usr/obj/usr/src/amd64.amd64/release/dist/kernel.txz
cd: //usr/obj/usr/src/amd64.amd64/release/dist/kernel: No such file or directory
*** [packagekernel] Error code 2

make[3]: stopped in /usr/src
1 error

make[3]: stopped in /usr/src
--- distributekernel ---
--- distributekernel ---
--- packagekernel ---
*** [packagekernel] Error code 2

make[2]: stopped in /usr/src
--- distributekernel ---
mkdir -p //usr/obj/usr/src/amd64.amd64/release/dist
cd /usr/obj/usr/src/amd64.amd64/sys/MYKERNEL;  MACHINE_ARCH=amd64  MACHINE=amd64  CPUTYPE= CC="cc -target x86_64-unknown-freebsd12.0 --sysroot=/usr/obj/usr/src/amd64.amd64/tmp -B/usr/obj/usr/src/amd64.amd64/tmp/usr/bin" CXX="c++  -target x86_64-unknown-freebsd12.0 --sysroot=/usr/obj/usr/src/amd64.amd64/tmp -B/usr/obj/usr/src/amd64.amd64/tmp/usr/bin"  CPP="cpp -target x86_64-unknown-freebsd12.0 --sysroot=/usr/obj/usr/src/amd64.amd64/tmp -B/usr/obj/usr/src/amd64.amd64/tmp/usr/bin"  AS="as" AR="ar" LD="ld" LLVM_LINK=""  NM=nm OBJCOPY="objcopy"  RANLIB=ranlib STRINGS=  SIZE="size" PATH=/usr/obj/usr/src/amd64.amd64/tmp/legacy/usr/sbin:/usr/obj/usr/src/amd64.amd64/tmp/legacy/usr/bin:/usr/obj/usr/src/amd64.amd64/tmp/legacy/bin:/usr/obj/usr/src/amd64.amd64/tmp/usr/sbin:/usr/obj/usr/src/amd64.amd64/tmp/usr/bin:  LD_LIBRARY_PATH=  PATH_LOCALE=/locale    PATH=/usr/obj/usr/src/amd64.amd64/tmp/legacy/usr/sbin:/usr/obj/usr/src/amd64.amd64/tmp/legacy/usr/bin:/usr/obj/usr/src/amd64.amd64/tmp/legacy/bin:/usr/obj/usr/src/amd64.amd64/tmp/usr/sbin:/usr/obj/usr/src/amd64.amd64/tmp/usr/bin:/sbin:/bin:/usr/sbin:/usr/bin make KERNEL=kernel  DESTDIR=/usr/obj/usr/src/amd64.amd64/release/dist/kernel  install
A failure has been detected in another branch of the parallel make

make[4]: stopped in /usr/obj/usr/src/amd64.amd64/sys/MYKERNEL
*** [distributekernel] Error code 2

make[3]: stopped in /usr/src
1 error
```

Question: Do I have to "install" the compiled kernel to create my custom ISO/IMG file somehow? I tried with the following, with no success:


```
make -j22 KERNCONF=MYKERNEL installkernel
```

- Judging by the error message, it seems the "make release" process is loooking for a file "kernel.txz" which actually doesn't exist anywhere.

Any help is very welcome!

Thanks!
Fabricio.


----------



## FabricioGuzzy (Apr 1, 2019)

One additional information:
I could successfully move forward only without the "-j22" option after the "make" command.
It seems the paralel compilation process is breaking for some reason during the "release"  process.

Background:  Host Machine is a DUAL XEON 12 Cores E5 Family with 128 GB RAM. (Total 24 Cores) - I don't use to use all of them to avoid make the machine too slow during compilations.

Fabricio.


----------

