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

Ink fragrance
Ink fragranceReply
#3
Old batteries can still last like this, I learned!
5 个月前
The clouds are li...
The clouds are li...Reply
#2
The actual measurement found that the management board still dropped 200mV when the power was cut off under 0.6A load, has the owner measured the amplitude of the drop voltage?
5 个月前
Under the moonlig...
Under the moonlig...Reply
#1
Clever idea, but what is the measured ripple pressure drop of UPS board switching in 0 seconds? Worried about N100 dropping.
5 个月前

Contact Us

Online Consultation: Click here to send me a message

WeChat ID: master_135

Scan to follow