Sharing files on the home network

Now that I have a newer desktop, with plenty of free disk space, I have setup file sharing for the home network.  My opensuse desktop is the server, with both Windows and linux clients.

I am using a separate disk partition for sharing.  It is mounted as “/shared”.  I am encrypting that partition (LUKS encryption).  Of course, that might sound silly; why encrypt what I am sharing on the home network?  Mainly, this is because hard disks eventually fail.  And if the disk is encrypted, somebody scavenging the dump for old disks won’t be able to recover useful data.  I do expect to sometimes backup systems over the network, so there could be private data on the shared disk.

The plan is to use samba for sharing with Windows clients, and to use NFS for sharing with linux clients.  At present, I have little on the shared disk – mostly music ripped from a few CDs that we own.  I also found it useful to put the Windows installer for firefox 15 there.  That way, I only downloaded it once, and could install on several Windows systems.  I have made a couple of shared directories writable by all users, so that backups over the network can go there.

Hostname considerations

I gave an artificial name “homebase” to the server.  That’s not the real server name, but it is what I am putting in “/etc/hosts” on the linux boxes.

192.168.x.y homebase

The Windows boxes will know the system by its real name, though I could configure “homebase” for the name there, too.  Perhaps I’ll change that at some time.

There’s actually a reason for using an artificial name.  I already have an entry in “/etc/hosts” for the real hostname of my server.  However, on my laptop, I am using my public IP address in that entry.  As it happens, my router does support loopback, so accessing the public IP from within the private network does work.  I have the router forward SSH connections to the server (my desktop system).  By using the public IP in “/etc/hosts”, I can also connect into my server while traveling.  However, I do not want to port-forward NFS connections.  So I need the private IP to use NFS from my laptop.  To avoid confusion, I must give it a different name.

Setting up the samba server

I used Yast to configure the samba server.  It adjusted the firewall to allow access, and configured “/etc/samba/smb.conf”.  It also setup the “nmbd” and “smbd” daemons to automatically start on reboot.  I later manually edited that “smb.conf” file for a little minor tweaking.

The setup went smoothly enough, except that the Windows boxes could not see it.  It turned out that whenever I use Yast to modify the configuration, it would stop both the “nmbd” and “smbd” daemons, and then restart only “smbd”.  I had to manually restart “nmbd” before the windows boxes could see the shares.  I suppose that’s a bug that I should report.  I am running 12.2 RC2 at present, so I will recheck that when I go to the final release of 12.2.  This is only a problem on updating the configuration with Yast, something that I will rarely do.

Setting up the NFS server

I did have to install the NFS server software before proceeding.  I had actually installed “nfs-kernel-server” on the initial system install from the DVD image.  I had to add “yast-nfs-server” before I could setup NFS sharing.

Again, I used Yast to setup the NFS sharing.  This seemed quite straightforward.  There was an option for including “nfsv4” support.  I did not choose that option, though perhaps I should.  I expect relatively light use of the shared files system and it will be restricted to the home private network, so it didn’t seem important to go with nfsv4.

Setting up samba clients

The samba clients are all Windows boxes (XP, Vista, Windows 7).  I have those setup for simple file sharing (instead of with a homegroup).  So the clients worked out of the box, once I made sure that “nmbd” was running on the server.

Setting up nfs clients

I used Yast to setup the NFS client on the first system that I configured (my previous desktop, now relegated to use as a backup system in case the main box fails).  That seemed easy enough to do, and I could see the shared files as soon as I had completed the configuration.  However, it setup file sharing by adding an nfs mount entry in “/etc/fstab”.  I did not think that the best approach.  So, I erased that line, and setup automount.

In the file “/etc/auto.master” I added a line:

/nfsmounts      /etc/auto.nfs

I put that line almost at the end, just before the “+auto.master” line.  And then I created a new file “/etc/auto.nfs” containing the one line:

shared  -fstype=nfs homebase:/shared

Finally, I ran the commands:

cd /
ln -s nfsmounts/shared .
/etc/init.d/autofs restart

and that seemed do the job nicely.  The entries in “auto.master” and “auto.nfs” will cause the shared file system to be mounted as “/nfsmounts/shared”.  The “ln -s” command creates a symbolic link so that I can see the mounted system at “/shared”.  And the restart option to the “init.d” command causes the automounter to reread its configuration after I had edited those files.

All seems to be working well.

For my other NFS clients, I simply edited the “auto.master” and “auto.nfs” files, and created the symbolic link.  Then I went into Yast for the runlevel service settings.  There I configured it to start “nfs” and “autofs”.  A prompt told me that it would also start “rpcbind”.  And those changes were sufficient for the other clients.

Why I use automount

There are two reasons that I prefer the automounter.  Firstly, the nfs mounting won’t interfere with booting, even if the server is down.  And secondly, when I am travelling with my laptop, the nfs server will be inaccessible.  As long as I do not try to access the shares, that should not cause any problems.

Advertisements

Tags: , ,

About Neil Rickert

Retired mathematician and computer scientist who dabbles in cognitive science.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: