Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
vms:freenas [2015/10/08 19:04] admin [Configure Auto-mounting of the SAMBA Shares] |
vms:freenas [2017/03/31 15:13] (current) admin ↷ Links adapted because of a move operation |
||
|---|---|---|---|
| Line 11: | Line 11: | ||
| ---- | ---- | ||
| - | ++++| | + | |
| ===== Shortcut ===== | ===== Shortcut ===== | ||
| ---- | ---- | ||
| - | OK, for the ones that do not want to take the deep dive into the gruesome details of building a FreeNAS development VM. Or if you simply don't have the time required to achieve the whole process, as it takes more than 3 hours to complete all described operations! Here is a download link to the .vdi file that is going to get build following the steps described in this article (you lucky ones!): | + | OK, for the ones that do not want to take the deep dive into the gruesome details of building a FreeNAS development VM. Or if you simply don't have the time required to achieve the whole process, as it takes more than 3 hours to complete all described operations! Here is a download link to the .vdi file that is going to get build following the steps described in this article +/- 663MB (you lucky ones!): |
| - | DOWNLOAD LINK (not yet available sorry) | + | Note that you'll probably have to create extra virtual drives for the VM to create a "virtual pool". |
| - | ++++ | + | |
| + | **{{:vms:freenas:freenas-dev-9.3.1.vdi|Download FreeNAS-Dev-9.3.1.vdi}}** | ||
| ---- | ---- | ||
| ===== Create a FreeBSD 9.3 Build Environment ===== | ===== Create a FreeBSD 9.3 Build Environment ===== | ||
| Line 437: | Line 438: | ||
| ++++ CLICK HERE TO READ| | ++++ CLICK HERE TO READ| | ||
| - | Since we won't be able to use shared folders with FreeBSD (as described in this wiki's [[vms:django#using_a_shared_folder_to_host_your_projects|Python/Django Development Environment section]]) we'll have to create a SAMBA shared folder to easily manage and edit FreeNAS GUI's files from our host system. | + | Since we won't be able to use shared folders with FreeBSD (as described in this wiki's [[vms:python:django#using_a_shared_folder_to_host_your_projects|Python/Django Development Environment section]]) we'll have to create a SAMBA shared folder to easily manage and edit FreeNAS GUI's files from our host system. |
| As the intention is to analyze, and maybe modify, some code in the FreeNAS GUI and/or api, our main target directory location is //**/usr/local/www/freenasUI**//. We'll first duplicate it's content to the host's HD, then make this duplicate directory a SAMBA shared folder that we'll access from the FreeNAS development VM. Finally this SAMBA share will be mounted, with adequate ownership and permissions, as the ///usr/local/www/freenasUI// directory inside the FreeNAS development VM. | As the intention is to analyze, and maybe modify, some code in the FreeNAS GUI and/or api, our main target directory location is //**/usr/local/www/freenasUI**//. We'll first duplicate it's content to the host's HD, then make this duplicate directory a SAMBA shared folder that we'll access from the FreeNAS development VM. Finally this SAMBA share will be mounted, with adequate ownership and permissions, as the ///usr/local/www/freenasUI// directory inside the FreeNAS development VM. | ||
| Line 492: | Line 493: | ||
| **YEP!**\\ | **YEP!**\\ | ||
| We are now listing our host's folders content inside our VM. We still need to configure some things before we get running though. | We are now listing our host's folders content inside our VM. We still need to configure some things before we get running though. | ||
| + | |||
| + | ---- | ||
| + | ==== Configure Auto-mounting of the SAMBA Shares ===== | ||
| + | |||
| + | What we want, ultimately, is to have our **fnui-UI** share mounted to //**/usr/local/www/freenasUI**//, with the correct permissions for the system to run. Also our **fnui-data/freenas-v1.db** should "replace" **/data/freenas-v1.db**... | ||
| + | |||
| + | === Inspect owners and permissions === | ||
| + | |||
| + | From the FreeNAS guest VM command line: | ||
| + | <code> | ||
| + | > ls -la /usr/local/www/ | grep freenasUI | ||
| + | drwxr-xr-x 26 www www 37 Aug 17 20:35 freenasUI/ | ||
| + | > id www | ||
| + | uid=80(www) gid=80(www) groups=80(www) | ||
| + | |||
| + | > ls -la /data/ | grep freenas | ||
| + | -rw-r----- 1 root operator 319488 Aug 21 03:43 freenas-v1.db | ||
| + | > id operator | ||
| + | uid=2(operator) gid=5(operator) groups=5(operator) | ||
| + | </code> | ||
| + | |||
| + | === Test mount options === | ||
| + | |||
| + | In the above mount test, one had to introduce a password to complete the mount_smbfs command (even if the password is blank).\\ | ||
| + | As we intend to have the smb shares automatically mounted, we need to store the password in **~/.nsmbrc** for our tests and in **/etc/nsmb.conf** for fstab. | ||
| + | |||
| + | Also, as we want the shared folder to be mounted with the correct permissions we'll add some options to the mount_smbfs command: | ||
| + | <code> | ||
| + | > nano ~/.nsmbrc | ||
| + | Write: | ||
| + | [SERVERNAME:USERNAME] | ||
| + | password=myPassword | ||
| + | |||
| + | > mount_smbfs -N -u 80 -g 80 -f 755 -d 755 -I 172.20.20.1 //FNGUEST@LMDE2-W150HR/fnui-UI /tmp/fnui | ||
| + | > ls -la /tmp/fnui | ||
| + | total 483 | ||
| + | drwxr-xr-x 1 www www 16384 Jan 1 1970 ./ | ||
| + | drwxrwxrwt 6 root wheel 360 Aug 21 16:51 ../ | ||
| + | -rw-r--r-- 1 www www 1365 Aug 17 23:29 __init__.py | ||
| + | -rw-r--r-- 1 www www 123 Aug 17 23:30 __init__.pyc | ||
| + | drwxr-xr-x 1 www www 16384 Aug 17 23:30 account/ | ||
| + | drwxr-xr-x 1 www www 16384 Aug 17 23:30 api/ | ||
| + | -rw-r--r-- 1 www www 28484 Aug 17 23:30 choices.py | ||
| + | -rw-r--r-- 1 www www 32839 Aug 17 23:29 choices.pyc | ||
| + | drwxr-xr-x 1 www www 16384 Aug 17 23:30 common/ | ||
| + | ... | ||
| + | > umount /tmp/fnui | ||
| + | </code> | ||
| + | |||
| + | <color grey>**Note:**</color>\\ | ||
| + | Both the hostname and the username need to be in **UPPERCASE**.\\ | ||
| + | The password **can be empty**.\\ | ||
| + | We now use the **-N** option for mount_smbfs to force password lookup in ~/.nsmbrc.\\ | ||
| + | We also use the **-u** (user-id), **-g** (group-id), **-f** (files permissions) and **-d** (directories permissions) options to get the correct ownership and rights on the mounted files.\\ | ||
| + | The uncommon **-f 755** usage comes from the fact that python files need execution rights. | ||
| + | |||
| + | === Automount using fstab === | ||
| + | |||
| + | Now that we are confident the mount process is working, let's automate it using **/etc/fstab**. | ||
| + | |||
| + | First, fstab will look for passwords in **/etc/nsmb.conf** so: | ||
| + | <code> | ||
| + | > nano /etc/nsmb.conf | ||
| + | |||
| + | Add at the end of file: | ||
| + | # VBox Shared Folders | ||
| + | [SERVERNAME:USERNAME] | ||
| + | password=thePassword | ||
| + | </code> | ||
| + | |||
| + | Next, our **fnui-UI** shared will be mounted at **/usr/local/www/freenasUI**, that is pretty straight forward.\\ | ||
| + | Regarding our **fnui-data** share, things are a little different, we need **only one file** (freenas-v1.db) "replaced" by our host located file. To achieve this, we'll create a specific mount point for fnui-data, then symlink the "original" file pointing to our mounted location. | ||
| + | |||
| + | Finally, the fstab syntax is slightly different from the command line, see how it is structured in the following code snippet: | ||
| + | <code> | ||
| + | > mkdir /mnt/shared-data | ||
| + | > nano /etc/fstab | ||
| + | |||
| + | Add at end of file: | ||
| + | # VBox smb shared folders | ||
| + | //FNGUEST@LMDE2-W150HR/fnui-UI /usr/local/www/freenasUI smbfs rw,-N,-u80,-g80,-f755,-d755,-I172.20.20.1 0 0 | ||
| + | //FNGUEST@LMDE2-W150HR/fnui-data /mnt/shared-data smbfs rw,-N,-u0,-g5,-f640,-d755,-I172.20.20.1 0 0 | ||
| + | |||
| + | > mount -a | ||
| + | </code> | ||
| + | |||
| + | At this point you should have your shared freenasUI files replacing the /usr/local/www/freenasUI directory and the freenas-v1.db in /mnt/shared-data. | ||
| + | |||
| + | Let's create the necessary symlink for the FreeNAS database and copy the local_settings.py file: | ||
| + | <code> | ||
| + | > mv /data/freenas-v1.db /data/freenas-v1.db.bak | ||
| + | > ln -s /mnt/shared-data/freenas-v1.db /data/freenas-v1.db | ||
| + | > cp /etc/local_settings.py /usr/local/www/freenasUI/ | ||
| + | </code> | ||
| + | |||
| + | Let's restart our VM to check everything goes as expected once we reboot the machine. | ||
| ---- | ---- | ||
| ++++ | ++++ | ||
| + | ---- | ||
| ===== IntelliJ IDEA Project Configuration ===== | ===== IntelliJ IDEA Project Configuration ===== | ||
| ---- | ---- | ||