How to Install Samba & NFS
-
2. System update and install core packages
Update your Fedora system and install all essential packages required for both Samba and NFS server setup.
sudo dnf update -y
sudo dnf install -y epel-release
sudo dnf install -y samba samba-client samba-common sssd realmd krb5-workstation oddjob oddjob-mkhomedir adcli samba-common-tools
sudo dnf install -y nfs-utils nfs4-acl-tools rpcbind
sudo dnf install -y policycoreutils-python-utils selinux-policy-devel
-
3. Create canonical directories and permissions
Create shared directories under /srv (recommended for server data) and set the right POSIX permissions before applying SELinux contexts.
sudo mkdir -p /srv/samba/share
sudo mkdir -p /srv/nfs/data
sudo chown -R root:root /srv/samba /srv/nfs
sudo chmod -R 2770 /srv/samba/share
-
4. SELinux: persistent file contexts for Samba and NFS
Label Samba share directories with the samba_share_t type so smbd can access them. For NFS exports, use nfs_t and enable the needed SELinux booleans. Use
semanage fcontextfor persistent labeling and apply withrestorecon.sudo semanage fcontext -a -t samba_share_t '/srv/samba(/.*)?'
sudo restorecon -Rv /srv/samba
sudo semanage fcontext -a -t nfs_t '/srv/nfs(/.*)?'
sudo restorecon -Rv /srv/nfs
sudo setsebool -P nfs_export_all_rw on
-
5. Samba basic config and test share
Create a minimal smb.conf for your Fedora Samba server with a secure test share. Use hosts allow and ACLs for access control; AD users/groups will be mapped later.
sudo mv /etc/samba/smb.conf /etc/samba/smb.conf.orig
sudo tee /etc/samba/smb.conf <<'EOF' [global] workgroup = EXAMPLE server string = Fedora Samba Server security = ADS realm = EXAMPLE.COM unix password sync = no client signing = mandatory server signing = mandatory idmap config * : backend = tdb template homedir = /home/%D/%U winbind use default domain = yes [share] path = /srv/samba/share browsable = yes read only = no create mask = 0660 directory mask = 2770 EOF
sudo systemctl enable --now smb nmb
Contents