Introduction
Introduction Statistics Contact Development Disclaimer Help
Title: Mount a folder on another folder
Author: Solène
Date: 22 May 2018
Tags: openbsd70 openbsd
Description:
This article will explain quickly how to bind a folder to access it
from another path. It can be useful to give access to a specific
folder from a chroot without moving or duplicating the data into the
chroot.
Real world example: "I want to be able to access my 100GB folder
/home/my_data/ from my httpd web server chrooted in /var/www/".
The trick on OpenBSD is to use NFS on localhost. It's pretty simple.
# rcctl enable portmap nfsd mountd
# echo "/home/my_data -network=127.0.0.1 -mask=255.255.255.255" >
/etc/exports
# rcctl start portmap nfsd mountd
The order is really important. You can check that the folder is
available through NFS with the following command:
$ showmount -e
Exports list on localhost:
/home/my_data 127.0.0.1
If you don't have any line after "Exports list on localhost:", you
should kill mountd with `pkill -9 mountd` and start mountd again. I
experienced it twice when starting all the daemons from the same
commands but I'm not able to reproduce it. By the way, **mountd** only
supports reload.
If you modify */etc/exports*, you only need to reload **mountd** using
`rcctl reload mountd`.
Once you have check that everything was alright, you can mount the
exported folder on another folder with the command:
# mount localhost:/home/my_data /var/www/htdocs/my_data
You can add `-ro` parameter in the */etc/exports* file on the export
line if you want it to be read-only where you mount it.
Note: On FreeBSD/DragonflyBSD, you can use `mount_nullfs /from /to`,
there is no need to setup a local NFS server. And on Linux you can use
`mount --bind /from /to` and some others ways that I won't cover here.
You are viewing proxied material from dataswamp.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.