Adding An NVMe Drive

Hi I’m trying to add an NVMe to my CM4 IO board but am little lost. I have seen this post but it seems quite complicated.

My goal is to use the NVMe as the backing store for a SAMBA container. So my questions are:

  1. How do I go about getting BalenaOS to see my NVMe drive?
  2. Do I need to format the drive and give it a volume name before using the drive? If so would it be easier to do this outside Balena?



I am not totally familiar with the CM4 IO board nor am I familiar with configuring a SAMBA container, but I set up the NVMe for my Jetson board with the following, high-level procedure:

  1. Install BalenaOS on the board. Instructions vary depending on board. See Balena’s documentation for your specific board.

  2. Log into the host via SSH.

  3. I believe the parted command line application is available in the BalenaOS host. I followed the How to Partition and Format Storage Devices in Linux tutorial by DigitalOcean to format the NVMe SSD.

  4. Add ENV UDEV=1 to dockerfile for the service/container.

  5. Create an initialization shell script that mounts the NVMe.

    #!/usr/bin/env bash
    su - -c "mkdir -p /mnt/nvme" root
    device=$(blkid | grep "LABEL=\"nvme\"" | cut -d : -f 1)
    echo "Mounting device = ${device}"
    su - -c "mount -t ext4 -o rw ${device} /mnt/nvme" root
    # May want to call the parent image entrypoint instead
    # exec "$@"
    exec "$@"
  6. Add the initialization shell script as an entrypoint to the dockerfile and provide the default command. This will be highly specific to the samba container you are using, so the following is not going to work and is meant for demonstration.

    ENV UDEV=1
    # Include the script in the image
    COPY /
    # Needed to make the script executable
    RUN chmod +x /
    # The name of the initialization shell script can be anything
    ENTRYPOINT ["/"]
    # Change to the command used by the parent image
    CMD ["samba"]


Thank you for you very detailed reply! I will try this in my container.