1. Current Location: Home >  NAS >  Create an N100 Flying Bull NAS "true uninterruptible power supply": old notebook battery resurrection record, power off 0 seconds switching, incoming call network wake-up, and comes with an automatic shutdown script

Create an N100 Flying Bull NAS "true uninterruptible power supply": old notebook battery resurrection record, power off 0 seconds switching, incoming call network wake-up, and comes with an automatic shutdown script

1. Write in front

Feiniu NAS (N100 small host + Feiniu OS) has low power consumption and strong performance, but the price of UPS that supports USB protocol is generally high, and the USB companion of NAS is also dozens of larger (even more so if there is a UPS, it is directly 0 cost you can achieve automatic shutdown, see the fourth step). In order to data security , I disassembled the dusty notebook battery in the drawer and spent less than a few tens of yuan to assemble a set of " beggar's version UPS", which can not only switch in 0 seconds, but also automatically shut down safely after a power outage, and wake up the network with one click on the main route + NAS after the call.

2. Bill of materials

Waste Notebook Lithium Battery (6 Cells)

Fully automatic 12V battery management board with UPS mode

12V Boost and Voltage Regulator Module

N100 small host (flashed Feiniu OS)

main route is iExpress (also connected to UPS)

secondary routing (bedroom relay)

DC5521 male/female, wire

Note: The keyword of the management board model is "12V UPS lithium battery protection board automatic charging and discharging uninterrupted", be sure to buy one with "UPS mode", switch for 0 seconds without dropping voltage.

3. Quick overview of principles

power supply path
mains → 12V UPS board→ regulated voltage 12V →N100NAS, main router, optical cat
After the mains power is lost, the UPS board cuts to the lithium battery in 0 seconds to continue output, and the voltage regulation module regulates 12V to the NAS, main router, and optical cat.

network wake-up link
Guangmao and the main route Aikuai are also connected to the same UPS, and they are still online after the power is cut off. After the NAS is turned off, you can → "Wake on to Network" in the iKuai app at any time.

automatic shutdown trigger
Feiniu OS has built-in Crontab+Shell, ping the sub-route every 3 seconds IP: 192.168.9.5 (this is my sub-router address, changed to your own address in the later code)
10 consecutive times of failure to connect will determine "mains power is cut off + sub-route is hung", and the shutdown is performed (the time and number can be modified according to your own needs).
secondary route is not connected to the UPS, and the power is cut off before the NAS after the mains power is cut off, naturally forming a "power loss signal".

4. Feiniu OS automatic shutdown script

log in to the NAS with WinSCP and create /usr/ups_safe_shutdown.sh:

#!/bin/bash # ============================================================================ # Automatic shutdown guard script for network loss (fixed router IP version) # Must run as root # Count Nest Notes # ============================================================================ # ---------- 1. Permission Check ---------- if [[ $EUID -ne 0 ]]; then echo "Error: This script must run with root privileges." >&2 exit 1 fi # ---------- 2. Singleton Lock ---------- LOCKFILE="/var/run/ups_safe_shutdown.pid" exec 200>"$LOCKFILE" if ! flock -n 200; then echo "The script is running, exit." exit 1 fi echo $$ >&200 # ---------- 3. Basic configuration ---------- ROUTER_IP="192.168.9.5" # Fixed router address (unchanged) MAX_FAIL=10 # Maximum number of consecutive failures CHECK_INT=3 # Detection interval (seconds) LOG_FILE="/usr/ups_safe_shutdown.log" failure_count=0 # Log function log() { echo "$(date '+%F %T') - $*" | tee -a "$LOG_FILE" } # ---------- 4. Main Cycle ---------- while :; do if ping -c1 -W1 "$ROUTER_IP" >/dev/null 2>&1; then # Network recovery if [[ $failure_count -ge $MAX_FAIL ]]; then # Shutdown was triggered before, now canceled shutdown -c 2>/dev/null &> log "Network restored, cancel shutdown schedule" fi failure_count=0 else # Network failure ((failure_count++)) log "Ping Failures: $failure_count/$MAX_FAIL" if [[ $failure_count -eq $MAX_FAIL ]]; then log "$MAX_FAIL pings fail in a row, the system will shut down after 60 seconds!" shutdown -h +1 "System triggers automatic shutdown due to loss of network connection" fi fi sleep "$CHECK_INT" done

1. Grant Execution Permissions:

chmod +x /usr/ups_safe_shutdown.sh

2. Create a systemd service unit:

sudo tee /etc/systemd/system/ups_safe_shutdown.service >/dev/null < <'EOF' [Unit] Description=Network Watchdog – auto-shutdown on lost router After=network-online.target Wants=network-online.target [Service] Type=simple ExecStart=/usr/ups_safe_shutdown.sh Restart=always RestartSec=10 KillMode=process # Send the log to journal for easy systemctl status viewing StandardOutput=journal StandardError=journal [Install] WantedBy=multi-user.target EOF

3. Enable and start immediately:

sudo systemctl daemon-reload sudo systemctl enable --now ups_safe_shutdown.service

4. Common Administrative Commands:

check the operating status
sudo systemctl status ups_safe_shutdown.service__TAG76_TAG77__ real-time log (journal)
sudo journalctl -u ups_safe_ shutdown - f
manually restart
sudo systemctl restart ups_safe_shutdown
stop
sudo systemctl stop ups_safe_shutdown

5. Verification steps

unplug the mains power, observe that the NAS panel light is still on, and the route can still be pinged → UPS switch successfully.

unplug the secondary route and wait for a while NAS automatically shut down → the script takes effect.

power up again, log in to the "Wake-on" app → select the NAS →, and after 5 seconds, the N100 drop starts → wakes up successfully.

6. Guide to pit drainage

is a fast router, so don't turn on hijacking all PING values.

7. Conclusion

whole solution makes use of the waste laptop battery, so you don't have to spend too much money to buy a UPS, and you don't have to worry about the hard drive being damaged during a power outage.
I wish you all a happy time and the data will last forever!

Read More


Copyright Notice Scan to read on mobile
All Rights Reserved: 《SHUNOT》 => 《Create an N100 Flying Bull NAS "true uninterruptible power supply": old notebook battery resurrection record, power off 0 seconds switching, incoming call network wake-up, and comes with an automatic shutdown script
Article URL: https://www.shunot.com/en/nas/660.html
Unless otherwise stated, all articles are original by 《SHUNOT》. Reposting is welcome! Please indicate the original URL when reposting, thank you.

Comment List

Red dust infatuation
Red dust infatuationReply
#18
This solution is very practical, saving money and environmental protection with old batteries, the key is to achieve real uninterrupted power supply, and it can also wake up the device remotely, which is too friendly to the home server.
4 个月前
The green light i...
The green light i...Reply
#17
This solution is very practical, using old batteries and basic modules to realize the UPS function, low cost and reliability, it is really a good way to kill multiple birds with one stone.
4 个月前
The ink dyed the ...
The ink dyed the ...Reply
#16
Homemade UPS has low cost and good effect, cannot cut off the voltage in seconds when the power is off, network wake-up is super convenient, and the flying bull OS automatic shutdown script is practical. Data security is guaranteed, and it is really good to use it to the best of things.
4 个月前
The south wind ha...
The south wind ha...Reply
#15
The cost of using an old battery to build a UPS is low, the effect is surprisingly good, the power is off in zero seconds, and the network can wake up, which is really an economical and practical solution, data security is guaranteed, and it is worth trying.
4 个月前
The flowers fall ...
The flowers fall ...Reply
#14
The cost of retrofitting old batteries to UPS is low, the effect is good, the power off is 0 seconds switching is very reassuring, and the automatic shutdown and network wake-up functions are practical, suitable for NAS users with limited budgets and stability.
4 个月前
Drunk lying on th...
Drunk lying on th...Reply
#13
This solution is quite practical, using old batteries and simple accessories to achieve uninterrupted power supply of NAS, and can also automatically shut down and wake up the network, which is cost-effective and suitable for users who want to protect their devices at low cost.
4 个月前
It's better to go...
It's better to go...Reply
#12
This transformation solution is very practical, using old batteries to achieve uninterrupted power supply of NAS and routers at low cost, automatic shutdown and wake-up calls when power is off, which not only saves money but also ensures data security, which is worth trying.
5 个月前
Walking in the cl...
Walking in the cl...Reply
#11
This solution is cost-effective, using old batteries to modify UPS, not only saving money but also practical, power-off 0-second switching and wake-up network functions are very intimate, suitable for users with limited budgets but pursuit of stability.
5 个月前
Life is like a dream
Life is like a dreamReply
#10
This solution is really the best use of things, using old batteries and low-cost accessories to achieve UPS functions, not only saving money but also very practical, data security is guaranteed, and the operation is not complicated, which is very suitable for users with limited budgets.
5 个月前
The ink turned white
The ink turned whiteReply
#9
This solution is very practical, using old batteries and simple accessories to achieve UPS function, low cost and reliability. Power off switching in zero seconds, wake-up is also very convenient, suitable for users with limited budgets but seeking stability.
5 个月前
The mountains and...
The mountains and...Reply
#8
This method is very practical, low-cost and effective, which not only ensures data security, but also allows the device to automatically shut down after a power outage, making it easy to resume incoming calls, suitable for users with limited budgets but want to improve NAS stability.
5 个月前
Spring is slow an...
Spring is slow an...Reply
#7
Do you dare to put old battery cells on UPS? Afraid of explosion......
5 个月前
The original inte...
The original inte...Reply
#6
Battery management board keywords ask for links!
5 个月前
Ink fragrance
Ink fragranceReply
#5
Old batteries are revived, saving money and peace of mind!
5 个月前
Half a cup of tea
Half a cup of teaReply
#4
0 seconds switching is too fragrant, how to warn of battery aging?
5 个月前

Contact Us

Online Consultation: Click here to send me a message

WeChat ID: master_135

Scan to follow