unRAID Command Thread


Recommended Posts

I am interested in a way to kickoff the parity check from a command line, and was wondering if anyone knew if there was a command line tool to do this?

 

I was looking around and trying to figure it out.  I wonder if there is a mdcmd option - but running

mdcmd -?

does not list the options.  Does anyone have a complete (or even partial) list of unRAID commands?

 

I know about ...

  poweroff (powers down the unRAID server)

  mdcmd set invalidslot 99 (tells raid to assume that parity is valid and starts parity check rather than parity rebuild with next array start)

  /proc/mdcmd (text file containing unRAID status)

  echo "status">/proc/mdcmd (request for unRAID to refresh the /proc/mdcmd file - seems to happen instantly)

  sync (not an unRAID command, but causes OS to dump buffers to disk.  Otherwise buffers can stay unwritten for a VERY long time)

Link to comment

check and nocheck look to be options to start and stop a parity sync

 

You can also look at the md.c code where it does token processing.

 

rcotrone@slacky:/usr/src/linux/drivers/md$ grep token md.c 
char *get_token( char **bufp, char *delim) {
        char *token;
                token = ptr;
                /*skip over token */
                token = NULL;
        return token;
        char buf[256], *bufp, *token, *temp;
        token = get_token( &bufp, delim);
        if (token == NULL) {
                strcpy( md_resp, "proc write: null token\n");
            ((md_trace == 1) && strcmp("status", token)))
        ok = sprintf( md_resp, "cmdOper=%s\ncmdResult=", token);
        if (!strcmp("set", token)) {
                if ((token = get_token( &bufp, delim)) != NULL)
                        name = token;
                if ((token = get_token( &bufp, delim)) != NULL)
                        value = simple_strtol( token, &temp, 10);
                        md_trace = token ? value : MD_TRACE;
                        rebuild_window = token ? value : REBUILD_WINDOW;
                        invalidslot = token ? value : 0;
                        reconstart = token ? value : 0;
                        md_write_limit = token ? value : MD_WRITE_LIMIT;
        if (!strcmp("dump", token)) {
        if (!strcmp("rderror", token)) {
                if ((token = get_token( &bufp, delim)) != NULL)
                        slot = simple_strtol( token, &temp, 10);
        if (!strcmp("wrerror", token)) {
                if ((token = get_token( &bufp, delim)) != NULL)
                        slot = simple_strtol( token, &temp, 10);
        if (!strcmp("status", token)) {
        if (!strcmp("start", token)) {
                if ((token = get_token( &bufp, delim)) != NULL)
                        state = token;
        if (!strcmp("stop", token)) {
        if (!strcmp("check", token)){
        if (!strcmp("nocheck", token)){
        if (!strcmp("clear", token)){

Link to comment

Thanks WeeboTech!

 

I experimented and found that these commands also work as command line arguments.

 

Thanks again.

That is because the command argument to the "mdcmd" shell script is echoed to /proc/mdcmd.

 

cat /mdcmd

#!/bin/bash

#

echo $* >/proc/mdcmd

cat /proc/mdcmd >/tmp/mdresp

cat /tmp/mdresp

 

Be careful with the experiments with some of those options... they might not be something you want to do with a lot of data in your array unless you know their effect.

 

mdcmd status  <-- gets a status report of the diaks in the array

mdcmd check    <-- starts a parity check

mdcmd nocheck  <-- stops a running parity check

mdcmd stop    <-- stops the unRAID array.  But beware, you must FIRST stop samba AND unmount all the disks before issuing.

 

I do remember seeing mdcmd commands in the code to artificially simulate a read or write failure on a specific disk.  I've never experimented with those, nor with the ones to artificially make the disks look much smaller. 

 

Also be aware, Tom has noted that the mdcmd status command is NOT thread safe.  In other words, it is possible to issue it when the md driver is doing something else and to get it confused.  See this thread: http://lime-technology.com/forum/index.php?topic=1569.0  I would suggest only experimenting on a test server, where you do not have data that is important.  Too easy to accidentally invoke a command that causes data to end up corrupted.

 

Joe L.

Link to comment

 

I know about ...

   poweroff (powers down the unRAID server)  <-- this is a shell scrip that DOES NOT cleanly stop the unRAID array.  It is part of slackware unix

   mdcmd set invalidslot 99 (tells raid to assume that parity is valid and starts parity check rather than parity rebuild with next array start)

-<-- this is NOt as you describe.  It sets the invalid slot in the array to a slot other than 0.  It is valid only after you have deleted the super.dat file (which in effect, invalidates slot 0 (parity))  Its use could cause all kinds of errors if used at the wrong time or cause your array to become un-recoverable if it had a failed disk.

   /proc/mdcmd (text file containing unRAID status)  <- this is NOT a text file... it is a special file in the /proc file system used to communicate with the "md" driver.

   echo "status">/proc/mdcmd (request for unRAID to refresh the /proc/mdcmd file - seems to happen instantly)

   sync (not an unRAID command, but causes OS to dump buffers to disk.  Otherwise buffers can stay unwritten for a VERY long time) <-- almost true.  It asks the OS to schedule a dump of the buffers.  It could still take a long time before it acts on that schedule to dump them.

 

 

Have fun...

Joe L.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.