Difference between revisions of "FUSE"

From OpenVZ Virtuozzo Containers Wiki
Jump to: navigation, search
(Added info on umounting sshfs)
(Container tuning)
 
(16 intermediate revisions by 9 users not shown)
Line 1: Line 1:
This page describes how to setup fuse inside VPS
+
This page describes how to setup FUSE (filesystem in userspace) inside a container.
  
== Introduction ==
 
 
[http://git.openvz.org/?p=linux-2.6.18-openvz;a=blob;h=a584f05403a412e778cf359e84d3690d5a22d1e4;hb=045f4a5fcb8c2625fe7505a8d9d4ebffd7e0d905;f=Documentation/filesystems/fuse.txt FUSE] is a filesystem in which data and metadata are provided by an ordinary userspace process. The filesystem can be accessed normally through the kernel interface.
 
[http://git.openvz.org/?p=linux-2.6.18-openvz;a=blob;h=a584f05403a412e778cf359e84d3690d5a22d1e4;hb=045f4a5fcb8c2625fe7505a8d9d4ebffd7e0d905;f=Documentation/filesystems/fuse.txt FUSE] is a filesystem in which data and metadata are provided by an ordinary userspace process. The filesystem can be accessed normally through the kernel interface.
  
Line 14: Line 13:
 
== Setup ==
 
== Setup ==
 
=== Kernel ===
 
=== Kernel ===
Download appropriate kernel from [http://download.openvz.org openvz.org] or compile kernel with <code>CONFIG_FUSE_FS</code> option set
+
* Download appropriate kernel from [http://download.openvz.org/ openvz.org] or compile kernel with <code>CONFIG_FUSE_FS</code> option set
 +
* Debian/Ubuntu: You can alternatively add the line <code>fuse</code> into /etc/modules, and apply immediately with the command: <pre>modprobe --first-time fuse</pre>
  
=== Libfuse ===
+
=== Userspace ===
Compile libfuse in VPS without kernel module
+
 
 +
You have to fuse libraries and some fuse filesystem modules (here we use sshfs as an example).
 +
 
 +
The best way to have it installed is to use the packages from your distro vendor. An alternative is compiling the stuff from source.
 +
 
 +
==== Gentoo ====
 +
 
 +
# emerge sys-fs/sshfs-fuse
 +
 
 +
==== Fedora ====
 +
 
 +
# yum install fuse-sshfs
 +
 
 +
==== Debian/Ubuntu ====
 +
===== Debian 5.0 (lenny) =====
 +
FUSE cannot be installed due to udev/hotplug dependency (explained in [http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=503953 bug report 503953])
 +
 
 +
===== Ubuntu, Debian 6.0 (squeeze), Debian 4.0 (etch) and older =====
 +
# apt-get install sshfs
 +
 
 +
(Debian 4.0 note: see [[Installing udev in VE based on Debian-4.0]])
 +
 
 +
==== Compiling from source ====
 +
If there are no packages provided for you distribution, you have to compile from source.
 +
 
 +
First, compile libfuse in a container without kernel module
 
<pre>
 
<pre>
 
# vzctl enter 100
 
# vzctl enter 100
Line 29: Line 54:
 
</pre>
 
</pre>
  
{{note| Sometimes <code>libfuse.so.X</code> is unseen by your programs. Usually this file is installed in <code>/usr/local/lib</code> directory so don't forget to add it into your <code>/etc/ld.so.conf</code>}}
+
{{note|Sometimes <code>libfuse.so.X</code> is unseen by your programs. Usually this file is installed in <code>/usr/local/lib</code> directory so don't forget to add this directory into your <code>/etc/ld.so.conf</code> and then run <code>ldconfig</code>.}}
  
=== Filesystem ===
+
Next, download and compile filesystem.
Download and compile filesystem.
 
 
<pre>
 
<pre>
 
# vzctl enter 100
 
# vzctl enter 100
Line 44: Line 68:
 
</pre>
 
</pre>
  
=== VPS tuning ===
+
=== Container tuning ===
You need to make a characted device named <code>/dev/fuse</code> and grant your VPS permissions to it
+
You need to make a character device named <code>/dev/fuse</code> and grant your container permissions to it
 
<pre>
 
<pre>
 
# vzctl set 100 --devices c:10:229:rw --save
 
# vzctl set 100 --devices c:10:229:rw --save
Line 52: Line 76:
 
...
 
...
 
</pre>
 
</pre>
 +
 +
Or more simply:
 +
<pre>
 +
# vzctl set 103 --devnodes fuse:rw --save
 +
...
 +
</pre>
 +
 +
Note that restart (or moving to root container device cgroup before mounting) might be required.
  
 
=== Mounting filesystem ===
 
=== Mounting filesystem ===
After this you may try to mount FUSE in VPS
+
After this you may try to mount FUSE in a container.
 
<pre>
 
<pre>
 
# vzctl enter 100
 
# vzctl enter 100
# sshfs root@foo.org:/root /mnt/foo.org.root
+
# sshfs <nowiki>root@foo.org</nowiki>:/root /mnt/foo.org.root
 
</pre>
 
</pre>
  
 
==== Unmounting filesystem ====
 
==== Unmounting filesystem ====
In case of <code>sshfs</code> after umounting an appropriate daemon must be killed. This may be done by the following command
+
In case of <code>sshfs</code> after umounting an appropriate daemon must be killed. This may be done by the following command:
 
<pre>
 
<pre>
# fusermount -u moutpoint
+
# fusermount -u mountpoint
 
</pre>
 
</pre>
  
 
== Using fusectl filesystem ==
 
== Using fusectl filesystem ==
Fusectl is a helper filesystem for FUSE. You may mount it in VPS as well
+
Fusectl is a helper filesystem for FUSE. You may mount it in a container as well.
 
<pre>
 
<pre>
 
# vzctl enter 100
 
# vzctl enter 100
Line 73: Line 105:
 
</pre>
 
</pre>
  
[[category:HOWTO]]
+
== External links ==
 +
 
 +
* [http://fuse.sourceforge.net/ FUSE site]
 +
 
 +
[[Category:HOWTO]]

Latest revision as of 16:28, 10 March 2022

This page describes how to setup FUSE (filesystem in userspace) inside a container.

FUSE is a filesystem in which data and metadata are provided by an ordinary userspace process. The filesystem can be accessed normally through the kernel interface.

Preparations[edit]

To use FUSE you need the following:

  1. OpenVZ kernel version 028test005 or higher
  2. Fuse lib
  3. Any FUSE-based filesystem

In the examples below sshfs is used.

Setup[edit]

Kernel[edit]

  • Download appropriate kernel from openvz.org or compile kernel with CONFIG_FUSE_FS option set
  • Debian/Ubuntu: You can alternatively add the line fuse into /etc/modules, and apply immediately with the command:
    modprobe --first-time fuse

Userspace[edit]

You have to fuse libraries and some fuse filesystem modules (here we use sshfs as an example).

The best way to have it installed is to use the packages from your distro vendor. An alternative is compiling the stuff from source.

Gentoo[edit]

# emerge sys-fs/sshfs-fuse

Fedora[edit]

# yum install fuse-sshfs

Debian/Ubuntu[edit]

Debian 5.0 (lenny)[edit]

FUSE cannot be installed due to udev/hotplug dependency (explained in bug report 503953)

Ubuntu, Debian 6.0 (squeeze), Debian 4.0 (etch) and older[edit]
# apt-get install sshfs

(Debian 4.0 note: see Installing udev in VE based on Debian-4.0)

Compiling from source[edit]

If there are no packages provided for you distribution, you have to compile from source.

First, compile libfuse in a container without kernel module

# vzctl enter 100
# tar xzf fuse-2.6.0.tar.gz
# cd fuse-2.6.0
# ./configure --disable-kernel-module
...
# make
...
# make install
Yellowpin.svg Note: Sometimes libfuse.so.X is unseen by your programs. Usually this file is installed in /usr/local/lib directory so don't forget to add this directory into your /etc/ld.so.conf and then run ldconfig.

Next, download and compile filesystem.

# vzctl enter 100
# tar xzf sshfs-fuse-1.7.tar.gz
# cd sshfs-fuse-1.7
# ./configure
...
# make
...
# make install

Container tuning[edit]

You need to make a character device named /dev/fuse and grant your container permissions to it

# vzctl set 100 --devices c:10:229:rw --save
...
# vzctl exec 100 mknod /dev/fuse c 10 229
...

Or more simply:

# vzctl set 103 --devnodes fuse:rw --save
...

Note that restart (or moving to root container device cgroup before mounting) might be required.

Mounting filesystem[edit]

After this you may try to mount FUSE in a container.

# vzctl enter 100
# sshfs root@foo.org:/root /mnt/foo.org.root

Unmounting filesystem[edit]

In case of sshfs after umounting an appropriate daemon must be killed. This may be done by the following command:

# fusermount -u mountpoint

Using fusectl filesystem[edit]

Fusectl is a helper filesystem for FUSE. You may mount it in a container as well.

# vzctl enter 100
# mount -t fusectl none /fuse_ctl

External links[edit]