# Nanobsd Build with Linux C7 Support



## SurtursRevenge (May 6, 2022)

Hello,

i am trying to build my own custom nanobsd image with some software preloaded. I need Linux C7 Support in my nanobsd image so i added the packages to the pkg install. I am getting the following error : 
Cannot install package: kernel missing 64-bit Linux support

As far as i understang the pkg setup is checking for the linux support Kernel Module which can be enabled with 
	
	



```
kldload linux64.ko
```
So my question is how do i do this in my build/install world. My generic kernel should support linux but the module is not loaded in the build chroot. Or do i have a different problem here ? 

p.s. i tried to install packages with cust_pkgng first, but was not able to get it to work at all so i created my own cust_install_pkgs (see below)


Here is the pkg log output:

```
install -y linux-c7-lttng-ust
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 3 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
        linux-c7-lttng-ust: 2.4.1
        linux-c7-userspace-rcu: 0.7.16
        linux_base-c7: 7.9.2009

Number of packages to be installed: 3

The process will require 233 MiB more space.
36 MiB to be downloaded.
[1/3] Fetching linux-c7-lttng-ust-2.4.1.pkg: .......... done
[2/3] Fetching linux-c7-userspace-rcu-0.7.16.pkg: ........ done
[3/3] Fetching linux_base-c7-7.9.2009.pkg: .......... done
Checking integrity... done (0 conflicting)
[1/3] Installing linux_base-c7-7.9.2009...
Cannot install package: kernel missing 64-bit Linux support
pkg: PRE-INSTALL script failed
```


Here is the nano config i use to build my image :

```
NANO_NAME=Nanox64
NANO_IMAGES=2

# Kernel
NANO_KERNEL=GENERIC
NANO_ARCH=amd64
TARGET_ARCH=amd64; export TARGET_ARCH

# Image 
FlashDevice SanDisk 4g
NANO_IMGNAME="nanox64.full.img"
NANO_IMG1NAME="nanox64.update.img"

NANO_BOOT2CFG="-h"
NANO_BOOTLOADER="boot/boot0"

CONF_INSTALL='
WITHOUT_BLUETOOTH=YES
WITHOUT_FORTRAN=YES
WITHOUT_HTML=YES
WITHOUT_LPR=YES
WITHOUT_SENDMAIL=YES
WITHOUT_SHAREDOCS=YES
WITHOUT_EXAMPLES=YES
WITHOUT_CALENDAR=YES
'

cust_install_pkgs() (

    PACKAGES="
pkg
vim
libunwind
curl
openssl
linux-c7-lttng-ust
"

    mount -t devfs devfs ${NANO_WORLDDIR}/dev


    /usr/sbin/pkg -c ${NANO_WORLDDIR} update

    for p in $PACKAGES
    do
        /usr/sbin/pkg -c ${NANO_WORLDDIR} install -y $p
    done

    rm -xrf ${NANO_WORLDDIR}/var/cache/pkg/*

    # Move pkgdb to /usr so package changes persist after reboots.
    # / needs to be remounted rw for pkg to work at runtime
    cd  ${NANO_WORLDDIR}
    mkdir -p usr/pkgdb
    cd var/db/pkg
    find . -print | cpio -dumpl ../../../usr/pkgdb
    cd ..
    rm -xrf pkg
    ln -s ../../usr/pkgdb pkg

    umount ${NANO_WORLDDIR}/dev
)
customize_cmd cust_install_pkgs
```


----------



## Phishfry (May 6, 2022)

SurtursRevenge said:


> My generic kernel should support linux but the module is not loaded in the build chroot. Or do i have a different problem here ?


You need to slipstream your configuration files in.

When I build NanoBSD for a specific target I do a bare bones regular install. Then take note of the packages needed to build your appliance. But importantly build your config files.
Then when you make your NanoBSD you slipstream in the files.
See the /tools/tools/nanobsd/files directory for a look at what 'slipstreaming in your config' looks like..
This is the default location. You can specify for your build. 

So for your build you would add the command to load the linux64 subsystem in /files/etc/rc.conf just like a regular machine.


----------



## SurtursRevenge (May 17, 2022)

I tought again and the PKG is run on the build system with the Buildenv as parameter. 
So i did a kdload on the build system and the PKG install was successfull. 

I was not able to test the actual nanobsd itself as i have some other issues with the created image like it crashes after 59 seconds uptime because it is trying to do an checkdisk. 
I will keep you post after i figured out my other issues when i am able to test the linux C7


----------

