October 23, 201213 yr I am running unraid v5rc8a and mount drives outside the array from within the go script as such: mount -t reiserfs /dev/disk/by-id/scsi-1ATA_INTEL_SSDSA1MH080G1GN_XXXX /mnt/disk/ssd Question: what happens during a powerdown? Is this drive unmounted cleanly or must I add something in any of the powerdown scripts to achieve a clean unmount? thanks
October 25, 201213 yr The drive is supposed to be unmounted cleanly, unless some other issue occurs, I.E. power failure
October 26, 201213 yr The drive is supposed to be unmounted cleanly, unless some other issue occurs, I.E. power failure Unless you un-mount the drive, nothing I know of will un-mount it for you on a power down. These lines in /etc/rc.d/rc.0 should un-mount all the file-systems IF IT CAN. echo "Unmounting local file systems." /bin/umount -v -a -t no,proc,sysfs The file-system will not be un-mounted if it is busy. (a file is open, or a process is using it as its current-working-directory)
October 26, 201213 yr The clues you need are in /etc/rc.d/rc.local #!/bin/sh # # /etc/rc.d/rc.local: Local system initialization script. # # Put any local startup commands in here. Also, if you have # anything that needs to be run at shutdown time you can # make an /etc/rc.d/rc.local_shutdown script and put those # commands in there. # Install any extra packages if [ -d /boot/extra ]; then ( cd /boot/extra ; find -maxdepth 1 -type f -exec installpkg {} \; ) fi # Install system plugins if [ -d /boot/plugins ]; then for Plugin in /boot/plugins/*.plg ; do /usr/local/sbin/installplg $Plugin | logger done fi # Install user plugins if [ -d /boot/config/plugins ]; then for Plugin in /boot/config/plugins/*.plg ; do /usr/local/sbin/installplg $Plugin | logger done fi # Invoke the 'go' script if [ -f /boot/config/go ]; then fromdos </boot/config/go >/var/tmp/go chmod +x /var/tmp/go /var/tmp/go fi You need to add any special shutdown commands for your custom stuff to /etc/rc.d/rc.local_shutdown Joe L.
October 26, 201213 yr Author So I'm assuming the rc.local_shutdown needs to be dynamically created in the go script to stick between reboots? Thanks
October 27, 201213 yr So I'm assuming the rc.local_shutdown needs to be dynamically created in the go script to stick between reboots? Thanks Exactly, or as part of one of the packages being installed. At least one package creates the file, as it exists on my server. (I think the "clean powerdown created it" It contains one line on my server: [ -x /etc/rc.d/rc.unRAID ] && /etc/rc.d/rc.unRAID stop Your script of commands just needs to append to the rc.local_shutdown file if it exists, or create it if it does not. Don't forget to make it executable.
October 27, 201213 yr Thanks for the help! Gives me enough to go on. Something as simple as these few lines might work for you. They will create/append to rc.local_shutdown lines needed to attempt to stop processes using the mounted disk and then un-mount it. You can add additional command lines just prior to the kill -HUP line, and after the sync line to stop other local add-ons. echo "sync; swapoff -a" >>/etc/rc.d/rc.local_shutdown echo "kill -HUP `lsof -t /mnt/disk/ssd`; sleep 5" >>/etc/rc.d/rc.local_shutdown echo "kill -INT `lsof -t /mnt/disk/ssd`; sleep 5" >>/etc/rc.d/rc.local_shutdown echo "kill -9 `lsof -t /mnt/disk/ssd`; sleep 5" >>/etc/rc.d/rc.local_shutdown echo "umount /mnt/disk/ssd" >>/etc/rc.d/rc.local_shutdown chmod +x /etc/rc.d/rc.local_shutdown
October 27, 201213 yr Author Thanks Joe., I was simply going to do a, "umount /mnt/disk/ssd" and call it quits. I'm glad you posted more, which I assume attempts to gracefully kill active processes on the filesystem. I also noticed the "swapoff -a" command which removes any swap usage, but is this necessary if I am not using additional swap space? I used to with 4.7, but now that I am on v5, I did not enabled it. Another question would be if 4Gb is sufficient without swap? I am running a bunch of plugins, sickbeard, sab, couchpotato, subsonic and utserver... Would one need to pipe lsof to xargs if there are multiple PIDs? Or it's not necessary. kill -HUP `lsof -t /mnt/disk/downloads/ | xargs` I actually have multiple disks outside of the array and made a script with your suggestions, maybe you can take a look? Thanks This script is on the boot usb in /boot/config/custom/rc.local_shutdown #!/bin/bash UMOUNT_TARGETS=( /mnt/disk/ssd /mnt/disk/downloads ) for (( i = 0 ; i < ${#UMOUNT_TARGETS[@]} ; i++ )); do if grep -qs ${UMOUNT_TARGETS[$i]} /proc/mounts; then echo "\"${UMOUNT_TARGETS[$i]}\" exists. Attempting to unmount" PIDS=$(lsof -t ${UMOUNT_TARGETS[$i]} | xargs) sync; swapoff -a if [[ -z $PIDS ]]; then echo "No PIDS to kill..." else echo "\"${PIDS}\" PIDs needs to be killed" kill -HUP $PIDS; sleep 5 kill -INT $PIDS; sleep 5 kill -9 $PIDS; sleep 5 fi echo "unmounting \"${UMOUNT_TARGETS[$i]}..." umount ${UMOUNT_TARGETS[$i]} if [[ $? -ne 0 ]]; then echo "Trouble umounting \"${UMOUNT_TARGETS[$i]}\"" fi else echo "\"${UMOUNT_TARGETS[$i]}\" does not exist." fi PIDS="" done Now, my /etc/rc.d/rc.local_shutdown looks like: [ -x /etc/rc.d/rc.unRAID ] && /etc/rc.d/rc.unRAID stop /boot/config/custom/rc.local_shutdown The only concern I have is that the majority of the PIDS on these mount points (outside disks) are in fact processes from the aforementioned plugins. I would not like to kill processes that have their respective shutdown scripts as designed by the plugin developers. I'm not sure at what point the plugins kill their respective processes. Is it in the rc.unRAID script? I have yet to test this out.
October 28, 201213 yr I think this line if [[ -z $PIDS ]]; then needs to be if [[ -z "$PIDS" ]]; then The variable needs to be surrounded by quotes... otherwise, when there are more than one PID, the syntax will fail, and the script will stop. (yes, the kill command can take multiple arguments) I do send a HUP signal first, then an INT. (and finally a KILL with some time delay for the kill signals to take effect and processes to stop gracefully) unRAID 5.X now has an event system which can be used to facilitate (or hamper ) a shutdown. Each process can tie into it, but the scripts are executed in series, and any one of them can block the entire process from completion. When that happens, then server never stops. (or never starts) You'll need to look to each of your plugins to see if they tie into the event system cleanly. They are invoked from /usr/local/sbin/emhttp_event (the shell script invoked from emhttp on each "event" type.) You'll probably want to see what your plugins do with the "stopping_svcs" event. Joe L.
October 31, 201213 yr Author Not sure it's quite working. I noticed that the shutdown fails to complete at times. It almost feels as though my script gets executed before the plugins' own shutdown happens. Not sure it that's causing the problem. I wish I knew how to tie it into the "stopping_svcs" event you mention and control the order of execution for the shutdown scripts..
Archived
This topic is now archived and is closed to further replies.