CIFS Mount External Share - Code for Lua start up.

I will give that a go, thanks!

[quote=“NotYetRated, post:27, topic:181206”]I also have the “df: /nas: Value too large for defined data type”. I am linking to my file server, something around 15TB now…

Any other options for this?[/quote]

Hi all, i got around the “value too large for defined data type” by simply deleting the nounix,noserverino comments in the akbooer script, after doing so I was able to mount the nas correctly and cleanly. Not exactly sure why it worked, maybe large file support is native now however just happy it works.

Hi

I’ve not checked my code for a while, but noticed when running ‘df’ my /nas mount is not appearing. Does anyone have any ideas? The share Backups is present on the NAS

-- @akbooer 2014-04-23
--

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 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,nounix,noserverino %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


local device = "//192.168.1.111/Backups"
local directory = "/nas"
local user = "user"
local pass = "password"


-- optional retry gives interval in minutes to retry failed mount attempt
cifsmount {user=user, pass=pass, device=device, directory=directory, retry=30} <0x30cf8680>

Log shows.

50 07/08/16 21:23:01.081 luup_log:0: cifsmount: '//192.168.1.111/Backups' mounted status: nil <0x30cf8680> 50 07/08/16 21:23:01.082 luup_log:0: cifsmount: '//192.168.1.111/Backups' mounted OK: 65280 <0x30cf8680>

But ‘df’ does not show it.

[font=Verdana][size=78%]root@MiOS_30102521:~# df[/size][/font]
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/root 4608 4608 0 100% /rom
tmpfs 63728 3028 60700 5% /tmp
tmpfs 512 0 512 0% /dev
/dev/mtdblock7 11264 3472 7792 31% /overlay
overlayfs:/overlay 11264 3472 7792 31% /
/dev/sda1 516024 24952 464856 5% /tmp/log/cmh
/dev/mtdblock8 4480 4480 0 100% /mios
root@MiOS_30102521:~#

Have you made any OS upgrades recently? I had to change the command line options I used in the CIFS mount a while ago. I’ll check what that was.

I’m no Unix expert, but would suggest that if df says it’s not mounted, then it’s not mounted.

[quote=“akbooer, post:44, topic:181206”]Have you made any OS upgrades recently? I had to change the command line options I used in the CIFS mount a while ago. I’ll check what that was.

I’m no Unix expert, but would suggest that if df says it’s not mounted, then it’s not mounted.[/quote]

Thanks @akbooer

Now that you mentioned it, my NAS has gone through a few firmware updates. The thing is I’d been focussed on my VeraPlus (and I only use this mount with my Vera 3) so have only just noticed it was not there…

I’ll be interested to see what your revised code is.

The target share to mount is //192.168.1.111/Backups

The command line is now:

mount -t cifs //192.168.1.111/Backups /nas -o user=XXX,pass=YYY,sec=ntlm

I found out somewhere that this works (for me, anyway.) Who knows why? It’s one of those Unix dark arts things.

You have to admire the ‘dark arts’ :slight_smile:

Thanks @akbooer, so that would make the code to be the following.

-- @akbooer 2014-04-23
--

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 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 //192.168.1.111/Backups /nas -o user=XXX,pass=YYY,sec=ntlm")
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

So change the line

local cmd = ("mount -t cifs -o user=%s,pass=%s,nounix,noserverino %s %s"): format (x.user, x.pass, x.device, x.directory)

to

local cmd = ("mount -t cifs -o user=%s,pass=%s,sec=ntlm %s %s"): format (x.user, x.pass, x.device, x.directory)

Ok, thanks - I gave this a try

[code]
@akbooer 2014-04-23

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 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

local device = “//192.168.1.111/Backups
local directory = “/nas”
local user = “user”
local pass = “password”

– optional retry gives interval in minutes to retry failed mount attempt
cifsmount {user=user, pass=pass, device=device, directory=directory, retry=30}[/code]

But sadly no joy with df, even thought it suggests it went ok in the log.

50 07/09/16 12:10:26.317 luup_log:0: cifsmount: '//192.168.1.111/Backups' mounted status: nil <0x30e6a680> 50 07/09/16 12:10:26.318 luup_log:0: cifsmount: '//192.168.1.111/Backups' mounted OK: 65280 <0x30e6a680>

Too bad. Suggest you get it working at the command line level first. It’s apparently not a Lua / Vera thing.

Yep, and it’s not playing nice - it seems I may have bigger issues to sort out ???

root@MiOS_30111521:~# mount -t cifs -o user=username,pass=password1,sec=ntlm //192.168.1.111/Backups /nas mount: mounting //192.168.1.111/Backups on /nas failed: No such device

I notice that I have a ‘/’ at the end of my device name for the mount, eg.

mount -t cifs /192.168.1.111/Backups/ /nas -o user=XXX,pass=YYY,sec=ntlm

does that, perchance, make any difference?

Sadly not - but good thought :slight_smile: - same error

mount: mounting //192.168.1.111/Backups/ on /nas failed: No such device

[quote=“parkerc, post:53, topic:181206”]Sadly not - but good thought :slight_smile: - same error

mount: mounting //192.168.1.111/Backups/ on /nas failed: No such device
[/quote]

Did you ever get this to work?

I now have this code in my Lua startup.

[code]-- cifs mount for use during startup
– big thanks to @akbooer 2014-04-23

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

local function cifsmount (x)
local function log (msg) luup.log ((“‘%s’ %s”): format (x.device or ‘’, msg), ‘mount’) end
local df = df ()
if df: find (x.device, 1, true) then
log “already mounted”
else
local cmd = table.concat {“mount -t cifs -o user=”, x.user, “,pass=”, x.pass, ",nounix,noserverino " , x.device, ’ ', x.directory}
local ok = os.execute (cmd)
if ok
then log “mounted OK”
else log “failed to mount”
end
end
end

cifsmount {user=“Username”, pass=“Password”, device=“//192.168.1.111/folder”, directory=“/nas”}
[/code]

Let me know how you get on…

I tried this on my VeraPlus and ran it on test Lua. It failed

(I did change the last line to reflect my info)

First of all in putty I can only mount my cifs using… mount -t cifs //xxx.xxx.xxx.xxx/Whisper /RT-AC87U -o user=xxx,pass=xxx,sec=ntlm

Could you give me another Lua code that can work with my actual mount command please?

EDIT: I just ran this in AltUi test lua and the return result was “[string “ALTUI - LuaRunHandler”]:3: attempt to call global ‘df’ (a nil value)”
This give you a clue?

Thanks

[quote=“parkerc, post:55, topic:181206”]I now have this code in my Lua startup.

[code]-- cifs mount for use during startup
– big thanks to @akbooer 2014-04-23

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

local function cifsmount (x)
local function log (msg) luup.log ((“‘%s’ %s”): format (x.device or ‘’, msg), ‘mount’) end
local df = df ()
if df: find (x.device, 1, true) then
log “already mounted”
else
local cmd = table.concat {“mount -t cifs -o user=”, x.user, “,pass=”, x.pass, ",nounix,noserverino " , x.device, ’ ', x.directory}
local ok = os.execute (cmd)
if ok
then log “mounted OK”
else log “failed to mount”
end
end
end

cifsmount {user=“Username”, pass=“Password”, device=“//192.168.1.111/folder”, directory=“/nas”}
[/code]

Let me know how you get on…[/quote]

Where is the code? Is it all in Lua Test? It looks like you did not include the definition of the df() function.

To change the mount command string, just replace the ,nounix,noserverino with ,sec=ntlm

[quote=“akbooer, post:57, topic:181206”]Where is the code? Is it all in Lua Test? It looks like you did not include the definition of the df() function.

To change the mount command string, just replace the ,nounix,noserverino with ,sec=ntlm[/quote]

Sorry, Im not a coder so I don’t know how to include this df function. I just copied the code from the thread.

But since DY does not “find” my mounted folder “Whisper” anyway, I suppose it’s a moot point. Although I can mount my nas folder, (see previous post) , DY cannot find it to write to.

It was all in the code below, but if you didn?t copy ALL of the code then it might have been missing.

This is nothing to do with DataYours, it’s all to do with Vera. If a file system is accessible from Vera, then DataYours can write to it, given the right path. If the disk is mounted already, then there?s absolutely no need for this code.

Out of desperation, I deleted and re installed DY. I plugged in my same info in variables, and lo and behold, it is working. My external mount is being seen by DY and added 2 metrics for testing. But it appears all is working now.

Thanks for your help.