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.
Before setting up Samba, we need a dedicated storage partition where shared files will be stored.
List Available Storage Devices:
lsblk
This 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/sdb1
This 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/sdb1
This formats the partition with the EXT4 file system and labels it as Storage
.
Create a Mount Point:
mkdir -p /mnt/storage
This command creates a directory where we will mount the storage drive.
Mount the Partition:
mount /dev/sdb1 /mnt/storage
This mounts the newly formatted partition to the /mnt/storage
directory.
To ensure that the partition is mounted automatically at boot, we need to add an entry to /etc/fstab
.
Edit fstab:
nano /etc/fstab
Add the following line to the file:
UUID=01c126f6-5a2a-46b8-9f1b-475720978b8f /mnt/storage ext4 defaults,noatime 0 0
Replace the UUID with the actual UUID of the partition found using the blkid
command.
Apply the Changes:
mount -a
This mounts all the filesystems defined in /etc/fstab
.
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/].
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 user smbuser
.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.A Samba user is required for authentication.
Create a New User:
useradd -m -s /bin/bash smbuser
This command creates a new user named smbuser
.
Set a Password for the User:
passwd smbuser
Add the User to Samba:
smbpasswd -a smbuser
This command sets a Samba-specific password for smbuser
.
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
.
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
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.
Your insights drive us! For any questions, feedback, or thoughts, feel free to connect:
If you found this guide beneficial, don’t hesitate to share it with your network. Until the next guide, happy coding! 🚀
Quick Links
Legal Stuff