Imagine the following situation: you have to compile some Linux/Unix application or kernel module that requires kernel source present at your hard drive, say, in /usr/src/kernels/kernel-2.6.21-i386/ or elsewhere. But there is not enough disk space to copy these sources or install kernel-devel or linux-source packages (in Fedora/RedHat or Ubuntu/Debian distros respectively)… Sounds familiar? Believe me, sometimes it happens 🙂
As a solution you can mount the directory of some remote PC that contains needed kernel source. It can be done via several protocols like smb, ftp etc. In this article we will mount remote directory using ssh protocol that is one the most popular for remote and secure access to Linux boxes over the network.
Below are the steps which should be taken to get the ball rolling. We need two packages: sshfs and fuse-utils.
1. Install necessary packages:
sudo aptitude install fuse-utils sshfs
yum install fuse-sshfs fuse fuse-libs
c. Other Linux: download and compile sshfs/fuse from sources
2. Check that kernel module
fuse is loaded:
lsmod | grep fuse
There should be the line containing “fuse” in the output (of not try
3. Mount remote filesystem using something like this (two commands):
mkdir -p /mnt/sshfs/
sshfs remote-user@remote-machine:/some/directory /mnt/sshfs
where remote-user is the username allowed to login remote-machine via ssh protocol. It will ask you to type the password so just type it and press return 🙂
4. That’s it. Good luck!