Difference between revisions of "Mount Network Shares"
(Add note about DAV) |
(reviewed, thanks des) |
||
Line 1: | Line 1: | ||
− | + | ==Automatically mount a network share on your SME server at boot== | |
− | + | {{Level|medium}} | |
− | + | ||
+ | === Assumptions=== | ||
− | |||
This Howto assumes: | This Howto assumes: | ||
* You will be mouning your shares into the '''info''' ibay | * You will be mouning your shares into the '''info''' ibay | ||
Line 13: | Line 13: | ||
** password: '''theplumber''' | ** password: '''theplumber''' | ||
− | == Create the local mount points == | + | === Create the local mount points === |
First create the directories that will be used to host the mounted data. These directories should remain empty at all times. | First create the directories that will be used to host the mounted data. These directories should remain empty at all times. | ||
Line 20: | Line 20: | ||
mkdir share2 | mkdir share2 | ||
− | == Create a password file == | + | === Create a password file === |
In order for your SME server to mount a network share, it needs to know a valid username and password on the intended network server. | In order for your SME server to mount a network share, it needs to know a valid username and password on the intended network server. | ||
Line 32: | Line 32: | ||
chmod 400 /root/.passwd/nas01 | chmod 400 /root/.passwd/nas01 | ||
− | == Modify the SME '''local''' event == | + | === Modify the SME '''local''' event === |
You can schedule a program to run whenever your system boots by adding it to the e-smith '''local''' event. This event is executed by SME after all other boot processes have run, so the network, USB subsystem, etc should all be initialized and available. | You can schedule a program to run whenever your system boots by adding it to the e-smith '''local''' event. This event is executed by SME after all other boot processes have run, so the network, USB subsystem, etc should all be initialized and available. | ||
Line 44: | Line 44: | ||
chmod 755 S95netshares | chmod 755 S95netshares | ||
− | == Mounting == | + | === Mounting === |
You can test your new mount script by running it: | You can test your new mount script by running it: | ||
/etc/e-smith/events/local/S95netshare | /etc/e-smith/events/local/S95netshare | ||
Line 53: | Line 53: | ||
Or by rebooting | Or by rebooting | ||
− | == Un-Mounting == | + | === Un-Mounting === |
You can un-mount your network shares using | You can un-mount your network shares using | ||
/etc/rc.d/init.d/netfs stop | /etc/rc.d/init.d/netfs stop | ||
Line 59: | Line 59: | ||
Or by shutting down or rebooting | Or by shutting down or rebooting | ||
− | == Testing == | + | === Testing === |
If all goes well, you should now be able to verify that your new script works as expected using one of these commands: | If all goes well, you should now be able to verify that your new script works as expected using one of these commands: | ||
{| border="1" cellpadding="5" cellspacing="0" | {| border="1" cellpadding="5" cellspacing="0" | ||
Line 73: | Line 73: | ||
|} | |} | ||
− | == Accessing your Data == | + | === Accessing your Data === |
Finally, you should be able to access your data in any of the following ways: | Finally, you should be able to access your data in any of the following ways: | ||
Line 91: | Line 91: | ||
|} | |} | ||
− | == Notes and Warnings == | + | === Notes and Warnings === |
# The method described gives access to //nas01/share1 and //nas02/share2 using the username and password placed into /root/.passwd/nas01. Once successfully mounted, this means that anyone who can browse to the '''info''' ibay will be able to access your data. Make sure this is what you want! | # The method described gives access to //nas01/share1 and //nas02/share2 using the username and password placed into /root/.passwd/nas01. Once successfully mounted, this means that anyone who can browse to the '''info''' ibay will be able to access your data. Make sure this is what you want! | ||
# If you don't include <tt>/etc/rc.d/init.d/netfs start</tt> in your script (S95netshares), your system will lock up every time you shutdown. This is a bug in CentOS (and hence will not be addressed by the SME developers). See [http://bugs.contribs.org/show_bug.cgi?id=4086 Bug 4086] for more information. | # If you don't include <tt>/etc/rc.d/init.d/netfs start</tt> in your script (S95netshares), your system will lock up every time you shutdown. This is a bug in CentOS (and hence will not be addressed by the SME developers). See [http://bugs.contribs.org/show_bug.cgi?id=4086 Bug 4086] for more information. | ||
# Combined with [[DAV]] or [[DAV_Enabled_Ibays]] this procedure would allow remote read-write access using [http://www.webdav.org/ WebDAV] to network shares on internal servers behind your SME server. | # Combined with [[DAV]] or [[DAV_Enabled_Ibays]] this procedure would allow remote read-write access using [http://www.webdav.org/ WebDAV] to network shares on internal servers behind your SME server. | ||
[[Category:Howto]] | [[Category:Howto]] |
Revision as of 11:27, 2 November 2008
Assumptions
This Howto assumes:
- You will be mouning your shares into the info ibay
- You will be using cifs (smbfs or nfs should be similar)
- Your cifs server is named nas01
- You want to access two shares on nas01: share1 and share2
- You can successfully open \\nas01\share1 and \\nas01\share2 from windows using
- username: joe
- password: theplumber
Create the local mount points
First create the directories that will be used to host the mounted data. These directories should remain empty at all times.
cd /home/e-smith/files/ibays/info/html mkdir share1 mkdir share2
Create a password file
In order for your SME server to mount a network share, it needs to know a valid username and password on the intended network server.
The most secure way to allow your SME server to login to a Windows (or other network) server is to place the required username and password information into a file on the disk, then set the permissions on that file so no one can read it who should not be able to.
I prefer to keep all such files in a folder under /root, as shown here:
mkdir /root/.passwd echo "username=joe password=theplumber " > /root/.passwd/nas01 chmod 400 /root/.passwd/nas01
Modify the SME local event
You can schedule a program to run whenever your system boots by adding it to the e-smith local event. This event is executed by SME after all other boot processes have run, so the network, USB subsystem, etc should all be initialized and available.
The following commands will add a command to the local event that will mount a network share:
cd /etc/e-smith/events/local echo "#! /bin/sh /etc/rc.d/init.d/netfs start mount -t cifs -o _netdev,credentials=/root/.passwd/nas01 //nas01/share1 /home/e-smith/files/ibays/info/html/share1 mount -t cifs -o _netdev,credentials=/root/.passwd/nas01 //nas01/share2 /home/e-smith/files/ibays/info/html/share2 " > S95netshares chmod 755 S95netshares
Mounting
You can test your new mount script by running it:
/etc/e-smith/events/local/S95netshare
Or by executing the SME local event:
signal-event local
Or by rebooting
Un-Mounting
You can un-mount your network shares using
/etc/rc.d/init.d/netfs stop
Or by shutting down or rebooting
Testing
If all goes well, you should now be able to verify that your new script works as expected using one of these commands:
df -h | output should include lines beginning with //nas01/share1 and //nas01/share2 |
mount | output should include lines beginning with //nas01/share1 and //nas01/share2 |
/etc/rc.d/init.d/netfs status | Should return: Active CIFS mountpoints: /home/e-smith/files/ibays/info/html/share1 /home/e-smith/files/ibays/info/html/share2 |
Accessing your Data
Finally, you should be able to access your data in any of the following ways:
ls /home/e-smith/files/ibays/info/html/share1 | should show the contents of //nas01/share1 |
ls /home/e-smith/files/ibays/info/html/share2 | should show the contents of //nas01/share2 |
http://your-sme-server/info/share1 | should show the contents of //nas01/share1 |
http://your-sme-server/info/share2 | should show the contents of //nas01/share2 |
Notes and Warnings
- The method described gives access to //nas01/share1 and //nas02/share2 using the username and password placed into /root/.passwd/nas01. Once successfully mounted, this means that anyone who can browse to the info ibay will be able to access your data. Make sure this is what you want!
- If you don't include /etc/rc.d/init.d/netfs start in your script (S95netshares), your system will lock up every time you shutdown. This is a bug in CentOS (and hence will not be addressed by the SME developers). See Bug 4086 for more information.
- Combined with DAV or DAV_Enabled_Ibays this procedure would allow remote read-write access using WebDAV to network shares on internal servers behind your SME server.