Samba - Setting up the fileshare
- First things first, add
samba to your USE flags in /etc/make.conf . Then emerge samba .
- Now copy the example configuration to the live configuration
file using:
cd /etc/samba/
gunzip smb.conf.example.gz
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
never .
- Under
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 yes .
- Now to edit the share definitions. Under
[homes] , change the code to take the following form:
[<share_folder_name_in_path_below>]
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: smbpasswd -a
<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
/etc/nsswitch.conf to:
hosts: files dns wins
so that NetBIOS can easily find Windows systems.
- Samba should now be ready to start, so type:
/etc/init.d/samba start .
- 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!
Troubleshooting:
- 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 users
and the directory should be readable/writable/executable by this group. Also, all the parent directories up the tree also need these
access rights.
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.
emerge proftpd .
- Copy the configuration file
/etc/proftpd/proftpd.conf.sample to /etc/proftpd/proftpd.conf .
- Login using your normal mythtv username and password!
|