Friday, October 26, 2007

Samba and SSHFS


Sharing remote file system via Samba
In given article reviewed example installation and configuration "Fuse" for sharing via Samba file system of other server.

From the beginning I use Samba as a gateway to export NFS volumes of other server to Windows clients.
I am using FreeBSD as NFS server and another Linux box (Debian) to mount the remote NFS volume locally, and this box also runs Samba3, export the local directory (on which the NFS volume is mounted) as CIFS shares.
My problem is that when using smbclient to access the CIFS share, I can get a directory listing, but after connecting I received “Error in dskattr: code 0” . If access from Windows clients, it takes a long time to display the directory contents, and then the Explorer window will keep hanging.
I've found other solution instead of NFS. What if I connected to the remote machines via SSHFS on FreeBSD machine and then shared the mounted directories via Samba on Linux machine ??
...So, We going to install SSHFS on Linux box (Debian in my case).
apt-get install sshfs
If You need mount directory as a regular user, you need to be added to the "fuse" group, which the package created:
adduser your-username fuse
Create a file at /etc/fuse.conf
touch /etc/fuse.conf
Put the following line in /etc/fuse.conf:
echo “user_allow_other” > /etc/fuse.conf
now I try to mount remote file system
sshfs root@192.168.0.1:/remotefolder /data/localfolder
and then receive ......failure:
fuse device not found, try 'modprobe fuse' first FATAL: Module fuse not found.
I found that needed to create a module for the kernel “fuse” . for installing fuse-source add following source to your Apt source.list:
deb http://ftp.de.debian.org/debian lenny main
apt-get update
apt--get install fuse-source
apt-get install dpatch ### Dependences
apt-get install module-assistant ### Dependences
apt-get install kernel-headers-`uname -r` ### Dependences
apt-get install kernel-source-`uname -r` ### Dependences
module-assistant build fuse #### Build module from source
m-a install fuse-source #### Installing module
Before loading the fuse kernel module, create the device node manually:
mknod -m 666 /dev/fuse c 10 229
modprobe fuse #### Loading the fuse kernel module
At this point You can rerun mounting : sshfs root@192.168.0.1:/remotefolder /data/localfolder