mount linux directory

I've got 2 linux boxes and I like to transfer files between them.  They both have ftpd and httpd running and I use those sometimes to get a file from one to the other.  More often I use scp to copy files between boxes.

What I want to do now is share a folder on one PC and mount it on the other so I can access it as if it was local.  Is samba the only way to accomplish this task???  I thought that samba was used to create windows shares on a linux box, and/or connect to windows shares from a linux box.  But here there are no windows involved so I would like to use something else, something pure linux.

Who is Participating?
http:// thevpn.guruCommented:
You can use samba in both ways...another way to do it would be to use NFS shares.
brasslanAuthor Commented:
oh ya, I knew there was another way besides samba.  Do you know how to create the NFS share, and the syntax to mount it?  Or maybe have any links for some reading material for NFS?

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

agriesserConnect With a Mentor Commented:
If you're familiar with scp and like SSH, you can even use sshfs.
Usually, it's easy as 1-2-3 to setup, just install the package "sshfs" if it isn't already installed, and afterwards, run this command to mount any directory from the remote system.

sshfs ssh-user@ssh-server:/remote/directory /local/mount-point

The command above mounts the directory /remote/directory on ssh-server in your directory /local/mount-point, authentication with user "ssh-user" on the other server (ssh-server).

To unmount this directory again, use:

fusermount -u /local/mount-point
packetgodConnect With a Mentor Commented:
You can do SCP/SSHFS if you want to wait forever, it is great if you are working over untrusted links but it has to encrypt everything and decrypt it on the other side.  If you are talking larger amounts of data over a local link NFS is totally the way to go.

Steps to do it are fairly simple, first make sure it is installed on the system you are using (different methodologies for different boxes.

Then edit your /etc/exports file and add in a line like this:

So that would be the directory you want to share followed by an IP or range of IPs you want to access it followed by a parenthesis and RW or RO for read write or read only followed by a bunch of other junk.

Hope that helps.
Sorry, forgot one other step.  After you edit your /etc/exports file and write it I do a /etc/init.d/nfs-kernel-server restart

That may look different on your system depending on your flavor of linux.  Look for something in /etc/init.d that starts with NFS.
Michael WorshamInfrastructure / Solutions ArchitectCommented:
Another option would be to setup iSCSI on both boxes and have it point to a 'shared' iSCSI data volume.

Or if you want to get a bit more complicated, look at using GFS or OCFS2:
Setting up nfs is simple.

The system with the directory you want to share is the server.  Make sure that the nfs server is installed and started when your server system boots up.  Also make sure that any firewall on the server system allows NFS connections.

Create /etc/exports.  The simplest format is
  /path/to/shared/directory     *(rw)

This says to share the directory with everyone on the network as a read-write directory.

Restart nfs on the server, or enter "sudo exportfs -a".  

On the client, first, make sure that you can mount the directory.  Enter
  sudo server:/path/to/shared/directory /path/on/client

Naturally, replace the paths with the correct names and make sure that the mount point on the client exists. If this works, you should be able to cd to /path/on/client and see the shared directory. if there is a failure, check paths, firewall, etc.  

Add the following to the line to /etc/fstab on the client:
  server:/path/to/shared/directory  /path/on/client   nfs  defaults  0 0

There are many more options available in NFS, but this should get you going.  

Have you read the sshfs manpage or do you simply dislike SSHFS because of it's name?
There are several disadvantages of NFS over SSHFS and any other shared filesystems but that's not the topic in here. But it's simply untrue that SSHFS is slow.

You can enable compression (does NFS support compression on the fly?) and you can use a fast cipher instead of a very strong one so packets get compressed first and afterwards encrypted with a fast cipher which will definetly transfer the packet faster to the other end (and even on large files, it will be faster than using FTP or NFS in some instances).

Of course, NFS is a good solution for the author's question but SSHFS is also a good solution (especially if you consider that even the LAN in an office could be an untrusted network depending on the size of the company and the co-workers in there).

@ agriesser:

I actually think SSHFS is really very cool and have used it regularly, I just never thought to reduce the Cipher strength to make it faster.  It certainly does add significant flexibility over NFS and ease of use through firewalls.  Although compression only really helps with compressable file formats and adds to your processor load as now it is doing both compression/decompression and encryption/decryption, perhaps with newer processors it isn't really an issue but I can see some hits on my older machines.

Of course most of my uses of SSHFS have been over untrusted links so I don't think I'd actually want to use a weaker cipher but I tend to use NFS for local and SSHFS for remote   Certainly weak encryption over a local link will most likely be sufficient for your security and file sharing needs.
I didn't want to sound rude, I just wanted to clarify the reason why I suggested SSHFS, I hope you didn't get me wrong in this one.

After all, it's up to the author of this question to choose what file sharing mechanisms is the best to choose in his environment.
brasslanAuthor Commented:
Oops, I forgot to close this one out...

Thanks everyone for all of your help!!!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.