Swap File in "Edit Startup Lua"

Just realized I can start my Swap File in “Edit Startup Lua”, that way I don’t have to create a “custom-user-startup” file.

I’m using the following [os.execute(‘swapon /tmp/log/cmh/swapfile’)]

Just curious if this is a proper thing to do ?
It appears to work fine. Any comments are welcome.

Thanks

See thread:

http://forum.micasaverde.com/index.php?topic=8883.msg71591.msg#71591

  • Garrett

@Garrett

Is this what you are suggesting to put in Edit Startup Lua ?


[code]local file = io.popen( “free | grep Swap: | awk ‘{printf $2}’” )
local data = file:read( “*a” )
file:close()

luup.log('Swap total: '…tostring(data) )

if tonumber( data ) == 0
then
os.execute( ‘swapon /tmp/log/cmh/swapfile’ )
end[/code]

I’ve used this on a Vera 2 that I gave to a coworker. Should work fine. Just make sure you have the path to the swap file correct.

  • Garrett

Great !
Thanks for the info

[quote=“jackpot, post:3, topic:171890”]@Garrett

Is this what you are suggesting to put in Edit Startup Lua ?


[code]local file = io.popen( “free | grep Swap: | awk ‘{printf $2}’” )
local data = file:read( “*a” )
file:close()

luup.log('Swap total: '…tostring(data) )

if tonumber( data ) == 0
then
os.execute( ‘swapon /tmp/log/cmh/swapfile’ )
end[/code]
--------------------------------------------------------------------------------------[/quote]

I’ve been having problems with memory on my VERALite so I thought I’d try the swapfile route to see if it would help. I copied this code into the Edit Startup Lua and it apparently created the swapfile but it shows the size as ZERO

              total         used         free       shared      buffers
  Mem:        62480        60392         2088            0         1620
 Swap:            0            0            0
Total:        62480        60392         2088

Two questions.

  1. What did I do wrong and
  2. How do I correct it and get the swap running

Hi @clippermiami

I’ll be interested to hear how you get on.

I’ve been tempted to try it http://wiki.micasaverde.com/index.php/USB_swapfile_creation by creating the swap file on the same USB key as used for Vera logging.

Is that where yours is?

As with most things we all want more out of our equipment, and while the Vera 2 was felt to be under spec before. Jumping to Jan 2014 due to the increase in apps the VeraLite for some (maybe many) might benefit of having the swap file there. (Especially if it’s only used when needed, and may advert the odd low memory restart)

[quote=“parkerc, post:7, topic:171890”]Hi @clippermiami

I’ll be interested to hear how you get on.

As with most things we all want more out of our equipment, and while the Vera 2 was felt to be under spec before. Jumping to Jan 2014 due to the increase in apps the VeraLite for some (maybe many) might benefit of having the swap file there. (Especially if it’s only used when needed, and may advert the odd low memory restart)[/quote]

Its not working, says size is zero.

Apparently there is nothing damaging about the code but it doesn’t create a swapfile. This is one of a number of cases where I have no idea what’s wrong — in the immortal words of Blance DuBois (Streetcar Named Desire) “I have always depended on the kindness of strangers” to tell me what I’ve done wrong ;D

My next step is a newer faster bigger Vera but I’m tempted to wait until the new models come out.

Not sure if you saw the update to my earlier post above.

Where did you create the swap file

[quote=“parkerc, post:9, topic:171890”]Not sure if you saw the update to my earlier post above.

Where did you create the swap file[/quote]

This code was in a previous forum post and it sounded like it fit my situation so I just copy/paste – obviously it wasn’t right :slight_smile:

[code]
local file = io.popen( “free | grep Swap: | awk ‘{printf $2}’” )
local data = file:read( “*a” )
file:close()

luup.log('Swap total: '…tostring(data) )

if tonumber( data ) == 0
then
os.execute( ‘swapon /tmp/log/cmh/swapfile’ )
end

I’m not an expert but I think you have to create your swap file first for it to work, as the code you copy and pasted seems to refer to that file.

(See http://wiki.micasaverde.com/index.php/USB_swapfile_creation)

That looks like the missing piece to me.

[quote=“parkerc, post:11, topic:171890”]I’m not an expert but I think you have to create your swap file first for it to work, as the code you copy and pasted seems to refer to that file.

(See http://wiki.micasaverde.com/index.php/USB_swapfile_creation)

That looks like the missing piece to me.[/quote]

Looks like that did it :slight_smile:

THANKS!!

Thats great news…

Can you share and updated view of the memory Vera is now reporting?

Also (and perhaps more important) please let me know if you notice any improvements (or issues) as a result of enabling it.

[quote=“parkerc, post:13, topic:171890”]Thats great news…

Can you share and updated view of the memory Vera is now reporting?

Also (and perhaps more important) please let me know if you notice any improvements (or issues) as a result of enabling it.[/quote]

Sure, I’ll get a screen shot out the result. Right now there I’d enough main memory that the swap file ivy being used