Unraid on the Laptop, using battery as an UPS.


Recommended Posts



I am using Thinkpad W530 Laptop for unraid server. Today, after fruitful discussion on this forum I made a user.script that will shutdown unraid when laptop battery is bellow 30% and ac is off.

Plugin user.script

is required to use my solution.

All You need to do is to extract attached archive to folder:  /boot/config/plugins/user.scripts/scripts/shutdownWhenBatteryDepleted

root@nas:/boot/config/plugins/user.scripts/scripts/shutdownWhenBatteryDepleted# ls -l
total 64
-rw------- 1 root root 2716 Mar  6 09:41 ac.ko.xz
-rw------- 1 root root 6700 Mar  6 09:41 battery.ko.xz
-rw------- 1 root root  177 Mar  6 11:20 description
-rw------- 1 root root 1018 Mar  6 12:54 script


It is important not to change script name, as path to *.ko.xz module is hardcoded in the script file.

When this is done, You must test script, by running it manually. Then after You make sure it works in Your system You can enable the scheduler. Script will write log using logger command when shutdown is issued.

On first run script will load ac and battery kernel modules.



In the attached figure I am running script every one minute, but maybe every 2 minutes would be sufficient. You can enter */2 * * * * to run script every 2 minutes. Use this website https://crontab.guru to find Your preferred schedule.


Use at Your own risk! For testing purpose I suggest commenting out (sign #) command /sbin/poweroff in my script.

I am still unsure if /sbin/poweroff is proper way to shutdown VMs and docker gracefully. Waitng for support to answere my question, as I was unable to find it on the Internet.


Best Regards,



shutdownWhenBatteryDepleted_unraid6_8_3.zip shutdownWhenBatteryDepleted_unraid6_9_0.zip

Edited by Kacper
Added kernel modules for unraid 6.9.0
  • Like 1
Link to comment
  • 5 months later...

Hi nice to know u like it. I used docker called:



Then I set to manual compile or sth. like that. Then I did my own make menuconfig - like it is described in the manual for this docker. Then I compiled with make commands. At the end i have copied over ssh battery modules.

Link to comment
  • 3 months later...

I am almost sure that this message means that module is not compiled for kernel used by unraid 6.9.2. Pay attention that I have compiled modules for unraid 6.8.3 and 6.9.0. I am still using unraid 6.9.0 as I don't want to waste time for upgrading my unraid server. It works fine right now. So you need to use docker called unraid-kernel-helper if it is already avaliable for 6.9.2 and compile ac and battery modules by yourselfe. Script will stay the same, it will work if modules load correctly.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.