Samba - Setting up the fileshare
- First things first, add
samba to your USE flags in
- Now copy the example configuration to the live configuration
cp smb.conf.example smb.conf
We can now edit this
smb.conf file to suit our needs.
- Change the workgroup name to your workgroup name previously specified, and change map to guest to the value
hosts allow, you should add the IP addressees of any clients on your network, the box's own IP, and the loopback IP of the box
(with only the first octal, i.e.
127. only). This will allow only these IP addresses access to the samba shares. For added security, add
hosts deny = 0.0.0.0/0.
- Ensure that
encrypt passwords is set to
- Now to edit the share definitions. Under
[homes], change the code to take the following form:
comment = Home Directories
path = <path_to_share>
valid users = <user1> <user2>
browseable = yes
writeable = yes
public = no
- Finally, comment out any references to printer sharing (we won't be using this on the box).
- Now in order to be able to add a samba user so that they can have access to the shares on the box, they must first have a user account on the box
itself. So do
useradd -G users -s /bin/false -p <new_password> <username>. This should be done for all of the users which will
be connected via samba.
- Next we need to add samba accounts using
smbpasswd. First ensure that the following directory exists:
/etc/samba/private/. Now execute the following command for each user in the system:
<username>. You will then be prompted for a password. Make sure that the usernames for samba and the box itself match, otherwise this
operation will fail.
- According to the gentoo samba how to, it is worth changing the hosts line in
hosts: files dns wins
so that NetBIOS can easily find Windows systems.
- Samba should now be ready to start, so type:
- To test if we can get a connection to the file store,
emerge samba on the client and run
smbclient //<box_machine_name>/<share_folder_name> -U <username>. Use this just like an ftp connection,
and try to download and upload files to test that it works.
- Now we can make the samba share accessible as a network folder using mount. However, we first need to ensure that the kernel supports
the samba filesystem, so check and recompile your kernel as necessary with the following option selected:
File systems -->
Network File Systems -->
SMB file system support (to mount Windows shares etc.)
- Boot with this new kernel (if necessary) and create the directory
/mnt/mythbox/. Then use the following to mount the samba share:
mount -t smbfs -o username=<username>,password=<password> //<hostname>/<share_folder_name> /mnt/mythbox/
- Make samba start upon boot using:
rc-update add samba default.
- Job done!
- I get messages in the log file saying that samba cannot change to the shared directory, or that the shared directory doesn't exist!
Ensure that the directory that you want to share has the permissions set correctly. The directory should belong to the group
and the directory should be readable/writable/executable by this group. Also, all the parent directories up the tree also need these
Alternatively - setting up an FTP daemon
After using samba, I have found that it can be a little flakey when transfering
large files over. Hence, you may choose to use samba for streaming MP3's, while
opting for FTP to transfer video files. Here's how.
- Copy the configuration file
- Login using your normal mythtv username and password!