I roadtested the Harting MICA Complete IIoT Starter Kit.
In this follow up, some experiments with the SD card: how to mount it in a container and how to share it on the network.
The documentation for the SD card options is terse. What you can see here are my try-outs. If you have a better solution, please comment.
For this exercise, It's expected that you have a formatted SD card installed in the mica, with at least one file on it - so that we can see if the content can be accessed.
Use the Internal Character Device to Mount the SD Card on a Container
Thank you Gough Lui for the help to get this working.
The sdcard is available as /dev/mmcblk1p1.
You can mount it by registering it in the fstab file.
However, when the init.d system calls mount at startup, the SD card device isn't ready yet.
A solution is to run it at system (re)boot, after devices are initialised. One option is to use cron.
You need to install 2 modules:
apt-get install findutils apt-get install cron
Create a mount point:
mkdir /media/sdcard chmod 770 /media/sdcard
Add the following line at the end of /etc/fstab:
/dev/mmcblk1p1 /media/sdcard vfat nofail,gid=46,umask=017,dmask=007 0 0
This registers it as a root writeable file system. Other users need sudo, except when they are in the group plugdev (46).
In the next section, I show how to grant individual users access.
umask 007 and dmask 17 are these responsiblilities:
I wanted to block users from executing files from the sdcard, but they need executable right on directories or they can't access them.
By setting umask=007, files are not executable, except for root. By setting dmask=017, directories are executable and the user can navigate to them.
Then add this line to /etc/crontab (I added it to the begin because it's something that runs early on, but you can place it anywhere in the file):
@reboot root mount /media/sdcard
Test this. I tried several combinations, such as only rebooting the container and restarting the full mica.
Check the mount point to see if you can see - and have access to - the mount.
ls -l /media/sdcard
Giving other users access
You do that by adding those users to the plugdev group:
adduser jancumps plugdev
Next time the user account logs in, it can create and write files on the sdcard.
Here's a directory listing and successful write made by my user:
(I edited the picture but this reflects the reality)
Share the SD card on the Network
There's a dedicated container to give network access to the SD card. It allows you to publish the SD card as a share.
Configure it similar to this:
The share is now available on the network.
If you want to mount this shared drive into a mica container, install CIFS utilities package.
apt-get install cifs-utils
Instead of the entry in the previous chapter, add this to the /etc/fstab:
//NAS/<sharename you used in the NAS container> /media/sdcard cifs credentials=/home/<youruser>/.smb 0 0
Make a file /home/<youruser>/.smb with the following content (password is the one you configured in the NAS container settings):
user=root password=<password you used in the NAS container> domain=home
I could not get this to work by using the @reboot hook in /etc/crontab. I used a 1 minute schedule:
* * * * * root mount /media/sdcard
Disadvantage, except for the resource use every minute, is that when you unmount the volume, it mounts again. It may not be what you want.