Mount CIFS Share on Vera Edge?

[quote=“reneboer, post:19, topic:185496”]Hi Akbooer,

I actually just took your startup LUA to mount the cifs. Changed all instances of pass to password and works kile a charm on Edge and Lite with UI5.

Cheers Rene[/quote]

Hey Renebor, which LUA? Could you paste the link? Thanks.

That would be this code, then [url=http://forum.micasaverde.com/index.php/topic,25134.msg184164.html#msg184164]http://forum.micasaverde.com/index.php/topic,25134.msg184164.html#msg184164[/url]

…that’s the second piece of my code which works for others, but not for me on UI7 :-[

Hi Akboeer,

Yes that is what I used.

I think you are pushing the Edge over the … edge with all your advanced coding ;D

Cheers Rene.

[quote=“reneboer, post:23, topic:185496”]Hi Akboeer,

Yes that is what I used.

I think you are pushing the Edge over the … edge with all your advanced coding ;D

Cheers Rene.[/quote]

LOL, meaning the Edge needs a factory reset?

I don’t think I am doing any advanced coding and am running into the same issue…

I wonder if a wipe - get CIFS mount working - and then restore from backup would fix it.

It is annoying that it works for some and not for others.

Glad that someone else is sharing the pain, but sorry it had to be you.

Perhaps a call, first, to support to see if there’s anything that they might do? I haven’t resorted to that since I’m heavily using the Edge for development at this time.

Some more information about CIFS here.

I upgraded my VeraEdge to the today 1.7.1018. I had to reset the device to factory default before because tech support told me that the device did not have enough space (though I really though I had plenty).

Anyway, after factory reset and upgrade, kmod-fs-cifs package is of course gone. I tried to install the package back per previous steps I had (using --force-depends) and found out that neither “mount -t cifs” nor “mount.cifs” nor “cifsmount” works. Here are my updated steps:

1. opkg update
2. opkg --force-depends install kmod-fs-cifs
3. opkg --force-depends install kmod-nls-utf8 kmod-nls-base kmod-crypto-hmac kmod-crypto-md5 kmod-crypto-misc
4. reboot
5. opkg --force-depends --force-reinstall kmod-fs-cifs (Not sure if this step is really needed, I was troubleshooting)
6. reboot
7. mount //nasip/DataYours/ /dataYours -o user=username,pass=password (nounix and noserverino doesn't work for me)

Note that in step 7., nounix and noserverino would give me device/source busy error. Only when I mount with just user and password options worked for me.

In addition, lsmod showed me that cifs module was loaded:
cifs 188077 3
crypto_hash 9546 9 cifs

Hi,

I’ve had to setup cifs on a few veras the last couple days and have come up with a way of doing it from within veras web ui (no ssh, no scp required and takes less than 3 mins)

First of all in the Startup Lua box, Enter the following (not forgetting to change the first 4 variables as appropriate): [code]–code to mount cifs share every restart, originally by akbooer and modified/updated by samyoue

–edit the following 4 variables to suit your credentials/directories
local device = “//192.168.0.1/volume
local directory = “/nas”
local user = “admin”
local pass = “admin”

local function df ()
local info
local p = io.popen (“df”,‘r’)
if p then info = p:read “*a”; p:close () end
return info
end

function cifsmount (x)
local lfs = require “lfs”
lfs.mkdir (directory)
local function log (msg) luup.log ((“cifsmount: ‘%s’ %s”): format (x.device or ‘?’, msg)) end
local df = df ()
if df: find (x.device, 1, true) then
log “already mounted”
else
local cmd = (“mount -t cifs -o user=%s,pass=%s,sec=ntlm %s %s”): format (x.user, x.pass, x.device, x.directory)
local ok, term, status = os.execute (cmd)
log ("mounted status: "…tostring(status))
if ok
then log ("mounted OK: "…tostring(ok))
elseif x.retry then luup.call_delay (“cifsmount”, 60 * x.retry)
else log “failed to mount”
end
end
end

cifsmount {user=user, pass=pass, device=device, directory=directory}

local info=‘

’…df()…os.date(‘
Last update: %A, %c

’)
local wf = io.open(‘/www/df.html’,‘w’)
if wf then
wf:write (info)
wf:close ()
return true
end

–to test go to (veras ip address)/df.html (after restart)[/code] then in ‘Test Lua Code’, enter the following:[code]local function execute (command)
p = io.popen (command)
local out = p: read “*a”
p: close()
print (out)
print “-----------”
return out
end

execute “opkg update”
execute “opkg --force-depends install kmod-fs-cifs”
execute “opkg --force-depends install kmod-nls-utf8 kmod-nls-base kmod-crypto-hmac kmod-crypto-md5 kmod-crypto-misc”
[/code]
Give it couple of minutes (don’t trigger any restarts if possible) then go to your veras IP address /df.html (eg. 192.168.0.55/df.html) and hopefully you should get something similar to:
[font=courier]
Filesystem 1K-blocks Used Available Use% Mounted on
rootfs 8832 6112 2720 69% /
/dev/root 10240 10240 0 100% /rom
tmpfs 127744 272 127472 0% /tmp
/dev/mtdblock7 8832 6112 2720 69% /overlay
overlayfs:/overlay 8832 6112 2720 69% /
tmpfs 512 0 512 0% /dev
/dev/mtdblock10 51200 11924 39276 23% /storage
/dev/mtdblock10 51200 11924 39276 23% /etc/cmh-firmware
/dev/mtdblock10 51200 11924 39276 23% /etc/cmh-backup
/dev/mtdblock9 10240 10240 0 100% /mios
[glow=red,2,300]//192.168.0.1/volume 530144 10200 519944 2% /nas[/glow]

Last update: Thursday, Thu Aug 23 10:34:54 2018[/font]

Note the last line of the df file (not the update timestamp) shows your cifs share should have been mounted.

Big thanks to all the contributors on this forum (this thread and this thread in particular)

Hope this helps someone, :slight_smile:

Sam.

EDIT:- updated code with akbooers alterations (much smarter than me :wink: lol)

Good to read!

I’m a bit unsure about simply using delays to time the actions. You could perhaps use io.popen() to open a pipe and check results? Not sure.

Anyhow, in the cifsmount routine, instead of:

os.execute("mkdir "..directory)

it might be preferable to use:

local lfs = require "lfs"
lfs.mkdir (directory)

I do hate using os.execute when I don’t have to.

Anyway, good stuff!

I don’t like using os.execute either tbh but noticed your startup code has the same line to mount as you put in an ssh session so I simply expanded upon that - if there is a better way then great - I only started learning lua and vera last year lol. I’ve updated the code with your mkdir improvement, if anyone knows of better ways then please post (eg. The pipe solution to timers as I’ve no idea how they work lol)

Sam

I guess we all learn over time - that code was originally written a long time ago!

The pipe solution to timers as I've no idea how they work

I’ve just tried this and it works fine…

local p = io.popen "opkg update"
local out = p: read "*a"
p: close()

print(out)

results in this output:

Downloading http://download1204.mios.com/firmware/mt7620a/openwrt/ramips/packages/Packages.gz.
Updated list of available packages in /var/opkg-lists/snapshots.

The read function doesn’t return until the the process is finished, so need need for a delay.

Just tested the whole thing…

local function execute (command)
    p = io.popen (command)
    local out = p: read "*a"
    p: close()
    print (out)
    print "-----------"
    return out
end

execute "opkg update"
execute "opkg --force-depends install kmod-fs-cifs"
execute "opkg --force-depends install kmod-nls-utf8 kmod-nls-base kmod-crypto-hmac kmod-crypto-md5 kmod-crypto-misc"

gives (since I have run it previously)…

Downloading http://download1204.mios.com/firmware/mt7620a/openwrt/ramips/packages/Packages.gz.
Updated list of available packages in /var/opkg-lists/snapshots.

-----------
Package kmod-fs-cifs (3.10.34-2) installed in root is up to date.

-----------
Package kmod-nls-utf8 (3.10.34-2) installed in root is up to date.
Package kmod-nls-base (3.10.34-2) installed in root is up to date.
Package kmod-crypto-hmac (3.10.34-2) installed in root is up to date.
Package kmod-crypto-md5 (3.10.34-2) installed in root is up to date.
Package kmod-crypto-misc (3.10.34-2) installed in root is up to date.

-----------

updated earlier post,

thanks!

Hi @akbooer

This is great, can I just confirm, can I just run this chunk of code on my Vera UI7 and it should install all the required CIFs etc packages ?

[quote=“akbooer, post:32, topic:185496”]Just tested the whole thing…

[code]
local function execute (command)
p = io.popen (command)
local out = p: read “*a”
p: close()
print (out)
print “-----------”
return out
end

execute “opkg update”
execute “opkg --force-depends install kmod-fs-cifs”
execute “opkg --force-depends install kmod-nls-utf8 kmod-nls-base kmod-crypto-hmac kmod-crypto-md5 kmod-crypto-misc”
[/code][/quote]

Yes, allegedly.

I just refactored the code from @samyoue, albeit that it came from elsewhere in the first place.

Tried the following code in Vera Secure firmware v1.7.4002. The device was just recovered from a factory reset.
The device immediately froze and stopped responding to commands or ping. Restared it through the switch under the cover. But it never started again. Hardware reset did not work. The Powerled light is constantly lit and it does not take any IP from the router. Support said it was bricked, and no chance to recover it. They tried by remote control but did not succeed either.

No devices were paired yet and only basic configuration were made on it. Is there something in this code that really can make it completely stop responding to this way if the device is ok. ?

Do you have to install the cifs packages before running or trying the code? Unfortunately, I missed trying to manually mount the network device before this code was executed.

[quote=“samyoue, post:28, topic:185496”]Hi,

I’ve had to setup cifs on a few veras the last couple days and have come up with a way of doing it from within veras web ui (no ssh, no scp required and takes less than 3 mins)

First of all in the Startup Lua box, Enter the following (not forgetting to change the first 4 variables as appropriate): [code]–code to mount cifs share every restart, originally by akbooer and modified/updated by samyoue

–edit the following 4 variables to suit your credentials/directories
local device = “//192.168.0.1/volume
local directory = “/nas”
local user = “admin”
local pass = “admin”

local function df ()
local info
local p = io.popen (“df”,‘r’)
if p then info = p:read “*a”; p:close () end
return info
end

function cifsmount (x)
local lfs = require “lfs”
lfs.mkdir (directory)
local function log (msg) luup.log ((“cifsmount: ‘%s’ %s”): format (x.device or ‘?’, msg)) end
local df = df ()
if df: find (x.device, 1, true) then
log “already mounted”
else
local cmd = (“mount -t cifs -o user=%s,pass=%s,sec=ntlm %s %s”): format (x.user, x.pass, x.device, x.directory)
local ok, term, status = os.execute (cmd)
log ("mounted status: "…tostring(status))
if ok
then log ("mounted OK: "…tostring(ok))
elseif x.retry then luup.call_delay (“cifsmount”, 60 * x.retry)
else log “failed to mount”
end
end
end

cifsmount {user=user, pass=pass, device=device, directory=directory}

local info=‘

’…df()…os.date(‘
Last update: %A, %c

’)
local wf = io.open(‘/www/df.html’,‘w’)
if wf then
wf:write (info)
wf:close ()
return true
end

–to test go to (veras ip address)/df.html (after restart)[/code] then in ‘Test Lua Code’, enter the following:[code]local function execute (command)
p = io.popen (command)
local out = p: read “*a”
p: close()
print (out)
print “-----------”
return out
end

execute “opkg update”
execute “opkg --force-depends install kmod-fs-cifs”
execute “opkg --force-depends install kmod-nls-utf8 kmod-nls-base kmod-crypto-hmac kmod-crypto-md5 kmod-crypto-misc”
[/code]
Give it couple of minutes (don’t trigger any restarts if possible) then go to your veras IP address /df.html (eg. 192.168.0.55/df.html) and hopefully you should get something similar to:
[font=courier]
Filesystem 1K-blocks Used Available Use% Mounted on
rootfs 8832 6112 2720 69% /
/dev/root 10240 10240 0 100% /rom
tmpfs 127744 272 127472 0% /tmp
/dev/mtdblock7 8832 6112 2720 69% /overlay
overlayfs:/overlay 8832 6112 2720 69% /
tmpfs 512 0 512 0% /dev
/dev/mtdblock10 51200 11924 39276 23% /storage
/dev/mtdblock10 51200 11924 39276 23% /etc/cmh-firmware
/dev/mtdblock10 51200 11924 39276 23% /etc/cmh-backup
/dev/mtdblock9 10240 10240 0 100% /mios
[glow=red,2,300]//192.168.0.1/volume 530144 10200 519944 2% /nas[/glow]

Last update: Thursday, Thu Aug 23 10:34:54 2018[/font]

Note the last line of the df file (not the update timestamp) shows your cifs share should have been mounted.

Big thanks to all the contributors on this forum (this thread and this thread in particular)

Hope this helps someone, :slight_smile:

Sam.

EDIT:- updated code with akbooers alterations (much smarter than me :wink: lol)[/quote]

Hi, I’ve no idea on Vera Secure, it was working on Vera Edge and Vera Plus at time of writing.
I don’t believe there is anything that could brick it (I’ve used it on 10 veras so far with no issues…) I did however have a vera plus with the same issue you had although it was like that from factory, returned to supplier for replacement … You mentioned you had to do a factory restore before , maybe there was an existing underlying issue with your unit?

Sam

Help!

I tried to mount a shared folder on my windows 10 machine, using:

mount //[machine IP]/VeraLogs /VeraLogs -o user=***,pass=****

Answer:

mount: mounting //[machine IP]/VeraLogs on /VeraLogs failed: Host is down

I also tried to add the “,vers=x.x”, no help.

All packages are installed fine. Disabling firewall in win 10 didn’t help.

[quote=“Forzaalfa, post:38, topic:185496”]Help!

I tried to mount a shared folder on my windows 10 machine, using:

mount //[machine IP]/VeraLogs /VeraLogs -o user=***,pass=****

Answer:

mount: mounting //[machine IP]/VeraLogs on /VeraLogs failed: Host is down

I also tried to add the “,vers=x.x”, no help.

All packages are installed fine. Disabling firewall in win 10 didn’t help.[/quote]

Forzaalfa (GREAT name!) what happens when you run the command?

C

well, absolutely nothing, it just replies with the “host is down” sentence shown above. I tried all ways to write this command on web searches, nothing works!

Tried again now:

[code]root@MiOS_VERA:~# opkg --force-depends install kmod-nls-utf8 kmod-nls-base kmod-crypto-hmac kmod-crypto-md5 kmod-crypto-misc
Package kmod-nls-utf8 (3.10.14-p112871-1) installed in root is up to date.
Package kmod-nls-base (3.10.14-p112871-1) installed in root is up to date.
Package kmod-crypto-hmac (3.10.14-p112871-1) installed in root is up to date.
Package kmod-crypto-md5 (3.10.14-p112871-1) installed in root is up to date.
Package kmod-crypto-misc (3.10.14-p112871-1) installed in root is up to date.

root@MiOS_VERA:~# opkg --force-depends install kmod-fs-cifs
Package kmod-fs-cifs (3.10.14-p112871-1) installed in root is up to date.

root@MiOS_VERA:~# mount -t cifs -o username=,password= //[IP]/VeraLogs /VeraLogs
mount: mounting //[IP]/VeraLogs on /VeraLogs failed: Host is down
root@MiOS_VERA:~#
[/code]