element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
RoadTests & Reviews
  • Products
  • More
RoadTests & Reviews
Blog HARTING MICA: SD Card as Shared Storage
  • Blog
  • RoadTest Forum
  • Documents
  • RoadTests
  • Reviews
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join RoadTests & Reviews to participate - click to join for free!
  • Share
  • More
  • Cancel
  • Author Author: Jan Cumps
  • Date Created: 9 Jun 2019 11:34 PM Date Created
  • Views 1448 views
  • Likes 6 likes
  • Comments 6 comments
Related
Recommended
  • mica
  • harting
  • sdcard
  • smb
  • cifs
  • linux

HARTING MICA: SD Card as Shared Storage

Jan Cumps
Jan Cumps
9 Jun 2019

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.

image

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:

imageimage

 

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

 

image

 

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:

image

(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:

 

image

 

The share is now available on the network.

image

 

 

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.

 

Related Blog
HARTING MICA: Develop and Debug a C GPIO Example in Eclipse - Part 1: User Experience
HARTING MICA: Develop and Debug a C GPIO Example in Eclipse - Part 2: MICA Debian Stretch Setup
HARTING MICA: Develop and Debug a C GPIO Example in Eclipse - Part 3: Eclipse Configuration on Windows
HARTING MICA: Develop and Debug a C GPIO Example in Eclipse - Part 4: Build and Debug the GPIO Example
HARTING MICA: Make a Safe(r) MQTT Container with Certificate and TLS/SSL
HARTING MICA: Manage Access to USB and other Devices
HARTING MICA: SD Card as Shared Storage
HARTING MICA: Alpine Linux and another MQTT Container with Certificate and TLS/SSL
HARTING MICA: Connect to Amazon Web Services
HARTING MICA: Install Java 8 VM in a Debian Stretch Container
HARTING MICA: Read BOSCH CISS Sensor with Java - part 1: USB Connect and Listen
  • Sign in to reply

Top Comments

  • Jan Cumps
    Jan Cumps over 6 years ago in reply to DAB +1
    DAB wrote: ... Is there a way to secure the data on the SD card? ... There's the physical security: the sdcard is mounted inside the box and it's not removed or replaced in 1-2-3. When installed in a locked…
  • DAB
    DAB over 6 years ago in reply to Jan Cumps

    Hi Jan,

     

    I do have an RPi, but I am in the middle of doing final edits on Volume 14 of my Sea War Series.

     

    DAB

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 6 years ago in reply to DAB

    DAB , I'm checking out this explanation of on the fly encrypt/decrypt block device data. The SD card is a block device.

    https://wiki.archlinux.org/index.php/Disk_encryption

     

    Do you have a Raspberry Pi or a BeagleBone? You could play along if you have one of those. Maybe we can validate each other's encryption approaches and try to find weaknesses?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 6 years ago in reply to DAB

    DAB  wrote:

     

    ...

     

    Is there a way to secure the data on the SD card?

     

    ...

    There's the physical security: the sdcard is mounted inside the box and it's not removed or replaced in 1-2-3. When installed in a locked din-rail rack, you have control over who can place another or use a laptop to add/read files.

    On linux, I've set it up that users need to be part of a dedicated linux group in order to write or create files (or be granted elevated permissions via sudo). As long as the password of root is not published, no one can create files.

     

    To share the SD Card on the network, HARTING made a dedicated container, called NAS. When you deploy and activate that, the sd card is accessible to other computers in the network via a username and password.

    If you don't run that container, it's accessible via the local containers on the Mica only.

     

    Linux also supports encrypted filesystems. I have not reviewed those yet.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 6 years ago

    Good post.

    There are a lot of possibilities for sharing stored data from remote collection stations not necessarily on line.

     

    Is there a way to secure the data on the SD card?

     

    DAB

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 6 years ago in reply to Jan Cumps

    Got it!

     

    umount /media/sdcard
    chmod 770 /media/sdcard
    adduser jancumps plugdev

     

    id jancumps
    uid=1002(jancumps) gid=100(users) groups=100(users),20(dialout),27(sudo),46(plugdev)

     

    -> gid 46 is plugdev

     

    in /etc/fstab

    /dev/mmcblk1p1 /media/sdcard vfat nofail,gid=46,umask=007  0 0

     

    mount /media/sdcard

     

    Log in as jancumps again (group assignment needs new logon)

     

     

    I've updated the article with the full instructions, including the additional mount creation and user management tasks.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube