User Tools

Site Tools




08 Samba

Under Linux, Samba (SMB-protokoll, former CIF) is the connection to Windows Networks. NI LinuxRT 2016 supports the old (deprecated) Samba version 3.6, LinuxRT 2018 supports the new (actual) Samba version 4.6 which has support of Microsoft Active Directory (AD), among other things.

More information about Samba: (german)

Mount a Windows Network Share

To mount a Windows Network Share the most common way - and suitable for LinuxRT - is to use the Samba Client CIFS. CIFS is a virtual file system that enables the possibility to mount a network share into the local file system. It is not necessary to install the whole Samba Server for this use case.


To use the CIFS virtual file system the package cifs-utils is necessary. Install it with:

$ opkg install cifs-utils

Temporary Mount

“Temporary Mount” means that you are on the LinuxRT command line (e.g. via SSH) and mount the network share. If you logout the mount will be closed. This approach is good for testing or for just down-/uploading some files from/to a server.

First a directory to mount the share into is needed. Then the common mount command with special options for CIFS is used. You need to be logged in with root privileges!

$ mkdir /mnt/smb
$ mount -t cifs -o username=otto,password=geheim // /mnt/smb

The directory /mnt/smb is only an example, any other empty directory with sufficient access rights will work.

Only users with root rights (e.g. user “admin”) can mount a share in this way. See section Mounting as lvuser for a workaround.

The share can be unmounted with:

$ umount /mnt/smb

Static Mount

The network share is automatic mounted when the LinuxRT device boot. This setup is suitable for systems where an application starts and needs access to a network share without further actions.

Again, a directory to mount the share inside is needed (if it doesn't already exist).

$ mkdir /mnt/smb

Automatic mounting of file systems is handled in the file /etc/fstab. Add a new line in the following pattern:

// /mnt/smb cifs username=otto,password=geheim 0 0
Don't change the existing lines, it could break LinuxRT!

The Problem

In tests on a cRIO-9030 with LinuxRT 4.0.0f0 this alone doesn't work. When the cRIO is booting the mounting of file systems is executed before the network is up and running, hence mounting the network share fails.

The Solution

A workaround is to disable the automatic mounting by adding the option noauto and add a call to the mount command at the end of the boot process. To do this create a new file with the following content in /etc/rc5.d/. The filename should start with S99 to be executed as late as possible in the boot order (e.g. S99_mount_smb).


mount /mnt/MOUNT_DIR

The new file must have execution rights.

$ chmod +x /etc/rc5.d/S99_mount_smb

Another option is to execute the mount command inside the LabVIEW programm with the System Exec VI. To do this the right way see the next chapter, too.

Mounting as lvuser

lvuser is the standard account for running all LabVIEW programs. Because this user has no root privileges it can not mount a network share without further configuration. First, a line in the file /etc/fstab like above is needed and this line must have the option users to allow any user to mount and unmount a file system.

Example entry in fstab:

// /mnt/smb cifs noauto,users,username=otto,password=geheim 0 0

Second, the CIFS mount program must have the SUID-Bit set. To do this execute the following command (as admin):

$ chmod +s /sbin/mount.cifs

Now it's possible to mount and unmount the network share as user lvuser, e.g. from LabVIEW with System

File Owner and Permissions

In default the mounted files and directories have the user- and group-id from the server. To map the IDs to a local user (e.g. lvuser) you can add the mount options (in the mount-command or in fstab) uid=USER and gid=GROUP. If the user lvuser and the group ni have the ID 500, a complete line in the file fstab could be:

// /mnt/smb cifs noauto,users,uid=500,gid=500,username=otto,password=geheim 0 0


kb/ni-rt/linuxrt/samba.txt · Last modified: 2021/02/04 09:26 by joerg.hampel