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:
- How do I go about getting BalenaOS to see my NVMe drive?
- 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?
Thanks,
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:
-
Install BalenaOS on the board. Instructions vary depending on board. See Balena’s documentation for your specific board.
-
Log into the host via SSH.
-
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.
-
Add ENV UDEV=1
to dockerfile for the service/container.
-
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 "$@"
-
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"]
@ts-cfield
Thank you for you very detailed reply! I will try this in my container.