Adding An NVMe Drive

Hello,

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 docker-entrypoint.sh "$@"
    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 custom-init.sh /custom-init.sh
    
    # Needed to make the script executable
    RUN chmod +x /custon-init.sh
    
    # The name of the initialization shell script can be anything
    ENTRYPOINT ["/custom-init.sh"]
    
    # Change to the command used by the parent image
    CMD ["samba"]