Skip to content

Month: June 2024

How to shutdown a second or additional server from one Unraid machine

Found this interesting post that helped me set it up.

https://forums.unraid.net/topic/53944-how-to-shutdown-2-servers-on-1-ups

Yes, if you are using the unraid stock ups software (apcupsd). On the slave server set the cable type to Ether, the ups type to Net, and the device to <master_server_name_or_ip>:3551

Make SURE that the conditions to shutdown are set to keep the master on long enough to allow the slave server to shutdown first.

Personally, I have the master machine set to shut down after 300 seconds on battery, and the slave after 270 seconds. If the power around here is off more than a minute, it’s going to be out a while.

BTW, this also works for VM’s. I have apcupsd set up in all my VM’s to initiate shutdown after 60 seconds of no power, so they have plenty of time to finish up what they are doing and shutdown cleanly before unraid pulls the rug out from under them

Leave a Comment

bash script to clean up directories

#!/bin/bash
# Define the directory to search (you can change this to the desired directory)
DIR="/temp"

# Array of file extensions to delete
EXTENSIONS=("*.txt" "*.srt" "*.nzb" "*.sup" "*.ac3" "*.dts" "*.sample.*" "*.srr")

# Counters for deleted files and directories
deleted_files=0
deleted_directories=0

# Loop through the array and delete the files, counting each deletion
for EXT in "${EXTENSIONS[@]}"; do
    count=$(find "$DIR" -type f -name "$EXT" -print -delete | wc -l)
    deleted_files=$((deleted_files + count))
done

# Find and delete empty directories, counting each deletion
count=$(find "$DIR" -type d -empty -print -delete | wc -l)
deleted_directories=$((deleted_directories + count))

# Output the counts
echo "Deleted $deleted_files files with extensions ${EXTENSIONS[*]}."
echo "Deleted $deleted_directories empty directories."

For the most up-to-date version, follow the links below.

https://snippets.cacher.io/snippet/b554e570d8ffc0431ad9

https://gist.github.com/xavier-hernandez/f4979b4ce174068ce5428a26ae08be32

Leave a Comment

Unraid BTRFS Issues

One of my BTRFS pools, which was RAID 1 corrupted and wouldn’t mount.

I want to say docker updates overloaded the size of the docker file.

I probably did this all wrong, but I got a lot of the data from it, so I provided some commands that might help others in the future.

Make sure to put Unraid into maintenance mode.

Below are just examples since I didn’t record exactly what I did.

To mount the degraded RAID configuration. Choose the primary partition/drive to mount somewhere.

#mount degraded RAID
mount -o degraded /dev/mapper/[partition] /mnt

# to unmount
umount /mnt

To check the filesystem and hopefully fix the filesystem issue.

#shows you the filesystem
btrfs fi show /dev/sdd

#starts the scrub process
btrfs scrub start /mnt

#checks the scrub process status
btrfs scrub status /mnt

You can also use this to monitor the status instead of running the last line above over and over again.

#this will check the status of the scrub every second

watch -n 1 btrfs scrub status /mnt

I was told not to use this since it might screw up the filesystem, but my filesystem was already screwed up 🙂 This checks and tries to repair the filesystem.

btrfs check --repair /dev/sdd
Leave a Comment