# Load Kernel Modules: cdc\_ether

**URL:** <https://forums.balena.io/t/load-kernel-modules-cdc-ether/371239>\
**Category:** balenaOS\
**Tags:** docker, network, kernelmodules, raspberrypi4\
**Created:** [August 27, 2024, 2:57pm UTC](https://forums.balena.io/t/load-kernel-modules-cdc-ether/371239 "2024-08-27T14:57:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![embedded](https://avatars.discourse-cdn.com/v4/letter/e/43a26b/32.png) [@embedded](https://forums.balena.io/u/embedded)\
**Post date:** [August 27, 2024, 2:57pm UTC](https://forums.balena.io/t/load-kernel-modules-cdc-ether/371239/1 "2024-08-27T14:57:37Z")

</div>

Hi

I have two services running on a Raspberry Pi CM4 with BalenaOS. One of these services is responsible for running a custom script to initialize the Quectel EC200U modem. After running the initialization script, we need to execute the following two commands to obtain an IP address on the `usb0` interface:

```auto
# Reload the cdc_ether module:
modprobe -r cdc_ether
modprobe cdc_ether

```

Currently, we establish an SSH connection to the host OS and run the commands above. After that, if we turn off WiFi, we can see that our device correctly switches to using the cellular network and works as expected:

 ![bridge](https://global.discourse-cdn.com/balena/original/2X/b/b51fc704731fd5ad2f650b10e1e85a69112589cd.png)

Is there any way to run these commands to load the `cdc_ether` module from within a service container? We would like to automate this step and add these two commands to our modem initialization script. However, it seems we don’t have access to the `cdc_ether` module inside the container, even though our `docker-compose.yml` file includes the `io.balena.features.kernel-modules` label.

Here is the relevant part of our `docker-compose.yml` file:

```auto
version: "2"
services:
 modem:
    build: ./modem
    privileged: true
    labels:
      io.balena.features.dbus: '1'
      io.balena.features.firmware: '1'
      io.balena.features.kernel-modules: '1'
      io.balena.features.supervisor-api: '1'
      io.balena.features.balena-api: '1'

```

---

<div class="post-metadata">

**Author:** ![embedded](https://avatars.discourse-cdn.com/v4/letter/e/43a26b/32.png) [@embedded](https://forums.balena.io/u/embedded)\
**Post date:** [August 29, 2024, 4:05pm UTC](https://forums.balena.io/t/load-kernel-modules-cdc-ether/371239/2 "2024-08-29T16:05:21Z")

</div>

[alexgg](https://forums.balena.io/u/alexgg) Do you have any insights on why I might be having trouble loading this kernel module inside the container?"

---

<div class="post-metadata">

**Author:** ![embedded](https://avatars.discourse-cdn.com/v4/letter/e/43a26b/32.png) [@embedded](https://forums.balena.io/u/embedded)\
**Post date:** [September 2, 2024, 2:16am UTC](https://forums.balena.io/t/load-kernel-modules-cdc-ether/371239/3 "2024-09-02T02:16:02Z")

</div>

[shaunmulligan1](https://forums.balena.io/u/shaunmulligan1) Do you have any insights on why I might be having trouble loading this kernel module inside the container?

---

<div class="post-metadata">

**Author:** ![mani13jha](https://avatars.discourse-cdn.com/v4/letter/m/c6cbf5/32.png) [@mani13jha](https://forums.balena.io/u/mani13jha)\
**Post date:** [September 3, 2024, 8:55am UTC](https://forums.balena.io/t/load-kernel-modules-cdc-ether/371239/4 "2024-09-03T08:55:19Z")

</div>

@embedded Please add this line(network\_mode: host) to your docker-compose.yml and then try again. I am not sure but this should have to work. Please let me know if this does not work for you.

```auto
version: "2"
services:
 modem:
    build: ./modem
    privileged: true
    network_mode: host
    labels:
      io.balena.features.dbus: '1'
      io.balena.features.firmware: '1'
      io.balena.features.kernel-modules: '1'
      io.balena.features.supervisor-api: '1'
      io.balena.features.balena-api: '1'

```

---

<div class="post-metadata">

**Author:** ![embedded](https://avatars.discourse-cdn.com/v4/letter/e/43a26b/32.png) [@embedded](https://forums.balena.io/u/embedded)\
**Post date:** [September 3, 2024, 10:49am UTC](https://forums.balena.io/t/load-kernel-modules-cdc-ether/371239/5 "2024-09-03T10:49:22Z")

</div>

> [@mani13jha](#):
>
> ```auto
> network_mode: host
> 
> ```

Hi @mani13jha

Thank you for your suggestion. I’ll give it a try in a few minutes, but I’ve found a different solution:

In my Dockerfile, I run a script to mount a temporary filesystem inside the container with the `cdc_ether.ko` kernel module file.

```auto
#!/bin/sh
set -e # Exit immediately if a command exits with a non-zero status

# Check if the mount-point directory exists
if [! -d "/mnt/tmpfs"]; then
    echo "Creating mount point directory..."
    mkdir /mnt/tmpfs
else
    echo "Mount point directory already exists."
fi

# Check if the mount-point directory exists
echo "Checking if /mnt/tmpfs is mounted..."
if mountpoint -q /mnt/tmpfs; then
    echo "/mnt/tmpfs is already mounted."
else
    echo "Mounting tmpfs at /mnt/tmpfs..."
    mount -t tmpfs -o size=10M tmpfs /mnt/tmpfs
fi

# Copy cdc_ether.ko file to our tmpfs
echo "Copying cdc_ether.ko to /mnt/tmpfs..."
cp /usr/src/app/startup-scripts/cdc_ether.ko /mnt/tmpfs

```

Then, I run a script to initialize the Quectel EC200U module with a set of AT commands and after that, the script load the kernel module from the tmpfs automatically, and it worked as expected:

```auto
rmmod cdc_ether
insmod /mnt/fs1/cdc_ether.ko

```
