Monday, January 18, 2010

Share files in a local network with NFS on Linux

Here's a really easy way to share folders and files between two Linux computers on a local network from mybeNi. (I've done it with Ubuntu and Debian.) It doesn't require the skills of a network administrator to implement, and uses NFS, which seems to be fast and reliable.
Here are the steps to go through- details are at the link above.

On the first computer:
Install NFS (either using Synaptic or the command line).
Edit an NFS configuration file to tell NFS which folder to share, which computer to share it with, and specify options.
Restart the NFS server.
On the second computer:
Install NFS.
Make a directory to contain the shared directory from the first computer.
Mount the directory.
Edit an NFS configuration file to mount the directory automatically if required.
Folder locations in the tutorial change be changed. For example, I shared...
/home/username/Shared
...on the first computer and created...
/home/username/Shared
...on the second.

Be carefully with typing the locations because case and spelling mistakes will mean the share won't work

For me, the tutorial didn't work at first. Then I noticed a comment which provided the answer. As described in later comments, I added lines to the /etc/hosts file on my computers to tell them the IP address of the other computer.

To edit the file:
sudo gedit /etc/hosts
Add:
'IP address' 'computer name', for example:
192.168.2.2 compaq
(To find the name of each computer, type the following in a terminal:
hostname)
Thanks to Beni for the tutorial.

Update: the original tutorial has gone, but I found a condensed version of it here:

==NFS shares
Condensed frm http://mybeni.rootzilla.de/mybeNi/2007/how_to_set_up_nfs_and_how_to_share_files_in_a_local_network_with_ubuntu_linux

====Share /media/music from 'ERNIE':
$ sudo apt-get install nfs-kernel-server

Add a line to /etc/exports:
$ ECHO "/media/music BERT(ro,async,all_squash)" >> /etc/exports

Restart the NFS Server
$ sudo /etc/init.d/nfs-kernel-server restart

====Connect and mount from 'BERT'
$ sudo apt-get install nfs-common
$ mkdir /var/music
$ sudo mount ernie:/media/music /var/music

To automount at start, add a line to /etc/fstab
$ ECHO "ernie:/media/music  /var/music     nfs r,hard   0  0" >> /etc/fstab

May have to add a line to /etc/hosts.allow

1. The server rejected the requests. What I did was I opened ports: 111, 2049, 32771 (from client and server, but not from router). This wasn't enough. I had to tell the servers firestarter to allow connections from my clients ip (in the lan).
2. Then I ran in to a new problem, but at least the server responded:
mount.nfs: access denied by server while mounting timo-desktop:/media/musiikki
Then I realized that for some reason I had to add the clients ip in to the file /etc/hosts
Like this
192.168.1.51 timo-laptop
after doing that and then I ran on the server:
sudo exportfs -ra
sudo /etc/init.d/portmap/ restart
sudo /etc/init.d/nfs-kernel-server restart

Folder sharing woes, and ultimate success!

Have you ever had a computer problem you've grappled with for days, experienced frustration and despair, and finally found an answer so simple it left you asking "Was that all there was to it?"
Well here is such a tale.
First some history. Sharing a folder between computers is supposed to be easy in Ubuntu, according to the Ubuntu documentation. At the time I tried it (probably around 8.04) there were two options for sharing folders with a right-click- Samba and NFS. Neither worked for me with the simple right-click option alone.
I had some success following this YouTube guide to Samba, which allows file sharing between Windows and Linux computers- and also between Linux computers. (The guide is for Ubuntu 6.10, but still seems relevant to current versions.) Accessing shared folders over the network was problematic, but using the IP address of the computer worked pretty well.
(The NFS option does not appear when attempting to share folders in Ubuntu 9.10 -Which makes me think it never worked as a right-click option without further configuration. It's interesting to note that the Samba guide considers Samba unnecessary for sharing folders between two Linux computers.)
After replacing an Ubuntu installation with Debian on my old computer recently, I tried to access the shared folder on my newer computer again- without any success. I looked at a lot of guides to Samba on the internet, and a lot of forum pages describing similar problems. This is where the frustration and despair mentioned above came in. (If I could have understood the guides and forum pages I looked at, I'm sure I'd be qualified as a network administrator.)
Eventually I found a partial answer. I'd been experimenting with a firewall (GUFW) and it had been blocking Samba. Removing the firewall (I'm behind a hardware firewall anyway) got me back to the previous situation- I could access the shared folder, but only by using the IP address of the computer, not the computer name. In frustration I uninstalled Samba and decided to have a go at using NFS- since it is recommended for sharing between two Linux computers.
I found a guide that seemed reasonably simple to follow, and had a go. Result? Failure. More frustration! But then I tried something mentioned in one of the comments. Suddenly it worked! I could see shared folders instantly and access files in a flash!
This was indeed the "Was that all there was to it?" I alluded to previously.
The thing that worked for me was to tell my computer the IP address of the computer I wanted to connect to. Which makes me think that my router is not good at matching a computer name to an IP address over the network. Which in turn makes me think that the reason I could get Samba to work (very well) may have been the same problem with one computer obtaining the IP address of the other.
I'm tempted to go back and try the right-click, 'Share this folder' option in Ubuntu again and see if it works now, but for the moment I'm going to post the guide to installing NFS folder sharing, in the hope that somebody might find it useful.

Thursday, January 14, 2010

Debian Nautilus browser mode

A final Debian tweak. By default, Debian does not launch Nautilus in browser mode (No 'Up' button or Location bar, and clicking on a folder opens a new window rather than simply changing the location in the original window.)
I found the solution on franciscoalecrim.com.
Over the last few posts, it's been interesting to note some of the features Ubuntu comes with by default, or which are easily installed from Canonical repositories, that perhaps make it the more visually (and audibly) attractive and user-friendly distro, at least for home users.

Audio preview in Debian

Debian does not come with audio file preview enabled. This is the useful feature that plays an audio track while you hover over the file icon. A post on the Debian User Forums describes how to enable it. (As well as the packages mentioned, this feature also seems to require the sound daemon esound mentioned in the previous post, which mixes audio streams for playback on an audio device. )

System sounds in Debian

My new installation of Debian came with no system sounds- rather soulless for a modern operating system I thought. I'd expected some Japanese mystical pipe music to match the wonderful image to the left, but I was disappointed.
It's possible to enable Gnome sounds (after installing a sound daemon), but Gnome sounds are pretty naff. The Cleanus Gnome system sounds on debian-art I think suit the distro, and sound much nicer than the Gnome sounds. They use a wood kalimba and a metal xylophone, giving a percussive sound with a wood sustain- quite and discrete, as described.
Here's how to enable system sounds. Install the following and reboot.
esound
libesd-alsa0
gnome-audio
Go to System>Preferences>Sound>Sounds and enable software sound mixing and play system sounds. Another reboot may be necessary here. If the Gnome sounds are not to your taste, download a set of system sounds from debian-art, and follow the instructions to install. (Basically just drop them in the appropriate folder [/usr/share/sounds] with root privileges.)

Tuesday, January 12, 2010

Free as in Freedom or Free as in Beer?

I now have a stable operating system running only free software (free as in freedom) running on my old Compaq (see below). If it were a person, it's feet would be two inches off the ground.
But can I listen to MP3's, watch video clips on the BBC or YouTube or watch DVD's? That will require some non-free software (as in freedom, but still free as in beer). It will also leave the computer distinctly earth-bound and not in its previous extramundane state.
MP3's were easy. Just a case of installing libxine1-ffmpeg.
Flash required a bit more effort. I had to add a repository for lenny-backports ( "Be warned : The resulting system can't be considered plain "stable" anymore"). If, like me, you're wondering what backports are, the Debian Wiki has an explanation.
DVD's also required adding a repository- this time debian-multimedia. After installing libdvdcss, and inserting a DVD, Totem popped up and auto-played it, but only the first chapter- the copyright notice and introductory screen. I installed MPlayer but that had the same problem. A quick Google suggested that this is a common problem in Debian- the support for DVD menus isn't there (both Totem and MPlayer can display DVD menus in Ubuntu). One media player that can handle DVD menus in Debian is gxine. Information on installation is in the link above.
After adding the debian-multimedia repository and checking Update Manager, there was a warning about "new dependencies for some new applications or newer versions of existing dependencies" and an option for a "smart upgrade". (As described here.) I took the option for a smart upgrade and it seemed to work out all right, but still, what was all that about?
In short, enabling the proprietary/non-free/possibly illegal packages which a lot of people (including me) use without much thought is trickier on Debian than on Ubuntu. Even on Ubuntu, it can be daunting if you're using Linux for the first time, or don't have much computer experience. I can see why distros like Mint are popular.
My experience with Debian was made more difficult than it needed to be because there was no multimedia installation page provided by Debian to refer to- I had to get information from a lot of different pages, many of them blogs or Linux resources rather than Debian pages. It something that Debian seems to be working on, which is good to know.
The feet of all Linux users do not hover two inches above the ground through purity and holiness.

Bad Karma? (II)

(Or: Can't Install Debian?)
I wrote previously about some users of Karmic Koala Ubuntu having bad experiences. Well I have to admit I'm now one of them. My (old and rarely used) Compaq laptop had problems with the latest version. Notifications and some windows failed to appear, or rather appeared as a rather fetching digital Burberry effect.
I can't say I was surprised or even disappointed- the laptop is seven years old and getting a bit long in the tooth, even with a recent memory upgrade from 256 to 512MB.
I decided to try out a distro a bit further away from the bleeding edge. Debian is the distro Ubuntu is based on, but it's more conservative- going for stability rather than the latest advances. It also has a reputation of being hard to install. (Joke: Ubuntu is an ancient African word meaning 'can't install Debian'.)
I downloaded the Debian DVD (the laptop won't read CD's for some reason) and opted for the GUI install.
I have to say it was the smoothest and easiest OS install I've ever done. The only minor issue was a message about non-free firmware, which I made a note of and then ignored.
After a reboot, the computer was working well. (I Googled the non-free firmware message and found I needed a driver for my wireless dongle, which I could get by enabling the non-free repositories in Debian.)
The laptop is now running Debian 5 apparently without a hitch. Debian 5 resembles earlier versions of Ubuntu which worked well on the laptop- I think 7.10 was the original version installed. Or to be more accurate, Debian 5 is what previous versions of Ubuntu were based on, so the resemblance is no surprise.
Either way, Koala was bad Karma for the Compaq, and I''ll be playing around with Debian for a while.