This guide will walk you through setting up SMB (Server Message Block) shares on an Ubuntu server, enabling seamless file access from your Windows machines. Whether you're looking to back up your critical data, collaborate on projects, or simply streamline file sharing, this guide provides a detailed roadmap.
An Ubuntu server (command-line access is sufficient) A Windows machine for testing SMB access Familiarity with basic terminal commands
sudo apt update
sudo apt install samba
sudo mkdir -p /shared_drive1
sudo mkdir -p /media/external_drive
Identify the Drive: Use the command lsblk to list all connected storage devices and identify your external drive (e.g., /dev/sdb1).Create a Mount Point: If you haven't already, create a mount point for the external drive:sudo mkdir -p /media/external_drive
Mount the Drive: Mount the external drive with appropriate permissions for your Samba user (e.g., "SAMBA_USER"):sudo mount -t exfat -o uid=$(id -u SAMBA_USER),gid=$(id -g SAMBA_USER) /dev/sdb1 /media/external_drive
sudo nano /etc/fstab
/dev/sdb1 /media/external_drive exfat defaults,uid=1500,gid=1500 0 0
sudo mount -a
sudo nano /etc/samba/smb.conf
[SHAREDDRIVE1]
path = /shared_drive1
valid users = SAMBA_USER
read only = no
browsable = yes
[EXTERNALDRIVE]
path = /media/external_drive
valid users = SAMBA_USER
read only = no
browsable = yes
sudo smbpasswd -a SAMBA_USER
sudo chown -R SAMBA_USER /shared_drive1
sudo chown -R SAMBA_USER /media/external_drive
sudo chmod 775 /shared_drive1
sudo chmod 775 /media/external_drive
sudo systemctl restart smbd
Permission Denied Errors: Double-check directory ownership and permissions. Verify that the UID and GID values in /etc/fstab match your Samba user's.
Mount Issues with External Drives: If the drive is "busy," identify and terminate any processes accessing it using lsof /media/external_drive. Always unmount the drive (sudo umount /media/external_drive) before making any changes.
Samba Configuration Changes Not Taking Effect: Ensure you've restarted the Samba service (sudo systemctl restart smbd) after making changes.
Testing Issues from Windows: Disconnect and reconnect any mapped drives to refresh permissions.
0 comments:
Post a Comment