How to CIFS Mount?

Hi,

has somebody managed to mount CIFS volumes in RancherOS? NFS works nicely in my configuration (see below) but CIFS does not work at all…

sudo vi /var/lib/rancher/conf/cloud-config.yml

mount -t nfs 192.168.178.123:/volume/abc /mnt/abc
mount -t cifs -o credentials=/root/.smbcredentials //192.168.178.123/bcd /mnt/bcd

Do you have any suggestions?

Best regards

Peter

I don’t believe you can using the default console as no rpcbind package is present for mounting any type of remote file system.

Switching to the ubuntu-console should make this possible (as at worst you can just install the package).

Hello,

I had a similar question and was struggling to get it working on our internal/private cloud. Here’s a stripped down version that will get you up and running.

#cloud-config
hostname: namehere
rancher:
   console: ubuntu
   network:
    interfaces:
      eth*:
        dhcp: true
   sysctl:
    vm.max_map_count: 262999
   services:
    rancher-agent1:
      image: rancher/agent:v1.2.2
      command: http://1.2.3.4:8080/v1/projects/1a5/scripts/the:unique:codehere
      privileged: true
      volumes:
        - /var/run/docker.sock:/var/run/docker.sock
      environment:
        CATTLE_HOST_LABELS: env=test&os=rancheros
runcmd:
  - chown -R :rancher /mnt
  - chmod -R g+rw /mnt
  - apt update
  - apt install cifs-utils -y
  - sudo mount //windowsFileServer/sharename -t cifs -o username=theUserName,password=thePassWordHere /mnt
ssh_authorized_keys:
  - ssh-rsa AAA...

This line is for running Elasticsearch on the host (off topic but may be helpful to others):

sysctl:
vm.max_map_count: 262999

To add more mounts you can create a yml file on rancheros like the following:

runcmd:

  • sudo mount //windowsFileServer/sharename2 -t cifs -o username=theUserName,password=thePassWordHere /mnt2

Then ‘sudo ros config merge -i moreMounts.yml’ and reboot. You can find the entry in /var/lib/rancher/conf/cloud-config.yml. This was brought to you in part by maik “No risk, no fun.” :slight_smile: and documentation.

version 1.0.4, successed

#cloud-config
mounts:
- - //192.168.1.1
  - /mnt/smb
  - cifs
  - username=guest,iocharset=utf8,_netdev

Hello! Did you happen to make this work on RancherOS on v1.5.8? Here’s what I’ve set up:

mounts:
-  - "//my_nas_address/share_name"
   - "/mnt/mountpoint"
   - "cifs"
   - "credentials=/root/.cifs,iocharset=utf8,_netdev"

And it doesn’t work. The sudo mount -t cifs "//my_nas_address/share_name" "/mnt/mountpoint" -o credentials=/root/.cifs,iocharset=utf8,_netdev works (but only after I switched to ubuntu console and I installed cifs-utils package.

The tail of dmesg says:

[   15.420866] FS-Cache: Netfs 'cifs' registered for caching
[   15.421124] Key type cifs.spnego registered
[   15.421142] Key type cifs.idmap registered
[   15.422067] Unable to determine destination address.

Any ideas on where to look for the issue?


Edit: I changed the “my_nas_address” (which was a DNS-resolved name) with an IP address and now, the error in dmesg is:

CIFS VFS: No username specified

After changing the credentials=/root/.cifs to username=XXX,password=YYY it stared to work. But I don’t like that workaround.

To solve first issue (Unable to determine destination address) I tried adding name resolve order = host lmhosts wins bcast to /etc/samba/smb.conf, but it sill didn’t accept the host DNS name.

I can live with hardcoded IP address, but I cannot stand the secrets being hardcoded in the config file.

Anyone got an idea on how to make this work with credfile and DNS name?


edit: The issues above, when unrelated to RancherOS, according to the internet, should be solved by installing cifs-utils. So my guess is that the udev container of RancherOS does not have it, so it’s impossible to do? Can someone confirm?