Linux Samba server or LXC Container?

baron164

New Member
Jan 16, 2024
25
3
3
I have unutilized storage on my Proxmox hosts and I want to utilize some of it for a samba share. I would normally just create a new Linux server with a virtual disk and make it a samba server. But I see that Proxmox has the ability to do containers, so I am wondering if I should instead of building a vm for samba access, build a container instead?

I am not familiar with how containers in Proxmox work but I am interested and willing to learn.
 
I would normally just create a new Linux server with a virtual disk and make it a samba server.
Bear in mind that using a container won't create any separation...what I have done is to use OpenMediaVault which is based on Debian...it's lightweight VM on Proxmox
 
  • Like
Reactions: baron164
Bear in mind that using a container won't create any separation...what I have done is to use OpenMediaVault which is based on Debian...it's lightweight VM on Proxmox

Thanks, how does OpenMediaVault compare to something like TrueNAS Core (FreeNAS)?
 
Thanks, how does OpenMediaVault compare to something like TrueNAS Core (FreeNAS)?
TrueNAS only supports ZFS. So you have to keep ZFS recommendations in mind like NO hardware raid, lots of (preferably ECC) RAM, no consumer SSDs and especially not QLC NAND nor HDDs using shingled magnetic recording.
So TrueNAS is probably the worst option if you just want something lightweight and simple.
 
Last edited:
Why is this? Can't you just backup the complete container to PBS?
You can, but each time you will have to read the full size of that LXC as only VMs could make use of dirty-bitmapping. So backing up a VMs would be way faster. Lets say you want to share 1TB of data and your data only changes 1GB between backups. An LXC would always need to read the full 1TB. A VM only needs to read the 1GB that changed and could ignore the other 999GB.
 
Last edited:
Hi, my current situation is this

- My Samba server should be lightweight because the disk containing the files would be mounted externally
- I backup my files with rsync (no PBS)

I don't know whether to install samba on an Ubuntu or LXC virtual machine
I would like to understand
Thank you for your time
 
Last edited:
Forgive my poor English
I need to install samba on an Ubuntu VM or an Ubuntu LXC
considering what was written previously
 
Any reason in particular for choosing a VM in this scenario?
Read what @Dunuin said.

My preferred way tbh is to use LXC-Containers and Passthrough a ZFS Folder (dataset) from the Host to the Container.
Those datasets which i passthrough, have all Hourly ZFS-Snapshots and are only exclusively for the Samba Shares.
And Samba has VSS enabled or defined, so i can restore Files simply on Windows natively.
The PBS just backups this way the OS Only and the Shares itself are "snapshotted".

Its very lightweight but too Complicated for a Beginner to Setup i think.

Just my 3 Cents, Cheers
 
  • Like
Reactions: frankco
Any reason in particular for choosing a VM in this scenario?
Apart from above mentioned point/s, using an external disk/device to passthrough to an unprivileged LXC, usually means you have to mount it to the host & then passthrough the mountpoints to the LXC etc. This comes with its own hurdles & issues. See here for example.
 
  • Like
Reactions: frankco
Read what @Dunuin said.

My preferred way tbh is to use LXC-Containers and Passthrough a ZFS Folder (dataset) from the Host to the Container.
Those datasets which i passthrough, have all Hourly ZFS-Snapshots and are only exclusively for the Samba Shares.
And Samba has VSS enabled or defined, so i can restore Files simply on Windows natively.
The PBS just backups this way the OS Only and the Shares itself are "snapshotted".

Its very lightweight but too Complicated for a Beginner to Setup i think.

Just my 3 Cents, Cheers
I'm think trying to do exactly this. You then host the passed through folder in the LXC as a SMB Share right? If so, would you mind giving a short rundown on how you did it?
 
Sure.

First you need to create a dataset on your PVE Host and mount it somewhere.
Here is an example:
Code:
root@proxmox:~# zfs list
NAME                      USED  AVAIL  REFER  MOUNTPOINT
HDD_Z2                   21.5T  82.2T   114K  /HDD_Z2
HDD_Z2/PVE_Backup         696G  82.2T   696G  /PVE_Backup
HDD_Z2/SMB_Data           125G  82.2T   125G  /smb/Data
HDD_Z2/SMB_Downloads      776G  82.2T   776G  /smb/Downloads
HDD_Z2/SMB_Media         18.8T  82.2T  18.8T  /smb/Media
HDD_Z2/SMB_Other         1.11T  82.2T  1.11T  /smb/Other
HDD_Z2/SMB_Rechnungen     235M  82.2T   235M  /smb/Rechnungen

Second you need to passthrough that dataset to your LXC Container, i simply use the mounted location of that dataset and edit my LXC container Config, because thats not possible in the GUI for whatever reason....
Here is my Example Config:
Code:
arch: amd64
cores: 2
features: nesting=1
hostname: linux-srv
memory: 2048
mp0: /smb/Other,mp=/smb_storage/Other,replicate=0
mp1: /smb/Media,mp=/smb_storage/Media,replicate=0
mp2: /smb/Data,mp=/smb_storage/Data,replicate=0
mp3: /smb/Rechnungen,mp=/smb_storage/Rechnungen,replicate=0
mp4: /smb/Downloads,mp=/smb_storage/Downloads,replicate=0
net0: name=eth0,bridge=vmbr0,hwaddr=50:6D:FF:F3:C8:DD,ip=dhcp,ip6=auto,type=veth
onboot: 1
ostype: ubuntu
rootfs: NVME_ZFS_R10:subvol-103-disk-1,mountoptions=noatime,size=16G
startup: order=3
swap: 512
lxc.cap.drop:
lxc.cap.drop: mac_admin mac_override sys_module sys_rawio

Only the mpX are important....
replicate=0 ist pretty important, to not Backup those Volumes with PBS...
Depending from the LXC Container if it Priviliged or Unpriviliged, you need to change the Rights on your PVE Host on the dataset mountpoint (to the UID:GID of the root user in the LXC Container).
But you need that only on a unpriviliged container, so you can skip that, because to run samba alone inside LXC you need a Priviliged Container as far i remember.

To find out the UID:GID of the Container:
Simply chmod the mountpoint from your dataset to 777 on the proxmox host, then enter your lxc container as root and create a file with nano or whatever on the mounted storage....
Then simply check on the proxmox host again with what UID:GID the file was created.... and chown the whole mountpoint to that...
And surely change back 777 to anything normal, like 775.

Then install on your Proxmox host anything that does the snapshots for you on your datasets...
I think in the meantime this is even implemented in Proxmox already...
However, im using still https://github.com/wezm/zfs-autosnap
Because i come from a time, where autosnapshots werent implemented in Proxmox....

Configure them....

then you have to configure smb.conf in your LXC container, one of my VSS Shares looks like this:
Code:
[Data]
   comment = Server Data
   path = /smb_storage/Data
   guest ok = no
   browseable = yes
   valid users = mw, root
   write list = mw, root
   create mask = 0775
   force create mode = 0775
   force user = samba
   force group = sambagroup
   vfs objects = shadow_copy2
   shadow:snapdir = /smb_storage/Data/.zfs/snapshot
   shadow:basedir = /smb_storage/Data
   shadow:sort = desc
   shadow:format = %Y-%m-%dT%H:%M:%SZ-autosnap

but you will probably change that a little, to a format and directory that matches your snapshotting method.


Thats a super Cheap How-To, but should help you at least, or give you the right direction....
Cheers
 
Sure.

First you need to create a dataset on your PVE Host and mount it somewhere.
Here is an example:
Code:
root@proxmox:~# zfs list
NAME                      USED  AVAIL  REFER  MOUNTPOINT
HDD_Z2                   21.5T  82.2T   114K  /HDD_Z2
HDD_Z2/PVE_Backup         696G  82.2T   696G  /PVE_Backup
HDD_Z2/SMB_Data           125G  82.2T   125G  /smb/Data
HDD_Z2/SMB_Downloads      776G  82.2T   776G  /smb/Downloads
HDD_Z2/SMB_Media         18.8T  82.2T  18.8T  /smb/Media
HDD_Z2/SMB_Other         1.11T  82.2T  1.11T  /smb/Other
HDD_Z2/SMB_Rechnungen     235M  82.2T   235M  /smb/Rechnungen

Second you need to passthrough that dataset to your LXC Container, i simply use the mounted location of that dataset and edit my LXC container Config, because thats not possible in the GUI for whatever reason....
Here is my Example Config:
Code:
arch: amd64
cores: 2
features: nesting=1
hostname: linux-srv
memory: 2048
mp0: /smb/Other,mp=/smb_storage/Other,replicate=0
mp1: /smb/Media,mp=/smb_storage/Media,replicate=0
mp2: /smb/Data,mp=/smb_storage/Data,replicate=0
mp3: /smb/Rechnungen,mp=/smb_storage/Rechnungen,replicate=0
mp4: /smb/Downloads,mp=/smb_storage/Downloads,replicate=0
net0: name=eth0,bridge=vmbr0,hwaddr=50:6D:FF:F3:C8:DD,ip=dhcp,ip6=auto,type=veth
onboot: 1
ostype: ubuntu
rootfs: NVME_ZFS_R10:subvol-103-disk-1,mountoptions=noatime,size=16G
startup: order=3
swap: 512
lxc.cap.drop:
lxc.cap.drop: mac_admin mac_override sys_module sys_rawio

Only the mpX are important....
replicate=0 ist pretty important, to not Backup those Volumes with PBS...
Depending from the LXC Container if it Priviliged or Unpriviliged, you need to change the Rights on your PVE Host on the dataset mountpoint (to the UID:GID of the root user in the LXC Container).
But you need that only on a unpriviliged container, so you can skip that, because to run samba alone inside LXC you need a Priviliged Container as far i remember.

To find out the UID:GID of the Container:
Simply chmod the mountpoint from your dataset to 777 on the proxmox host, then enter your lxc container as root and create a file with nano or whatever on the mounted storage....
Then simply check on the proxmox host again with what UID:GID the file was created.... and chown the whole mountpoint to that...
And surely change back 777 to anything normal, like 775.

Then install on your Proxmox host anything that does the snapshots for you on your datasets...
I think in the meantime this is even implemented in Proxmox already...
However, im using still https://github.com/wezm/zfs-autosnap
Because i come from a time, where autosnapshots werent implemented in Proxmox....

Configure them....

then you have to configure smb.conf in your LXC container, one of my VSS Shares looks like this:
Code:
[Data]
   comment = Server Data
   path = /smb_storage/Data
   guest ok = no
   browseable = yes
   valid users = mw, root
   write list = mw, root
   create mask = 0775
   force create mode = 0775
   force user = samba
   force group = sambagroup
   vfs objects = shadow_copy2
   shadow:snapdir = /smb_storage/Data/.zfs/snapshot
   shadow:basedir = /smb_storage/Data
   shadow:sort = desc
   shadow:format = %Y-%m-%dT%H:%M:%SZ-autosnap

but you will probably change that a little, to a format and directory that matches your snapshotting method.


Thats a super Cheap How-To, but should help you at least, or give you the right direction....
Cheers
Thank you very much for your quick reply, I will give it a go as soon as I can and report back!
 

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 yours easily in our online shop.

Buy now!