Setting Up Samba on Proxmox A Detailed Guide

Table Of Contents
Introduction
Samba is a powerful and flexible tool that enables file sharing between Linux and Windows systems. In this guide, I will walk through the detailed steps to install and configure Samba on a Proxmox server.
Step 1: Identify and Prepare the Storage Drive
Before setting up Samba, we need a dedicated storage partition where shared files will be stored.
List Available Storage Devices:
lsblkThis command lists all the block devices (storage drives) connected to the server. It helps us identify the correct disk to use.
Check the Partition’s UUID:
blkid /dev/sdb1This command displays the UUID (Unique Identifier) of the partition
/dev/sdb1, which will be useful for mounting the drive persistently.Format the Partition with EXT4 Filesystem:
mkfs.ext4 -L Storage /dev/sdb1This formats the partition with the EXT4 file system and labels it as
Storage.Create a Mount Point:
mkdir -p /mnt/storageThis command creates a directory where we will mount the storage drive.
Mount the Partition:
mount /dev/sdb1 /mnt/storageThis mounts the newly formatted partition to the
/mnt/storagedirectory.
Step 2: Configure Persistent Mounting
To ensure that the partition is mounted automatically at boot, we need to add an entry to /etc/fstab.
Edit fstab:
nano /etc/fstabAdd the following line to the file:
UUID=01c126f6-5a2a-46b8-9f1b-475720978b8f /mnt/storage ext4 defaults,noatime 0 0Replace the UUID with the actual UUID of the partition found using the
blkidcommand.Apply the Changes:
mount -aThis mounts all the filesystems defined in
/etc/fstab.
Step 3: Install Samba
Now, we install the Samba package to enable file sharing.
apt update && apt install samba
This command updates the package list and installs Samba.
If you have error check (this)[https://shadynagy.com/how-to-fix-proxmox-update-errors-step-by-step-guide/].
Step 4: Configure Samba
- Edit Samba Configuration File:Add the following section at the end of the file:nano /etc/samba/smb.conf[Storage]path = /mnt/storagewritable = yesbrowseable = yesguest ok = novalid users = smbuser
path = /mnt/storage: Specifies the shared directory.writable = yes: Allows writing files to the share.browseable = yes: Makes the share visible on the network.guest ok = no: Prevents guest access.valid users = smbuser: Restricts access to the usersmbuser.
Step 5: Start and Enable Samba Services
We need to enable and start the Samba services to ensure it runs automatically on boot.
systemctl enable smbd nmbdsystemctl start smbd nmbd
smbd: Handles file sharing services.nmbd: Manages network name resolution.
Step 6: Create a Samba User
A Samba user is required for authentication.
Create a New User:
useradd -m -s /bin/bash smbuserThis command creates a new user named
smbuser.Set a Password for the User:
passwd smbuserAdd the User to Samba:
smbpasswd -a smbuserThis command sets a Samba-specific password for
smbuser.
Step 7: Set Permissions
We need to grant the user permission to access the storage directory.
chown -R smbuser:smbuser /mnt/storage
This command changes the ownership of /mnt/storage to smbuser.
Step 8: Restart Samba Services
To apply all changes, restart the Samba services:
systemctl restart smbd nmbd
To verify that Samba is running correctly, check its status:
systemctl status smbd nmbd
Conclusion
Now, the Samba server is up and running. You can access the shared folder from a Windows machine by entering \\your-server-ip\Storage MAC (smb://your-server-ip/Storage) in the File Explorer.
This guide ensures that the configuration is persistent across reboots, secure, and accessible only to authorized users.
Feedback and Questions
Your insights drive us! For any questions, feedback, or thoughts, feel free to connect:
- Email: shady@shadynagy.com
- Twitter: @ShadyNagy_
- LinkedIn: Shady Nagy
- GitHub: ShadyNagy
If you found this guide beneficial, don’t hesitate to share it with your network. Until the next guide, happy coding! 🚀

