Menu="Main:5"
Title="Array Operation"
Tag="snowflake-o"
---
<?PHP
/* Copyright 2005-2017, Lime Technology
 * Copyright 2012-2017, Bergware International.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License version 2,
 * as published by the Free Software Foundation.
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 */
?>
<?
function maintenance_mode() {
  echo "<tr>";
  echo "<td></td>";
  echo "<td><input type='checkbox' name='startMode' value='Maintenance'>Maintenance mode</td>";
  echo "<td><strong>Maintenance mode</strong> - if checked, Start array but do not mount disks.</td>";
  echo "</tr>";
}
function status_indicator() {
  global $var;
  $ball = "/webGui/images/{$var['mdColor']}.png";
  switch ($var['mdColor']) {
   case 'green-on': $help = 'Started, array protected'; break;
   case 'green-blink': $help = 'Stopped'; break;
   case 'yellow-on': $help = 'Started, array unprotected'; break;
   case 'yellow-blink': $help = 'Stopped'; break;
  }
  return "<a class='info nohand' onclick='return false'><img src='$ball' class='icon'><span>$help</span></a>";
}
?>
<script>
var ask1 = <?=$confirm['stop'] ? 'true' : 'false'?>;
var ask2 = <?=$confirm['down'] ? 'true' : 'false'?>;
var ctrl = "<span class='status'><a style='cursor:pointer' class='tooltip_diskio' title='Toggle reads/writes display' onclick='toggle_diskio();return false'><i class='toggle fa'></i></a></span>";

function tab0() {
  $.removeCookie('one',{path:'/'});
  $.cookie('tab','tab0',{path:'/'});
}
function parity_status() {
  $.post('/webGui/include/DeviceList.php',{path:'<?=$path?>',device:'parity'},function(data) {
    if (data) {$.each(data.split(';'),function(k,v) {if ($('#line'+k).length>0) $('#line'+k).html(v);});}
<?if ($tabbed):?>
    if ($('#tab'+$('input[name$="tabs"]').length).is(':checked')) timer = setTimeout(parity_status,3000);
<?else:?>
    setTimeout(parity_status,3000);
<?endif;?>
    if (!data && $('#cancelButton').length>0 && $('#cancelButton').val()=='Cancel') {
      $('#cancelButton').val('Done').unbind().bind({click:function(){refresh();}});
      $('#cancelText').html('');
      $('#line4').html('completed');
    }
  });
}
function parity_warning(form) {
<?if (strpos($disks['parity2']['status'],'_NP')===false):?>
  var text = '<i>Dual parity valid</i> requires <b>ALL</b> disks in their original slots';
<?else:?>
  var text = '<i>Parity valid</i> requires <b>ALL</b> disks to have their original content';
<?endif;?>
  $('<input>').attr({type:'hidden',name:'cmdStart',value:'submit'}).appendTo($(form));
  if (form.md_invalidslot.checked) {
    swal({title:'Proceed to start',text:text,html:true,type:'warning',confirmButtonText:'Proceed',confirmButtonColor:'#FFFFFF',showCancelButton:true},function(){form.submit();});
  } else {
    form.submit();
  }
}
function stop_array(form) {
  $(form).append('<input type="hidden" name="cmdStop" value="Stop">');
  if (ask1) {
    swal({title:'Proceed?',text:'This will stop the array',type:'warning',showCancelButton:true},function(p){if (p) form.submit(); else $('input[name="cmdStop"]').remove();});
  } else {
    form.submit();
  }
}
function stop_parity(form,text) {
  $(form).append('<input type="hidden" name="cmdNoCheck" value="Cancel">');
  if (ask1) {
    swal({title:'Proceed?',text:'This will stop the running '+text+' operation',type:'warning',showCancelButton:true},function(p){if (p) form.submit(); else $('input[name="cmdNoCheck"]').remove();});
  } else {
    form.submit();
  }
}
function shut_down(form,cmd) {
  $(form).append('<input type="hidden" name="cmd" value="'+cmd+'">');
  if (ask2) {
    swal({title:'Proceed?',text:'This will '+cmd+' the system',type:'warning',showCancelButton:true},function(p){if (p) form.submit(); else $('input[name="cmd"]').remove();});
  } else {
    form.submit();
  }
}
parity_status();

<?if ($tabbed):?>
$('.tabs').append(ctrl);
if ($.cookie('tab')=='tab0') $('i.toggle').hide();
$('#tab'+$('input[name$="tabs"]').length).bind({click:function() {clearTimeout(timer); parity_status(); tab0(); $('i.toggle').hide('slow');}});
<?else:?>
$('div[id=title]:not(":last, .disable_diskio")').each(function(){$(this).append(ctrl);});
<?endif;?>
<?if (substr($var['fsState'],-3)=='ing'):?>
function reload_page() {
  $.get('/webGui/include/ReloadPage.php',function(data) {
    switch (data) {
    case 'wait':
      setTimeout(reload_page,10000);
    break;
    case 'stop':
      setTimeout(refresh,0);
    break;
    default:
      if (data) $('#fsState').html(data);
      setTimeout(reload_page,3000);
    break;
    }
  });
}
reload_page();
<?endif;?>
$('.tooltip_diskio').tooltipster({delay:100, trigger:'custom', triggerOpen:{mouseenter: true}, triggerClose:{click:false,scroll:true,mouseleave:true}});
toggle_diskio(true);
</script>
<form name="arrayOps" method="POST" action="/update.htm" target="progressFrame">
<input type="hidden" name="startState" value="<?=htmlspecialchars($var['mdState'])?>">
<table class="array_status">
<?$parity = $var['mdResync']>0 ? '<small>Disabled -- Parity operation is running</small>' : '';
  $mover = file_exists('/var/run/mover.pid') ? '<small>Disabled -- Mover is running</small>' : '';
  switch ($var['fsState']):
  case "Started":?>
    <tr>
    <td><?=status_indicator()?><span class="strong big">Started<?=(($var['startMode']=='Maintenance')?' - Maintenance Mode':'')?></span></td>
    <td><input type="button" value="Stop" onclick="stop_array(this.form)"<?if ($parity||$mover):?> disabled<?endif;?>></td>
    <td><strong>Stop</strong> will take the array off-line.<?=$parity?"<br>$parity":($mover?"<br>$mover":"")?></td>
    </tr>
<?  if ($var['fsNumUnmountable']>0):?>
      <tr>
      <td><strong>Unmountable disk<?=$var['fsNumUnmountable']==1?'':'s'?> present:</strong><br>
<?    foreach ($disks as $disk) if (strstr($disk['fsStatus'],'Unmountable')) echo "<br><span class='blue-text'>".my_disk($disk['name'])."</span> &bullet; ".my_id($disk['id'])." (".$disk['device'].")";?></td>
      <td><input type="submit" id="cmdFormat" name="cmdFormat" value="Format" disabled><input type="hidden" name="unmountable_mask" value="<?=$var['fsUnmountableMask']?>"></td>
      <td><strong>Format</strong> will create a file system in all <strong>Unmountable</strong> disks, discarding all data currently on those disks.<br>
      <input type="checkbox" name="confirmFormat" value="OFF" onClick="arrayOps.cmdFormat.disabled=!arrayOps.confirmFormat.checked"><small>Yes I want to do this</small>
      </td>
      </tr>
<?  endif;
    if (!$parity):
      if (strstr($var['mdResyncAction'],"recon")):?>
        <tr>
        <td></td>
        <td><input type="submit" name="cmdCheck" value="Sync"></td>
        <td><strong>Sync</strong> will start <strong>Parity-Sync</strong> and/or <strong>Data-Rebuild</strong>.</td>
        </tr>
<?    elseif (strstr($var['mdResyncAction'],"clear")):?>
        <tr>
        <td></td>
        <td><input type="submit" name="cmdCheck" value="Clear"></td>
        <td><strong>Clear</strong> will start <strong>Clearing</strong> new data disk(s).</td>
        </tr>
<?    else:
        if ($var['mdResyncAction']=="check"):?>
          <tr>
          <td></td>
          <td><input type="submit" name="cmdCheck" value="Check"></td>
          <td><strong>Check</strong> will start <strong>Read-Check</strong> of all data disks.</td>
          </tr>
<?      elseif (strstr($var['mdResyncAction'],"check")):?>
          <tr>
          <td>Parity is valid.</td>
          <td><input type="submit" name="cmdCheck" value="Check"></td>
          <td><strong>Check</strong> will start <strong>Parity-Check</strong>.
          <br><input type="checkbox" name="optionCorrect" value="correct" checked><small>Write corrections to parity</small></td>
          </tr>
<?      endif;
        if ($var['sbSyncExit']!=0):?>
          <tr>
          <td></td>
          <td><input type="button" value="History" onclick="openBox('/webGui/include/ParityHistory.php','Parity/Read-Check History',600,540,false)"></td>
          <td>Last check incomplete on <strong><?=my_time($var['sbSynced2']).day_count($var['sbSynced2'])?></strong><?if ($var['sbSynced2']):?>, finding <strong><?=$var['sbSyncErrs']?></strong> error<?=$var['sbSyncErrs']==1?'':'s'?>.<?endif;?>
          <br><i class="fa fa-dot-circle-o icon"></i><small>Error code: <?=my_error($var['sbSyncExit'])?></small></td>
          </tr>
<?      elseif ($var['sbSynced']==0):?>
          <tr>
          <td></td>
          <td><input type="button" value="History" onclick="openBox('/webGui/include/ParityHistory.php','Parity/Read-Check History',600,540,false)"></td>
          <td>Last checked on <strong><?=my_time(0).day_count(0)?></strong>
          <br><i class="fa fa-clock-o icon"></i><small>Duration: <?=my_check(0,0)?></small></td>
          </tr>
<?      elseif ($var['sbSynced2']==0):?>
          <tr>
          <td></td>
          <td><input type="button" value="History" onclick="openBox('/webGui/include/ParityHistory.php','Parity/Read-Check History',600,540,false)"></td>
<?        list($entry,$duration,$speed,$status,$error) = explode('|', read_parity_log($var['sbSynced']));
          if ($status==0):?>
            <td>Last checked on <strong><?=my_time($var['sbSynced']).day_count($var['sbSynced'])?></strong>, finding <strong><?=$error?></strong> error<?=$error==1?'':'s'?>.
            <br><i class="fa fa-clock-o icon"></i><small>Duration: <?=my_check($duration,$speed)?></small>
<?        else:?>
            <td>Last check incomplete on <strong><?=my_time($var['sbSynced']).day_count($var['sbSynced'])?></strong>, finding <strong><?=$error?></strong> error<?=$error==1?'':'s'?>.
            <br><i class="fa fa-dot-circle-o icon"></i><small>Error code: <?=$status?></small>
<?        endif;?>
          </td></tr>
<?      else:
          $duration = $var['sbSynced2']-$var['sbSynced'];
          $speed = $duration?my_scale($var['mdResyncSize']*1024/$duration,$unit,1)." $unit/sec":'';?>
          <tr>
          <td></td>
          <td><input type="button" value="History" onclick="openBox('/webGui/include/ParityHistory.php','Parity/Read-Check History',600,540,false)"></td>
          <td>Last check completed on <strong><?=my_time($var['sbSynced2']).day_count($var['sbSynced2'])?></strong>, finding <strong><?=$var['sbSyncErrs']?></strong> error<?=$var['sbSyncErrs']==1?'':'s'?>.
          <br><i class="fa fa-clock-o icon"></i><small>Duration: <?=my_check($duration,$speed)?></small></td>
          </tr>
<?      endif;
      endif;
    else:
      if ($var['mdResyncAction']=="check"):?>
        <tr>
        <td>Read-Check in progress.</td>
        <td><input type="button" id="cancelButton" value="Cancel" onclick="stop_parity(this.form,'Read-Check')"></td>
        <td id="cancelText"><strong>Cancel</strong> will stop the Read-Check.</td>
        </tr>
<?    elseif (strstr($var['mdResyncAction'],"check")):?>
        <tr>
        <td>Parity-Check in progress.</td>
        <td><input type="button" id="cancelButton" value="Cancel" onclick="stop_parity(this.form,'Parity-Check')"></td>
        <td id="cancelText"><strong>Cancel</strong> will stop the Parity-Check.</td>
        </tr>
<?    elseif (strstr($var['mdResyncAction'],"recon")):?>
        <tr>
        <td>Parity-Sync/Data-Rebuild in progress.</td>
        <td><input type="button" id="cancelButton" value="Cancel" onclick="stop_parity(this.form,'Parity-Sync/Data-Rebuild')"></td>
        <td id="cancelText"><strong>Cancel</strong> will stop Parity-Sync/Data-Rebuild.
        <br>WARNING: canceling may leave the array unprotected!</td>
        </tr>
<?    elseif (strstr($var['mdResyncAction'],"clear")):?>
        <tr>
        <td>Clearing in progress.</td>
        <td><input type="button" id="cancelButton" value="Cancel" onclick="stop_parity(this.form,'Clearing')"></td>
        <td id="cancelText"><strong>Cancel</strong> will stop Clearing.</td>
        </tr>
<?    endif;?>
      <tr>
      <td>Total size:</td>
      <td id="line0"></td>
      <td></td>
      </tr>
      <tr>
      <td>Elapsed time:</td>
      <td id="line1"></td>
      <td></td>
      </tr>
      <tr>
      <td>Current position:</td>
      <td id="line2"></td>
      <td></td>
      </tr>
      <tr>
      <td>Estimated speed:</td>
      <td id="line3"></td>
      <td></td>
      </tr>
      <tr>
      <td>Estimated finish:</td>
      <td id="line4"></td>
      <td></td>
      </tr>
<?    if (strstr($var['mdResyncAction'],"check ")):?>
        <tr>
        <td>Sync errors <?if ($var['mdResyncCorr']==0):?>detected:<?else:?>corrected:<?endif;?></td>
        <td id="line5"></td>
        <td></td>
        </tr>
<?    endif;
    endif;
    break;
  case "Mounting":?>
    <tr>
    <td><?=status_indicator()?><span class="strong big">Starting...</span></td>
    <td><input type="submit" name="cmdStart" value="Start" disabled></td>
    <td></td>
    </tr>
<?  break;
  case "Formatting":?>
    <tr>
    <td><?=status_indicator()?><span class="strong big">Started, formatting...</span></td>
    <td><input type="submit" name="cmdStart" value="Start" disabled></td>
    <td></td>
    </tr>
<?  break;
  case "Copying":?>
    <tr>
    <td><?=status_indicator()?><span id="fsState" class="strong big">Copying, <?=$var['fsCopyPrcnt']?>% complete...</span></td>
    <td><input type="submit" name="cmdNoCopy" value="Cancel"></td>
    <td></td>
    </tr>
<?  break;
  case "Clearing":?>
    <tr>
    <td><?=status_indicator()?><span id="fsState" class="strong big">Clearing, <?=$var['fsClearPrcnt']?>% complete...</span></td>
    <td><input type="submit" name="cmdNoClear" value="Cancel"></td>
    <td></td>
    </tr>
<?  break;
  case "Stopping":?>
    <tr>
    <td><?=status_indicator()?><span class="strong big">Stopping...</span></td>
    <td><input type="submit" name="cmdStop" value="Stop" disabled></td>
    <td></td>
    </tr>
<?  break;
  case "Stopped":
    if ($var['configValid']=="error"):?>
      <tr>
      <td><?=status_indicator()?><span class="strong big">Stopped.</span></td>
      <td><input type="submit" name="cmdStart" value="Start" disabled></td>
      <td>Invalid, missing or expired <a href="/Tools/Registration">registration key</a>.</td>
      </tr>
<?  elseif ($var['configValid']=="invalid"):?>
      <tr>
      <td><?=status_indicator()?><span class="strong big">Stopped.</span></td>
      <td><input type="submit" name="cmdStart" value="Start" disabled></td>
      <td>Too many attached devices. Please consider upgrading your <a href="/Tools/Registration">registration key</a>.</td>
      </tr>
<?  elseif ($var['configValid']=="nokeyserver"):?>
      <tr>
      <td><?=status_indicator()?><span class="strong big">Stopped.</span></td>
      <td><input type="submit" name="cmdStart" value="Start" disabled></td>
      <td>Cannot contact key-server.  Please check your <a href="/Settings/NetworkSettings">network settings</a>.</td>
      </tr>
<?  elseif ($var['configValid']=="withdrawn"):?>
      <tr>
      <td><?=status_indicator()?><span class="strong big">Stopped.</span></td>
      <td><input type="submit" name="cmdStart" value="Start" disabled></td>
      <td>This unRAID Server OS release has been withdrawn and may no longer be used. Please <a href="/Plugins">update</a> your server.</td>
      </tr>
<?  else:
    switch ($var['mdState']):
    case "STOPPED":
      if (strstr($var['mdResyncAction'],"recon")):?>
        <tr>
        <td><?=status_indicator()?><span class="strong big">Stopped</span>. Configuration valid.</td>
        <td><input type="submit" name="cmdStart" value="Start"></td>
        <td><strong>Start</strong> will bring the array on-line and start <strong>Parity-Sync</strong> and/or <strong>Data-Rebuild</strong>.</td>
        </tr>
<?    elseif ($var['mdResyncAction']=="clear"):?>
        <tr>
        <td><?=status_indicator()?><span class="strong big">Stopped</span>. New data disk(s) detected.</td>
        <td><input type="submit" name="cmdStart" value="Start"></td>
        <td><strong>Start</strong> will bring the array on-line and start <strong>Clearing</strong> new data disk(s).</td>
        </tr>
<?    elseif ($var['sbClean']!="yes" && $var['mdResyncAction']=="check"):?>
        <tr>
        <td><?=status_indicator()?><span class="strong big">Stopped</span>. Unclean shutdown detected.</td>
        <td><input type="submit" name="cmdStart" value="Start"></td>
        <td><strong>Start</strong> will bring the array on-line.</td>
        </tr>
<?    elseif ($var['sbClean']!="yes" && strstr($var['mdResyncAction'],"check")):?>
        <tr>
        <td><?=status_indicator()?><span class="strong big">Stopped</span>. Unclean shutdown detected.</td>
        <td><input type="submit" name="cmdStart" value="Start"></td>
        <td><strong>Start</strong> will bring the array on-line and start <strong>Parity-Check</strong>.
        <br><input type="checkbox" name="optionCorrect" value="correct" checked><small>Write corrections to parity</small></td>
        </tr>
<?    else:?>
        <tr>
        <td><?=status_indicator()?><span class="strong big">Stopped</span>. Configuration valid.</td>
        <td><input type="submit" name="cmdStart" value="Start"></td>
        <td><strong>Start</strong> will bring the array on-line.</td>
        </tr>
<?    endif;
      maintenance_mode();
      break;
    case "NEW_ARRAY":
      if (strpos($disks['parity']['status'],"DISK_NP")===0 && (empty($disks['parity2']) || strpos($disks['parity2']['status'],"DISK_NP")===0)):?>
        <tr>
        <td><?=status_indicator()?><span class="strong big">Stopped</span>. Configuration valid.</td>
        <td><input type="submit" name="cmdStart" value="Start"></td>
        <td><strong>Start</strong> will record all disk information and bring the array on-line.
        <br>The array will be immediately available, but <strong>unprotected</strong> since <em>parity</em> has not been assigned.</td>
        </tr>
<?    else:?>
        <tr>
        <td><?=status_indicator()?><span class="strong big">Stopped</span>. Configuration valid.</td>
        <td><input type="button" value="Start" onclick="parity_warning(this.form)"></td>
        <td><strong>Start</strong> will record all disk information, bring the array on-line, and start Parity-Sync.
        <br>The array will be immediately available, but <strong>unprotected</strong> until Parity-Sync completes.
        <br><input type="checkbox" name="md_invalidslot" value="99">Parity is already valid.</td>
        </tr>
<?    endif;
      maintenance_mode();
      break;
    case "UNPROTECTED_EXPANSION":?>
      <tr>
      <td><?=status_indicator()?><span class="strong big">Stopped</span>. Found <?=my_word($var['mdNumNew'])?> new disk<?=$var['mdNumNew']==1?'':'s'?>.<br>
<?    foreach ($disks as $disk) if ($disk['status']=='DISK_NEW') echo "<br><span class='blue-text'>".my_disk($disk['name'])."</span> &bullet; ".my_id($disk['id'])." (".$disk['device'].")";?></td>
      <td><input type="submit" name="cmdStart" value="Start"></td>
      <td><strong>Start</strong> will record the new disk<?=$var['mdNumNew']==1?'':'s'?> information and bring the expanded array on-line.</td>
      </tr>
<?    maintenance_mode();
      break;
    case "PROTECTED_EXPANSION":
      if ($var['mdNumErased']==$var['mdNumNew']):?>
        <tr>
        <td><?=status_indicator()?><span class="strong big">Stopped</span>. Found <?=my_word($var['mdNumNew'])?> new erased disk<?=$var['mdNumNew']==1?'':'s'?>.<br>
<?      foreach ($disks as $disk) if ($disk['status']=='DISK_NEW') echo "<br><span class='blue-text'>".my_disk($disk['name'])."</span> &bullet; ".my_id($disk['id'])." (".$disk['device'].")";?></td>
        <td><input type="submit" name="cmdStart" value="Start" disabled></td>
        <td><strong>Start</strong> will record the new disk<?=$var['mdNumNew']==1?'':'s'?> information and bring the expanded array on-line.
        <br><input type="checkbox" name="confirmStart" value="OFF" onClick="arrayOps.cmdStart.disabled=!arrayOps.confirmStart.checked"><small>Yes I want to do this</small></td>
        </tr>
<?      maintenance_mode();
      else:?>
        <tr>
        <td><?=status_indicator()?><span class="strong big">Stopped</span>. Found <?=my_word($var['mdNumNew'])?> new disk<?=$var['mdNumNew']==1?'':'s'?>.<br>
<?      foreach ($disks as $disk) if ($disk['status']=='DISK_NEW') echo "<br><span class='blue-text'>".my_disk($disk['name'])."</span> &bullet; ".my_id($disk['id'])." (".$disk['device'].")";?></td>
        <td><input type="submit" name="cmdClear" value="Clear" disabled></td>
        <td><strong>Clear</strong> will completely clear (set to zero) the new disk<?=$var['mdNumNew']==1?'':'s'?>.
        <br>Once clear completes, the array may be Started, expanding the array to include the new disk<?=$var['mdNumNew']==1?'':'s'?>.
        <br><strong>Caution: any data on the new disk<?=$var['mdNumNew']==1?'':'s'?> will be erased!</strong>
        <br>If you want to preserve the data on the new disk<?=$var['mdNumNew']==1?'':'s'?>, reset the array configuration and rebuild parity instead.
        <br><input type="checkbox" name="confirmClear" value="OFF" onClick="arrayOps.cmdClear.disabled=!arrayOps.confirmClear.checked"><small>Yes I want to do this</small></td>
        </tr>
<?    endif;
      break;
    case "DISABLE_DISK":?>
      <tr>
      <td><?=status_indicator()?><span class="strong big">Stopped</span>. Missing disk.</td>
      <td><input type="submit" name="cmdStart" value="Start" disabled></td>
      <td><strong>Start</strong> will disable the missing disk and then bring the array on-line.
      <br>Install a replacement disk as soon as possible.
      <br><input type="checkbox" name="confirmStart" value="OFF" onClick="arrayOps.cmdStart.disabled=!arrayOps.confirmStart.checked"><small>Yes I want to do this</small></td>
      </tr>
<?    maintenance_mode();
      break;
    case "RECON_DISK":?>
      <tr>
      <td><?=status_indicator()?><span class="strong big">Stopped</span>. Replacement disk installed.</td>
      <td><input type="submit" name="cmdStart" value="Start" disabled></td>
      <td><strong>Start</strong> will start <strong>Parity-Sync</strong> and/or <strong>Data-Rebuild</strong>.
      <br><input type="checkbox" name="confirmStart" value="OFF" onClick="arrayOps.cmdStart.disabled=!arrayOps.confirmStart.checked"><small>Yes I want to do this</small></td>
      </tr>
<?    maintenance_mode();
      break;
    case "SWAP_DSBL":
      if ($var['fsCopyPrcnt']=="100"):?>
        <tr>
        <td><?=status_indicator()?><span class="strong big">Stopped</span>. Ugrading disk/swapping parity.</td>
        <td><input type="submit" name="cmdStart" value="Start" disabled></td>
        <td><strong>Start</strong> will expand the file system of the data disk (if possible); then bring the array on-line and start Data-Rebuild.
        <br><input type="checkbox" name="confirmStart" value="OFF" onClick="arrayOps.cmdStart.disabled=!arrayOps.confirmStart.checked"><small>Yes I want to do this</small></td>
        </tr>
<?      maintenance_mode();
      else:?>
        <tr>
        <td><?=status_indicator()?><span class="strong big">Stopped</span>. Ugrading disk/swapping parity.</td>
        <td><input type="submit" name="cmdCopy" value="Copy" disabled></td>
        <td><strong>Copy</strong> will copy the parity information to the new <em>parity</em> disk.
        <br>Once copy completes, the array may be Started, to initiate Data-Rebuild of the disabled disk.
        <br><input type="checkbox" name="confirmStart" value="OFF" onClick="arrayOps.cmdCopy.disabled=!arrayOps.confirmStart.checked"><small>Yes I want to do this</small></td>
        </tr>
<?    endif;
      break;
    case "RECORD_DISKS":?>
      <tr>
      <td><?=status_indicator()?><span class="strong big">Stopped</span>. Two or more disks are wrong.<br>
<?    foreach ($disks as $disk) if ($disk['status']=='DISK_WRONG') echo "<br><span class='blue-text'>".my_disk($disk['name'])."</span> &bullet; ".my_id($disk['id'])." (".$disk['device'].")";?></td>
      <td><input type="submit" name="cmdStart" value="Start" disabled></td>
      <td><strong>Start</strong> will just record the new disk positions and bring the array on-line.
      <br>We recommend you start a Parity-Check afterwards just to be safe.
      <br><input type="checkbox" name="confirmStart" value="OFF" onClick="arrayOps.cmdStart.disabled=!arrayOps.confirmStart.checked"><small>Yes I want to do this</small></td>
      </tr>
<?    maintenance_mode();
      break;
    case "ERROR:INVALID_EXPANSION":?>
      <tr>
      <td><?=status_indicator()?><span class="strong big">Stopped</span>. Invalid expansion.</td>
      <td><input type="submit" name="cmdStart" value="Start" disabled></td>
      <td>You may not add new disk(s) and also remove existing disk(s).</td>
      </tr>
<?    break;
    case "ERROR:NEW_DISK_TOO_SMALL":?>
      <tr>
      <td><?=status_indicator()?><span class="strong big">Stopped</span>. Replacement disk is too small.</td>
      <td><input type="submit" name="cmdStart" value="Start" disabled></td>
      <td>The replacement disk must be as big or bigger than the original.</td>
      </tr>
<?    break;
    case "ERROR:PARITY_NOT_BIGGEST":?>
      <tr>
      <td><?=status_indicator()?><span class="strong big">Stopped</span>. Disk in parity slot is not biggest.</td>
      <td><input type="submit" name="cmdStart" value="Start" disabled></td>
      <td>If this is a new array, move the largest disk into the <em>parity</em> slot.
      <br>If you are adding a new disk or replacing a disabled disk, try Parity-Swap.</td>
      </tr>
<?    break;
    case "ERROR:TOO_MANY_MISSING_DISKS":?>
      <tr>
      <td><?=status_indicator()?><span class="strong big">Stopped</span>. Invalid configuration.</td>
      <td><input type="submit" name="cmdStart" value="Start" disabled></td>
      <td>Too many wrong and/or missing disks!</td>
      </tr>
<?    break;
    case "ERROR:NO_DATA_DISKS":?>
      <tr>
      <td><?=status_indicator()?><span class="strong big">Stopped</span>. No data disks.</td>
      <td><input type="submit" name="cmdStart" value="Start" disabled></td>
      <td>No array data disks have been assigned!</td>
      </tr>
<?    break;
    endswitch;
  endif;
  endswitch;?>
  <tr><td></td><td class="line" colspan="2"></td></tr>
</table>
</form>
<?if ($var['fsState']=="Started"):?>
<form name="otherOps" method="POST" action="/update.htm" target="progressFrame">
<input type="hidden" name="startState" value="<?=$var['mdState']?>">
<table class="array_status">
  <tr>
  <td></td>
  <td><input type="submit" name="cmdSpindownAll" value="Spin Down"<?=$parity?' disabled':''?>><input type="submit" name="cmdSpinupAll" value="Spin Up"<?=$parity?' disabled':''?>></td>
  <td><strong>Spin Down</strong> will immediately spin down all disks.<br><strong>Spin Up</strong> will immediately spin up all disks.</td>
  </tr>
  <tr>
  <td></td>
  <td><input type="submit" name="clearStatistics" value="Clear Statistics"></td>
  <td><strong>Clear Statistics</strong> will immediately clear all disk statistics.</td>
  </tr>
</table>
</form>
<?if ($var['shareCacheEnabled']=="yes" && is_dir("/mnt/cache")):?>
<form name="mover_schedule" method="POST" action="/update.htm" target="progressFrame">
<table class="array_status">
  <tr><td colspan="3"></td></tr>
  <tr>
  <td></td>
<?if ($mover):?>
  <td><input type="submit" name="cmdStartMover" value="Move now" disabled></td><td>Mover is running.</td>
<?else:?>
  <td><input type="submit" name="cmdStartMover" value="Move now"></td><td>Click to invoke the Mover.</td>
<?endif;?>
  </tr>
</table>
</form>
<?endif;?>
<?endif;?>
<form name="shutdownOps" method="POST" action="/webGui/include/Boot.php">
<table class="array_status">
  <tr>
  <td></td>
  <td><input type="button" name="reboot" value="Reboot" onclick="shut_down(this.form,'reboot')"><input type="button" name="shutdown" value="Power down" onclick="shut_down(this.form,'shutdown')"></td>
  <td><strong>Reboot</strong> will activate a <em>clean</em> system reset.<br><strong>Power down</strong> will activate a <em>clean</em> power down.</td>
  </tr>
</table>
</form>
<?
if (isset($display['sleep'])) @include $display['sleep'];
?>

> **Colored Status Indicator** the significance of the color indicator of the *Array* is as follows:
>
> <img src='/webGui/images/green-on.png' class='icon'>Array is Started and Parity is valid.
>
> <img src='/webGui/images/green-blink.png' class='icon'>Array is Stopped, Parity is valid.
>
> <img src='/webGui/images/yellow-on.png' class='icon'>Array is Started, but Parity is invalid.
>
> <img src='/webGui/images/yellow-blink.png' class='icon'>Array is Stopped, Parity is invalid.
>

<?if ($var['fsState'] == "Stopped"):?>
> #### Assigning Devices
>
> An unRAID disk array consists of a single parity disk and a number of data disks. The data
> disks are exclusively used to store user data, and the parity disk provides the redundancy necessary
> to recover from any singe disk failure.
>
> Note that we are careful to use the term *disk* when referring to an array storage device.  We
> use the term *hard drive* (or sometimes just *drive*) when referring to an actual hard disk drive (HDD)
> device. This is because in a RAID system it is possible to read/write an array disk whose corresponding
> hard drive is disabled or even missing! In addition, it is useful to be able to ask, "which device is
> assigned to be the parity disk?"; or, "which device corresponds to disk2?".
>
> We therefore need a way to assign hard drives to array disks. This is accomplished here on the
> Main page when the array is stopped. There is a drop-down box for each array disk which lists all the
> unassigned devices. To assign a device simply select it from the list. Each time a device
> assignment is made, the system updates a configuration file to record the assignment.
>
> #### Requirements
>
> Unlike traditional RAID systems which stripe data across all the array devices, an unRAID server
> stores files on individual hard drives. Consequently, all file write operations will involve both the
> data disk the file is being written to, and the parity disk. For these reasons,
>
> * the parity disk size must be as large or larger than any of the data disks,
>
> and
>
> * given a choice, the parity disk should be the fastest disk in your collection.
>
> #### Guidelines
>
> Here are the steps you should follow when designing your unRAID disk array:
>
> 1. Decide which hard drive you will use for parity, and which hard drives you will use for
> data disk1, disk2, etc., and label them in some fashion. Also, find the serial number of each hard
> drive and jot it down somewhere; you will need this information later.
>
> 2. Install your hard drive devices, boot unRAID Server and bring up the webGui. If this is a fresh system
> build, then the Main page will show no disks installed. This doesn't mean the system can't detect your
> hard drives; it just means that none have been assigned yet.
>
> 3. Remember the serial numbers you recored back in step 1? For parity and each data disk, select the
> proper hard drive based on its serial number from the drop down list.
>
> #### Hot Plug
>
> You may also *hot plug* hard drives into your server if your hardware supports it. For example,
> if you are using hard drive cages, you may simply plug them into your server while powered on and
> with array Stopped. Refresh the Main page to have new unassigned devices appear in the assignment
> dropdown lists.
>
> #### Next Steps
>
> Once you have assigned all of your hard drives, refer to the Array Status section below
> and Start the array.
<?endif;?>
