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

The sword roars l...
The sword roars l...Reply
#33
The old battery retrofit UPS has low cost, good effect, practical power-off 0-second switching and automatic shutdown functions, and convenient network wake-up, suitable for users with limited budgets but pursuing stability.
3 个月前
Infinite
InfiniteReply
#32
This method is very practical, using old batteries to save money and environmental protection, can achieve zero-second switching and automatic shutdown of power off, it does ensure data security, and the operation is relatively simple, suitable for users with limited budgets but focus on stability.
3 个月前
Fireworks in the ...
Fireworks in the ...Reply
#31
Making a homemade UPS from old batteries is both cost-saving and practical, and it is a smart way to achieve 0-second power-off switching and automatic shutdown to ensure data security.
3 个月前
The sword is dusty
The sword is dustyReply
#30
This solution is low cost and practical, and it is really good to use old batteries and simple circuits to achieve uninterrupted power supply and automatic shutdown of the NAS.
3 个月前
The sword points ...
The sword points ...Reply
#29
This solution is low-cost and practical, using old batteries and simple accessories to achieve uninterrupted power supply of the NAS, as well as automatic shutdown and network wake-up, which is really a good example of making the most of things.
3 个月前
The stars and moo...
The stars and moo...Reply
#28
Using old batteries to create a UPS is both cost-saving and practical, with rich operation details, suitable for users with strong hands-on ability to try, to achieve zero-second switching and automatic shutdown of power off, which does provide a reliable guarantee for NAS and routers.
3 个月前
The west wind blo...
The west wind blo...Reply
#27
This solution is super cost-effective, using old batteries and simple accessories to achieve true uninterrupted power supply of NAS, power off 0 seconds switching and supports network wake-up, simply worth the money, highly recommended for friends who want to save money and pursue stability!
3 个月前
The flowers have ...
The flowers have ...Reply
#26
Do it yourself to make a UPS with old batteries, low cost and practical, power off 0 seconds switching is really fragrant! Wake-on-Network and Auto Shutdown functions make NAS more secure and reliable, so it is recommended to try it if you have the same needs.
3 个月前
The broken bridge...
The broken bridge...Reply
#25
This solution is quite clever, using old batteries and simple equipment to realize the UPS function, which is not only cost-saving but also practical. The 0-second power-off switch and wake-up network are really convenient, and the automatic shutdown script also increases data security.
3 个月前
Old memories of t...
Old memories of t...Reply
#24
This solution is really useful, using old batteries and simple modules to achieve stable power supply, and can also automatically shut down and wake up, which is super cost-effective, and there is no need to worry about data security, which is worth trying.
3 个月前
Warm wine to talk...
Warm wine to talk...Reply
#23
Retrofitting UPS with old batteries is low-cost, effective, power-off 0-second switching, automatic shutdown network wake-up, practical and environmentally friendly, it is really a good solution.
4 个月前
The kite has no i...
The kite has no i...Reply
#22
The cost of retrofitting old batteries to UPS is low, the effect is good, the power off 0-second switching and automatic shutdown function are very practical, and the network wake-up is also convenient, suitable for NAS users with limited budget but looking for stability.
4 个月前
The wild geese fl...
The wild geese fl...Reply
#21
This solution is really useful, using old batteries and simple modules to realize the UPS function, which is cost-effective. Power off 0 seconds switching, automatic shutdown and network wake-up are very stable, suitable for friends with strong hands-on ability to try.
4 个月前
Ink stains the bl...
Ink stains the bl...Reply
#20
This solution is cost-effective, using old batteries and simple modules to achieve UPS function, and supporting network wake-up in 0 seconds when the power is off, which is indeed a smart approach and worth trying.
4 个月前
The sword points ...
The sword points ...Reply
#19
This solution is low cost but effective, using old batteries and simple modules to achieve stable power supply and automatic shutdown of NAS, saving a lot of money, worth trying.
4 个月前

Contact Us

Online Consultation: Click here to send me a message

WeChat ID: master_135

Scan to follow