Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

how make a clean shutdown in console ?

Featured Replies

Hi, I upgraded unRAID 4.2.1 to 4.3.3,

with 4.2.1 version, to make make  a clean shutdown in console I used  command lines :

 

stop

poweroff

 

but with 4.3.3 version "stop" command is gone.

 

how make a clean shutdown in console with unRAID 4.3.3 ?

 

Thanks

Best is to install the powerdown script.  Then, you can just type "powerdown"  See here: http://lime-technology.com/forum/index.php?topic=812.msg11124#msg11124

 

If those scripts are not in place, then here is a short series of commands similar to the old "stop" command.

 

cd

samba stop

sync

for i in /dev/md*

do

umount ${i}

done

mdcmd stop

poweroff

 

Edited to fix "cd" command.

A more complete set of commands for a "stop" script is here (some parts borrowed from the powerdown script)

It checks for and kills any processes accessing the disks, allowing them to be un-mounted.

 

A zipped file copy is attached.  Download and unzip a copy to your flash drive.  Then you can log in and type

/boot/stop

 

# Stop Samba
killall smbd nmbd

# Kill any processes using the disks
for fs in /mnt/user /mnt/disk*
do
  if [ ! -d ${fs} ] ; then continue ; fi
  for pid in $(fuser -cu $fs 2>/dev/null)
  do
      kill -TERM ${pid}
  done
done

#un-mouunt the disks
for disk in /mnt/disk*
do
  /bin/umount ${disk}
done

# Stop the unRAID array
echo stop > /proc/mdcmd

echo "The unRAID array is stopped"

 

I'm mentioning this to avoid the proliferation of duplicate scripts. (scriplets)

 

if the powerdown/powercontrol package is installed,  the array can be stopped with the command /etc/rc.d/rc.unRAID stop

 

This does all of the other commands, plus the diagnostic dump.

 

It does not power off the system if you run the etc/rc.d script directly.

The etc/rc.d script is hooked into the rc0 and rc6 run levels so that the array is shutdown gracefully.

Otherwise it is the same set of commands as provided, yet there's a simple package way of installing it.

 

http://code.google.com/p/unraid-powercontrol/

 

 

  • 1 month later...

I made an unmenu powerdown package for installing v1.02 of Weebotech's powerdown script

 

I don't know if this already exists or not, I did a bunch of searching and couldn't find it anywhere.  I can't upload (getting error message) the .confs but the details are listed below.

 

Cheers,

Matt

 

contents of each .conf are as follows:

 

powerdown_ctrlaltdel-unmenu-package.conf <- contains the script for installing with control + Alt + del set to reboot

PACKAGE_NAME Clean Powerdown
PACKAGE_DESCR Primary purpose is to provide graceful shutdown of the environment when called from scripts
PACKAGE_DESCR or via command line.
PACKAGE_DESCR Sets ctrl-alt-del to do powerdown instead of reboot 
PACKAGE_URL http://unraid-powercontrol.googlecode.com/files/powerdown-1.02-noarch-unRAID.tgz
PACKAGE_FILE powerdown-1.02-noarch-unRAID.tgz
PACKAGE_MD5 10eff6bbb4a2f1428b4c57dbc292a2a5
PACKAGE_INSTALLED /etc/rc.d/rc.unRAID
PACKAGE_DEPENDENCIES none
PACKAGE_INSTALLATION CTRLALTDEL=yes installpkg powerdown-1.02-noarch-unRAID.tgz
PACKAGE_VERSION_TEST ls /etc/rc.d/rc.unRAID
PACKAGE_VERSION_STRING /etc/rc.d/rc.unRAID
PACKAGE_MEMORY_USAGE Light (10K to 500K)

 

powerdown-unmenu-package.conf <- contains the basic "default" installation script settings

PACKAGE_NAME Clean Powerdown
PACKAGE_DESCR Primary purpose is to provide graceful shutdown of the environment when called from scripts
PACKAGE_DESCR or via command line.
PACKAGE_URL http://unraid-powercontrol.googlecode.com/files/powerdown-1.02-noarch-unRAID.tgz
PACKAGE_FILE powerdown-1.02-noarch-unRAID.tgz
PACKAGE_MD5 10eff6bbb4a2f1428b4c57dbc292a2a5
PACKAGE_INSTALLED /etc/rc.d/rc.unRAID
PACKAGE_DEPENDENCIES none
PACKAGE_INSTALLATION installpkg powerdown-1.02-noarch-unRAID.tgz
PACKAGE_VERSION_TEST ls /etc/rc.d/rc.unRAID
PACKAGE_VERSION_STRING /etc/rc.d/rc.unRAID
PACKAGE_MEMORY_USAGE Light (10K to 500K)

 

EDIT to remove /boot/unmenu/ from PACKAGE_INSTALLATION lines

I only need to install one of these conf files right???

 

I tried to install the one that includes support for ctrl-alt-del, but I get the following error:

 

Cannot install /boot/packages/powerdown-1.02-noarch-unRAID.tgz: package does not end in .tgz

 

Problem is that the downloaded packages DOES end in .tgz, and I can open it with winzip.  I don't see the problem.

I only need to install one of these conf files right???

 

I tried to install the one that includes support for ctrl-alt-del, but I get the following error:

 

Cannot install /boot/packages/powerdown-1.02-noarch-unRAID.tgz: package does not end in .tgz

 

Problem is that the downloaded packages DOES end in .tgz, and I can open it with winzip.  I don't see the problem.

You probably used an editor that added carriage returns to the lines in the package-conf file, or there are trailing spaces in the file name of the .tgz file.

 

The message issued by installpkg is what it will say if the file name is not matched.  You could type

installpkg joe.tgz

and you will get exactly the same error message, because a file does not exist with that name, not because the name does not end in .tgz.

 

you can get rid of the extra carriage-return characters in the package .conf file by typing:

fromdos powerdown_ctrlaltdel-unmenu-package.conf

You'll need to check with an editor if the file name has trailing spaces on the PACKAGE_FILE line.

 

Then, try installing it once more.

I deleted everything on from the packages directory that had to do with this package.  Downloaded the .conf that Biggy posted.  Then through the package manager re-downloaded the package and attempted to install.  The archive downloaded OK (checksum matches), but I still get the same message when I attempt to install:

 

"Cannot install /boot/packages/powerdown-1.02-noarch-unRAID.tgz: package does not end in .tgz"

 

Currently, I am using the package manager to install 7 other packages with no issue.  Not sure how to figure out what is going on with this one.  The archive looks fine.  I'm assuming the .conf is tested and fine.  I don't know.

I deleted everything on from the packages directory that had to do with this package.  Downloaded the .conf that Biggy posted.  Then through the package manager re-downloaded the package and attempted to install.  The archive downloaded OK (checksum matches), but I still get the same message when I attempt to install:

 

"Cannot install /boot/packages/powerdown-1.02-noarch-unRAID.tgz: package does not end in .tgz"

 

Currently, I am using the package manager to install 7 other packages with no issue.  Not sure how to figure out what is going on with this one.  The archive looks fine.  I'm assuming the .conf is tested and fine.  I don't know.

 

Is /boot/packages/ your package directory?  you might have to change that in the .conf to where the location of your actual package directory is.  I thought you had said once in the past that your package directory is /boot/custom/packages?

 

It could be saving it in one directory and and the .conf is trying to run it from another.

 

Cheers,

Matt

I deleted everything on from the packages directory that had to do with this package.  Downloaded the .conf that Biggy posted.  Then through the package manager re-downloaded the package and attempted to install.  The archive downloaded OK (checksum matches), but I still get the same message when I attempt to install:

 

"Cannot install /boot/packages/powerdown-1.02-noarch-unRAID.tgz: package does not end in .tgz"

 

Currently, I am using the package manager to install 7 other packages with no issue.  Not sure how to figure out what is going on with this one.  The archive looks fine.  I'm assuming the .conf is tested and fine.  I don't know.

 

Is /boot/packages/ your package directory?  you might have to change that in the .conf to where the location of your actual package directory is.  I thought you had said once in the past that your package directory is /boot/custom/packages?

 

It could be saving it in one directory and and the .conf is trying to run it from another.

 

Cheers,

Matt

I'll bet that is it.

 

The package.conf should not have any leading path on the "installpkg" line as it will already invoke it in the correct directory.  (Now, it will work if it is the "correct" path, but it sure won't if it points to the wrong folder.)

 

The corrected line should say:

 

PACKAGE_INSTALLATION CTRLALTDEL=yes installpkg powerdown-1.02-noarch-unRAID.tgz

 

instead of:

PACKAGE_INSTALLATION CTRLALTDEL=yes installpkg /boot/packages/powerdown-1.02-noarch-unRAID.tgz

 

You can use the File-Editor plug-in to edit the package.conf file.  (available from here) Then it should work as desired.

  Note: the File-Editor needs the 1.1 version of unmenu to work... If you do not have it installed, you can use any editor, it is just very convenient if you do.

Joe L.

That was the issue.  Thank's guys.  I can't believe I didn't notice that myself.

  • 3 weeks later...

A more complete set of commands for a "stop" script is here (some parts borrowed from the powerdown script)

It checks for and kills any processes accessing the disks, allowing them to be un-mounted.

 

A zipped file copy is attached.  Download and unzip a copy to your flash drive.  T

 

Joe L., Where is this attached zipped powerdown file?

A more complete set of commands for a "stop" script is here (some parts borrowed from the powerdown script)

It checks for and kills any processes accessing the disks, allowing them to be un-mounted.

 

A zipped file copy is attached.  Download and unzip a copy to your flash drive.  T

 

Joe L., Where is this attached zipped powerdown file?

 

The simple "stop" command was in the post you referred to... for the more complete powerdown command...

 

The powerdown command is available from a link in this post:

http://lime-technology.com/forum/index.php?topic=2781.msg22884#msg22884

 

Even easier, since it needs to be re-installed every time you reboot, you might want to install unmenu,

described here in the wiki:

http://lime-technology.com/wiki/index.php?title=UnRAID_Add_Ons#UnMENU

Version 1.1 ia available here:

http://code.google.com/p/unraid-unmenu/

 

then download the package.conf file for the powerdown command from here:

http://lime-technology.com/forum/index.php?topic=3020.msg24990#msg24990

 

Use unmenu's Package Manager download install the powerdown command, install it and then enable it to be re-installed every time you reboot.

 

Joe L.

Thans Joe.

  • 1 month later...

guys, I'm getting confused.  I'm looking for a console clean shutdown method.  I'm running unRAID 4.4 basic with no add-ons or changes, happy with the web interface and getting other info from the console.  with a monitor connected to the VGA port of the server I can watch the boot process and shutdown process.  When I select "powerdown" from the web interface of my PC, I notice the system calls a shutdown script "/etc/rc.d/rc.0".  I'm assuming this is not accessible or valid from the console, too chicken to try!  so what needs to be done with 4.4?

 

I'm reading about Linux admin, but really appreciate your support...

 

thanks.. 

guys, I'm getting confused.  I'm looking for a console clean shutdown method.  I'm running unRAID 4.4 basic with no add-ons or changes, happy with the web interface and getting other info from the console.  with a monitor connected to the VGA port of the server I can watch the boot process and shutdown process.  When I select "powerdown" from the web interface of my PC, I notice the system calls a shutdown script "/etc/rc.d/rc.0".  I'm assuming this is not accessible or valid from the console, too chicken to try!  so what needs to be done with 4.4?

 

I'm reading about Linux admin, but really appreciate your support...

 

thanks.. 

If you have not added any packages or scripts, and are running a completely stock version of unRAID (of ANY recent release in the past year or two) there is NO supplied clean shutdown method from the system console.

 

If you download and install the powerdown package, then you can type powerdown, or type Ctl-Alt-Del on the console as it properly installs the needed script in the rc.d directory.

 

Other than that, you can type a series of commands prior to calling shutdown, as described earlier in this thread.  Or you can download stop.zip I posted earlier and unzip it on your flash drive.  It will do a fair job of cleanly stopping the array.  Best is to download and install the powerdown package.  It is even better but will need to be re-installed every time you reboot.

 

 

 

Joe L.

thanks Joe, I like the "unmenu" script you developed and posted (7/06) will this work?  I'm all SATA.  If so, is the ZIP on that post still valid for 4.4?

 

love this server, just want a reliable alternative to the browser...

 

thanks again...

 

 

  • 6 months later...

I've been running this package and it is a lifesaver.  However, i just installed the cache_dirs package (http://lime-technology.com/wiki/index.php/Improving_unRAID_Performance#Keep_directory_entries_cached) which makes you press the Stop button twice on the main menu for a clean shutdown.  I'm wondering if that will prevent powerdown from being able to cleanly shutdown.  I'm afraid to try it since it takes so long to rebuild the parity drive if it fails.  Anyone know?

 

cache_dirs -q will apparently shut down that process, but rc.unRAID gets rebuilt on each startup, so I'm not sure where I could invoke it.

cache_dirs -q will apparently shut down that process, but rc.unRAID gets rebuilt on each startup, so I'm not sure where I could invoke it.

 

I'll post an update to the script to call the cache_dirs -q command.

The only issue I have is, I do not always know where it is.

 

Joe, is there a standard install location?

 

I was thinking of just running any script in a directory called /boot/custom/shutdown.d

This would allow anyone to just drop scripts into that location.

 

The ideal choice is to add an /etc/rc.d/rc.cache_dirs script which has the start/stop commands.

Then have the install procedure add the call to /etc/rc.d/

 

I.E.

root@Atlas /etc/rc.d #more rc.local_shutdown 


[ -x /etc/rc.d/rc.unRAID ] && /etc/rc.d/rc.unRAID stop

 

The only trick is to do some fancy manipulation to insure call to cache_dirs is first!

 

cache_dirs -q will apparently shut down that process, but rc.unRAID gets rebuilt on each startup, so I'm not sure where I could invoke it.

 

I'll post an update to the script to call the cache_dirs -q command.

The only issue I have is, I do not always know where it is.

 

Joe, is there a standard install location?

 

I was thinking of just running any script in a directory called /boot/custom/shutdown.d

This would allow anyone to just drop scripts into that location.

 

The ideal choice is to add an /etc/rc.d/rc.cache_dirs script which has the start/stop commands.

Then have the install procedure add the call to /etc/rc.d/

 

I.E.

root@Atlas /etc/rc.d #more rc.local_shutdown 


[ -x /etc/rc.d/rc.unRAID ] && /etc/rc.d/rc.unRAID stop

 

The only trick is to do some fancy manipulation to insure call to cache_dirs is first!

 

 

Thanks for looking into it WeeboTech!  It seems like a good idea to invoke scripts in a custom directory, that way you won't need to keep modifying powerdown as new packages (that might need custom handling) are released.

Unfortunately, they can invoke it from anywhere...

 

Fortunately, it has as its main loop this logic

while [ -f "$lockfile" ]

do

...

  sleep (scan increment)

done

 

So it will kill itself if you remove the lock file.  The file is:

/var/lock/cache_dirs.LCK

 

If you want to kill it with a signal, the PID of the cache_dirs process is in the lockfile, but removing it will cause the cache_dirs to kill itself within 10 seconds or so.

Perhaps

something like this

kill `cat /var/lock/cache_dirs.LCK`

 

You do bring up a great point though, we need a common place to put the shutdown functions... Perhaps we can follow the rc.d structure... That way, you can just invoke

rc.cache_dirs stop

and invoke the "stop" command for each script in a rc directory.

 

Ideas? 

 

Joe L.

So it will kill itself if you remove the lock file.  The file is:

/var/lock/cache_dirs.LCK

 

If you want to kill it with a signal, the PID of the cache_dirs process is in the lockfile, but removing it will cause the cache_dirs to kill itself within 10 seconds or so.

Perhaps

something like this

kill `cat /var/lock/cache_dirs.LCK

 

This is perfect, by convention it should be

 

/var/run/cache_dirs.pid

 

 

 

What method does cache_dirs -q use to exit the process?  Does it just remove the lock file?  I'm wondering how quickly or slowly I should expect cache_dirs -q to actually shut it down.

What method does cache_dirs -q use to exit the process?  Does it just remove the lock file?  I'm wondering how quickly or slowly I should expect cache_dirs -q to actually shut it down.

It sends a "kill" signal based on the PIC in the lock file.  You should wait 5 or 10 seconds probably...

 

There is one tiny catch, even with a "kill"  as a "find" in progress on a disk, where it is waiting for a disk(or disks) to spin up, will take as long as it needs as you are killing the parent shell, not the "find" and I don't think the "find" can be killed at that point anyway as it is locked in kernel space waiting for the spin-up. (immune to even a kill -9 at that point in time

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.