VM and LXC mount CIFS problem. [SOLVED]

monsignore

New Member
Jan 16, 2020
5
2
3
53
EDIT: [solved] see end of this post for the solution



Hello,

I'm installing Proxmox 6.1-5 to replace several servers, and enjoy the possibility of using LXC and virtualization.

Scénario :

One VM to offer fileserver services SMB/CIFS : OpenMediavault or Linux.
LXC Turnkey Centos 8 : to use docker.
Mint Cinnamo VM : to work
Other VM for services.


The scenario exclude the use of smb/cifs share mounted on Proxmox host that will link to LXC as cifs/smb share are provided by a VM hosted on proxmox.
The cifs/smb shares won't be available before OpenMediavault VM is up and running, making Proxmox mounts fail.
  • Mounting shares to Mint VM works successfully.
  • I try to connect LXC Turnkey Centos 8 to shares but I ain't achieve it.



Mint VM
To test the mount, I tried to mount SMB/CIFS share from Mint VM terminal to an existing Linux file server and it worked flawlessly.
To make the mount reboot proof I used it in fstab :

Code:
monsignore@monsignore-Standard-PC-i440FX-PIIX-1996:~/mnt$ sudo cat /etc/fstab
# /etc/fstab: static file system information.
......
//192.168.222/shared /home/monsignore/mnt cifs username=xxxxxxxxxxxxxx,password=xxxxxxxxxxxxx,rw,users,dir_mode=0777,file_mode=0777 0 0

Works with ReadWrite for everyone !!


LXCs:
I tried to mount the same share with fstab on Privilegied and UnPrivilegied LXC Turnkey Centos8.
I'm looged as root.


Privilegied Centos8 LXC
I tried x2 different mounts so I created x2 directories :
Code:
[root@CentosPrivilegied media]# ls -lan /media
total 16
drwxr-xr-x  4 0 0 4096 Jan 27 13:03 .
drwxr-xr-x 19 0 0 4096 Jan 27 06:53 ..
drwxr-xr-x  2 0 0 4096 Jan 26 11:46 shared1
drwxr-xr-x  2 0 0 4096 Jan 27 13:03 shared2
[root@CentosPrivilegied media]# ls -la /media
total 16
drwxr-xr-x  4 root root 4096 Jan 27 13:03 .
drwxr-xr-x 19 root root 4096 Jan 27 06:53 ..
drwxr-xr-x  2 root root 4096 Jan 26 11:46 shared1
drwxr-xr-x  2 root root 4096 Jan 27 13:03 shared2


Coresponding mounts in fstab:
Code:
[root@CentosPrivilegied media]# cat /etc/fstab
//192.168.1.222/shared /media/shared1 cifs username=xxxxxx,password=xxxxxx,rw,users,dir_mode=0777,file_mode=0777 0 0
//192.168.1.222/shared /media/shared2 cifs username=xxxxxx,password=xxxxxx,uid=0,gid=0,iocharset=utf8,noperm 0 0

Results:
Code:
[root@CentosPrivilegied media]# mount -a
mount: /media/shared1: permission denied.
mount: /media/shared2: permission denied.

None of the mounts works.




UnPrivilegied Centos8 LXC
I tried x2 different mounts so I created x2 directories :
Code:
[root@Docker-Centos media]# ls -lan /media
total 16
drwxr-xr-x  4 100000 100000 4096 Jan 27 13:09 .
drwxr-xr-x 19 100000 100000 4096 Jan 27 06:51 ..
drwxr-xr-x  2      0      0 4096 Jan 27 13:09 shared1
drwxr-xr-x  2      0      0 4096 Jan 27 13:09 shared2
[root@Docker-Centos media]# ls -la /media
total 16
drwxr-xr-x  4 100000 100000 4096 Jan 27 13:09 .
drwxr-xr-x 19 100000 100000 4096 Jan 27 06:51 ..
drwxr-xr-x  2 root   root   4096 Jan 27 13:09 shared1
drwxr-xr-x  2 root   root   4096 Jan 27 13:09 shared2


Corresponding mounts in fstab:
Code:
[root@CentosPrivilegied media]# cat /etc/fstab
//192.168.1.222/shared /media/shared1 cifs username=xxxxxxxxxxx,password=xxxxxxxxxxx,rw,users,dir_mode=0777,file_mode=0777 0 0
//192.168.1.222/shared /media/shared2 cifs username=xxxxxxxxxxx,password=xxxxxxxxxxx,uid=0,gid=0,iocharset=utf8,noperm 0 0

Results:
Code:
[root@Docker-Centos media]# mount -a
mount: only root can use "--all" option (effective UID is 100000)

None of the mountsworks.


I tried to integrate the gid uid in the fstab :

Code:
[root@CentosPrivilegied media]# cat /etc/fstab
//192.1681.222/shared /media/shared1 cifs username=xxxxxxxxxxx,password=xxxxxxxxxxx,uid=100000,gid=100000,iocharset=utf8,noperm 0 0
//192.1681.222/shared /media/shared2 cifs username=xxxxxxxxxxx,password=xxxxxxxxxxx,uid=101001,gid=101001,iocharset=utf8,noperm 0 0

Results
Code:
[root@Docker-Centos media]# mount -a
mount: only root can use "--all" option (effective UID is 100000)
But no mounts either.


Thanks in advance for your help.


EDIT : THE SOLUTION thanks to Wolfgang :


First you can mount CIFS shares in a LXC ONLY if it's Privilegied.
You MUST untick "Unprivilegied Container" when creating the LXC

Screenshot_4.jpg


After creation you start the LXC, you have to modify Feature in Proxmox/Your LXC Option/Feature: adding CIFS capability:

Screenshot_5.jpg





you log in as root/sudo and install cifs-util :

Code:
[root@Centos-Docker shared]# yum install cifs-utils

Once done edit the LXC's fstab :

Code:
[root@Centos-Docker shared]# vi /etc/fstab
//192.168.1.XXX/shared /media/shared cifs username=xxxxxxxxxxxxxx,password=xxxxxxxxxxxx,rw,users,dir_mode=0777,file_mode=0777 0 0

Mount the share on your LXC :

Code:
[root@Centos-Docker shared]# mount -a

And voilà !
Code:
[root@Centos-Docker shared]# mount |grep 222
//192.168.1.222/shared on /media/shared type cifs (rw,nosuid,nodev,noexec,relatime,vers=3.1.1,cache=strict,username=monsignore,uid=0,noforceuid,gid=0,noforcegid,addr=192.168.1.222,file_mode=0777,dir_mode=0777,soft,nounix,serverino,mapposix,rsize=4194304,wsize=4194304,bsize=1048576,echo_interval=60,actimeo=1)
[root@Centos-Docker shared]#

You got a fully Read-Write share mounted on your LXC.


Once again a huge thanks for this product, and for the support team ! ;)
 
Last edited:

wolfgang

Proxmox Staff Member
Staff member
Oct 1, 2014
6,496
474
103
Hi,

There is a CIFS checkbox in the options Tab(section Features) what has to be used.
You can only use it with privileged containers.
 
  • Like
Reactions: monsignore

monsignore

New Member
Jan 16, 2020
5
2
3
53
Great thanks for your help !

I'm going to edit my post to give a full answer to the community.
 
May 11, 2019
203
10
23
Hi,

There is a CIFS checkbox in the options Tab(section Features) what has to be used.
You can only use it with privileged containers.


@wolfgang
Is it easier to create a new privileged container or convert an unprivileged ?

Having some issues running this:

root@pve:/mnt/pve/Backups/dump# pct restore 1001 vzdump-lxc-1000-2020_09_02-11_49_01.tar.zst -ignore-unpack-errors 1 -unprivileged -storage Backups
400 Parameter verification failed.
storage: storage 'Backups' does not support container directories
pct restore <vmid> <ostemplate> [OPTIONS]
 

wolfgang

Proxmox Staff Member
Staff member
Oct 1, 2014
6,496
474
103
Is it easier to create a new privileged container or convert an unprivileged ?
The easiest way is to backup and restores as a privileged container, but hit takes time.
 

BrentPn

New Member
Feb 21, 2021
1
1
1
21
Hi guys, sorry to re bring this all up again but I 'm having an issue with this at the moment. I have all the above configured as described

-privileged container,
-cifs feature option checked,
-cifs-utils installed,
-mounts added to /etc/fstab

but I can not get the mount to persist after reboot. They mount perfectly fine and operate as they should as long as the container remains on but I have to mount -a after every reboot. I have been scouring the forums all day today to no avail, can someone set me straight?
 
  • Like
Reactions: alex-gee

alex-gee

New Member
Apr 3, 2021
2
0
1
44
Hi guys, sorry to re bring this all up again but I 'm having an issue with this at the moment. I have all the above configured as described

-privileged container,
-cifs feature option checked,
-cifs-utils installed,
-mounts added to /etc/fstab

but I can not get the mount to persist after reboot. They mount perfectly fine and operate as they should as long as the container remains on but I have to mount -a after every reboot. I have been scouring the forums all day today to no avail, can someone set me straight?
I'm new to Proxmox, but I managed to setup a homeserver with it. 1x VM for OMV (Fileserver) and 1x LXC (running Ubuntu with Plex Media Server). I have the exact same issue than BrentPn.
I tried to delay the startup of the Ubuntu LXC as I was thinking that OMV might need to be started up first, but no luck so far.

I also see a error message on the pve:
CIFS VFS: Error connecting to Socket. Aborting Operation
CIFS VFS: cifs_mount failed w/return code = -2

Any clues how to solve it (beside typing sudo mount -a after each reboot of the pve)?
 
May 11, 2019
203
10
23
I'm new to Proxmox, but I managed to setup a homeserver with it. 1x VM for OMV (Fileserver) and 1x LXC (running Ubuntu with Plex Media Server). I have the exact same issue than BrentPn.
I tried to delay the startup of the Ubuntu LXC as I was thinking that OMV might need to be started up first, but no luck so far.

I also see a error message on the pve:
CIFS VFS: Error connecting to Socket. Aborting Operation
CIFS VFS: cifs_mount failed w/return code = -2

Any clues how to solve it (beside typing sudo mount -a after each reboot of the pve)?
I can't actually give you any tips in particular, but I do run ubuntu LXC with emby and all what I did was an entry in /etc/fstab as:

//<server> <mount_point> cifs guest,uid=998,gid=998,forceuid,forcegid,iocharset=utf8 0 0

And I checked my config as it has only:

cat 1000.conf
arch: amd64
hostname: emby-vm
memory: 2048
net0: name=eth0,bridge=vmbr0,firewall=1,hwaddr=5A:B3:94:AA:AA:ED,ip=dhcp,ip6=dhcp,type=veth
onboot: 1
ostype: ubuntu
rootfs: VMs:vm-1000-disk-0,size=40G
swap: 512

Hope some help :)
 

super_edgui

New Member
May 7, 2020
1
0
1
38
EDIT: [solved] see end of this post for the solution



Hello,

I'm installing Proxmox 6.1-5 to replace several servers, and enjoy the possibility of using LXC and virtualization.

Scénario :

One VM to offer fileserver services SMB/CIFS : OpenMediavault or Linux.
LXC Turnkey Centos 8 : to use docker.
Mint Cinnamo VM : to work
Other VM for services.


The scenario exclude the use of smb/cifs share mounted on Proxmox host that will link to LXC as cifs/smb share are provided by a VM hosted on proxmox.
The cifs/smb shares won't be available before OpenMediavault VM is up and running, making Proxmox mounts fail.
  • Mounting shares to Mint VM works successfully.
  • I try to connect LXC Turnkey Centos 8 to shares but I ain't achieve it.



Mint VM
To test the mount, I tried to mount SMB/CIFS share from Mint VM terminal to an existing Linux file server and it worked flawlessly.
To make the mount reboot proof I used it in fstab :

Code:
monsignore@monsignore-Standard-PC-i440FX-PIIX-1996:~/mnt$ sudo cat /etc/fstab
# /etc/fstab: static file system information.
......
//192.168.222/shared /home/monsignore/mnt cifs username=xxxxxxxxxxxxxx,password=xxxxxxxxxxxxx,rw,users,dir_mode=0777,file_mode=0777 0 0

Works with ReadWrite for everyone !!


LXCs:
I tried to mount the same share with fstab on Privilegied and UnPrivilegied LXC Turnkey Centos8.
I'm looged as root.


Privilegied Centos8 LXC
I tried x2 different mounts so I created x2 directories :
Code:
[root@CentosPrivilegied media]# ls -lan /media
total 16
drwxr-xr-x  4 0 0 4096 Jan 27 13:03 .
drwxr-xr-x 19 0 0 4096 Jan 27 06:53 ..
drwxr-xr-x  2 0 0 4096 Jan 26 11:46 shared1
drwxr-xr-x  2 0 0 4096 Jan 27 13:03 shared2
[root@CentosPrivilegied media]# ls -la /media
total 16
drwxr-xr-x  4 root root 4096 Jan 27 13:03 .
drwxr-xr-x 19 root root 4096 Jan 27 06:53 ..
drwxr-xr-x  2 root root 4096 Jan 26 11:46 shared1
drwxr-xr-x  2 root root 4096 Jan 27 13:03 shared2


Coresponding mounts in fstab:
Code:
[root@CentosPrivilegied media]# cat /etc/fstab
//192.168.1.222/shared /media/shared1 cifs username=xxxxxx,password=xxxxxx,rw,users,dir_mode=0777,file_mode=0777 0 0
//192.168.1.222/shared /media/shared2 cifs username=xxxxxx,password=xxxxxx,uid=0,gid=0,iocharset=utf8,noperm 0 0

Results:
Code:
[root@CentosPrivilegied media]# mount -a
mount: /media/shared1: permission denied.
mount: /media/shared2: permission denied.

None of the mounts works.




UnPrivilegied Centos8 LXC
I tried x2 different mounts so I created x2 directories :
Code:
[root@Docker-Centos media]# ls -lan /media
total 16
drwxr-xr-x  4 100000 100000 4096 Jan 27 13:09 .
drwxr-xr-x 19 100000 100000 4096 Jan 27 06:51 ..
drwxr-xr-x  2      0      0 4096 Jan 27 13:09 shared1
drwxr-xr-x  2      0      0 4096 Jan 27 13:09 shared2
[root@Docker-Centos media]# ls -la /media
total 16
drwxr-xr-x  4 100000 100000 4096 Jan 27 13:09 .
drwxr-xr-x 19 100000 100000 4096 Jan 27 06:51 ..
drwxr-xr-x  2 root   root   4096 Jan 27 13:09 shared1
drwxr-xr-x  2 root   root   4096 Jan 27 13:09 shared2


Corresponding mounts in fstab:
Code:
[root@CentosPrivilegied media]# cat /etc/fstab
//192.168.1.222/shared /media/shared1 cifs username=xxxxxxxxxxx,password=xxxxxxxxxxx,rw,users,dir_mode=0777,file_mode=0777 0 0
//192.168.1.222/shared /media/shared2 cifs username=xxxxxxxxxxx,password=xxxxxxxxxxx,uid=0,gid=0,iocharset=utf8,noperm 0 0

Results:
Code:
[root@Docker-Centos media]# mount -a
mount: only root can use "--all" option (effective UID is 100000)

None of the mountsworks.


I tried to integrate the gid uid in the fstab :

Code:
[root@CentosPrivilegied media]# cat /etc/fstab
//192.1681.222/shared /media/shared1 cifs username=xxxxxxxxxxx,password=xxxxxxxxxxx,uid=100000,gid=100000,iocharset=utf8,noperm 0 0
//192.1681.222/shared /media/shared2 cifs username=xxxxxxxxxxx,password=xxxxxxxxxxx,uid=101001,gid=101001,iocharset=utf8,noperm 0 0

Results
Code:
[root@Docker-Centos media]# mount -a
mount: only root can use "--all" option (effective UID is 100000)
But no mounts either.


Thanks in advance for your help.


EDIT : THE SOLUTION thanks to Wolfgang :


First you can mount CIFS shares in a LXC ONLY if it's Privilegied.
You MUST untick "Unprivilegied Container" when creating the LXC

View attachment 14471


After creation you start the LXC, you have to modify Feature in Proxmox/Your LXC Option/Feature: adding CIFS capability:

View attachment 14472





you log in as root/sudo and install cifs-util :

Code:
[root@Centos-Docker shared]# yum install cifs-utils

Once done edit the LXC's fstab :

Code:
[root@Centos-Docker shared]# vi /etc/fstab
//192.168.1.XXX/shared /media/shared cifs username=xxxxxxxxxxxxxx,password=xxxxxxxxxxxx,rw,users,dir_mode=0777,file_mode=0777 0 0

Mount the share on your LXC :

Code:
[root@Centos-Docker shared]# mount -a

And voilà !
Code:
[root@Centos-Docker shared]# mount |grep 222
//192.168.1.222/shared on /media/shared type cifs (rw,nosuid,nodev,noexec,relatime,vers=3.1.1,cache=strict,username=monsignore,uid=0,noforceuid,gid=0,noforcegid,addr=192.168.1.222,file_mode=0777,dir_mode=0777,soft,nounix,serverino,mapposix,rsize=4194304,wsize=4194304,bsize=1048576,echo_interval=60,actimeo=1)
[root@Centos-Docker shared]#

You got a fully Read-Write share mounted on your LXC.


Once again a huge thanks for this product, and for the support team ! ;)
Funcionó, hacer todo en ese mismo orden!, muchas gracias por compartir
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get your own in 60 seconds.

Buy now!