Menu="OtherSettings"
Title="Disk Settings"
Icon="disk-settings.png"
---
<?PHP
/* Copyright 2005-2016, Lime Technology
 * Copyright 2012-2016, 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.
 */
?>
<?
require_once "$docroot/webGui/include/Preselect.php";
$events = isset($var['smEvents']) ? explode('|', $var['smEvents']) : $numbers;

function displayTemp($temp) {
  global $display;
  return $display['unit']=='F' ? round(9/5*$temp)+32 : $temp;
}
?>
<script>
function doDispatch(form) {
  var fields = {};
<?if ($display['unit']=='F'):?>
  form.display_hot.value = Math.round((form.display_hot.value-32)*5/9);
  form.display_max.value = Math.round((form.display_max.value-32)*5/9);
<?endif;?>
  fields['#cfg'] = "/boot/config/plugins/dynamix/dynamix.cfg";
  $(form).find('input[name^="display_"]').each(function(){fields[$(this).attr('name')] = $(this).val(); $(this).prop('disabled',true);});
  $.post('/webGui/include/Dispatcher.php',fields);
}
function prepareDiskSettings(form) {
  var events = [];
  for (var i=0; i < <?=count($preselect)?>; i++) {
    if (form.elements['at'+i].checked) events.push(form.elements['at'+i].value);
    form.elements['at'+i].disabled = true;
  }
  var custom = form.smCustom.value.trim();
  var custom = custom.length ? custom.split(',') : [];
  for (var i=0; i < custom.length; i++) events.push(custom[i].trim());
  form.smEvents.value = events.join('|');
}
function setIndex(form) {
  form.smIndex.value = form.smType.selectedIndex;
}
</script>

<form markdown="1" method="POST" action="/update.htm" target="progressFrame" onsubmit="doDispatch(this)">
Enable auto start:
: <select name="startArray" size="1">
  <?=mk_option($var['startArray'], "no", "No")?>
  <?=mk_option($var['startArray'], "yes", "Yes")?>
  </select>

> If set to 'Yes' then if the device configuration is correct upon server start-up,
> the array will be automatically Started and shares exported.<br>
> If set to 'No' then you must Start the array yourself.

Default spin down delay:
: <select name="spindownDelay" size="1">
  <?=mk_option($var['spindownDelay'], "0",  "Never")?>
  <?=mk_option($var['spindownDelay'], "15", "15 minutes")?>
  <?=mk_option($var['spindownDelay'], "30", "30 minutes")?>
  <?=mk_option($var['spindownDelay'], "45", "45 minutes")?>
  <?=mk_option($var['spindownDelay'], "1",  "1 hour")?>
  <?=mk_option($var['spindownDelay'], "2",  "2 hours")?>
  <?=mk_option($var['spindownDelay'], "3",  "3 hours")?>
  <?=mk_option($var['spindownDelay'], "4",  "4 hours")?>
  <?=mk_option($var['spindownDelay'], "5",  "5 hours")?>
  <?=mk_option($var['spindownDelay'], "6",  "6 hours")?>
  <?=mk_option($var['spindownDelay'], "7",  "7 hours")?>
  <?=mk_option($var['spindownDelay'], "8",  "8 hours")?>
  <?=mk_option($var['spindownDelay'], "9",  "9 hours")?>
  </select>

> This setting defines the 'default' time-out for spinning hard drives down after a period
> of no I/O activity.  You may override the default value for an individual disk on the Disk Settings
> page for that disk.

Enable spinup groups:
: <select name="spinupGroups" size="1">
  <?=mk_option($var['spinupGroups'], "no", "No")?>
  <?=mk_option($var['spinupGroups'], "yes", "Yes")?>
  </select>

> If set to 'Yes' then the [Spinup Groups](/Help) feature is enabled.

Default partition format:
: <select name="defaultFormat" size="1">
  <?=mk_option($var['defaultFormat'], "1", "MBR: unaligned")?>
  <?=mk_option($var['defaultFormat'], "2", "MBR: 4K-aligned")?>
  </select>

> Defines the type of partition layout to create when formatting hard drives 2TB in size and
> smaller **only**. (All devices larger then 2TB are always set up with GPT partition tables.)
>
> **MBR: unaligned** setting will create MBR-style partition table, where the single
> partition 1 will start in the **63rd sector** from the start of the disk.  This is the *traditional*
> setting for virtually all MBR-style partition tables.
>
> **MBR: 4K-aligned** setting will create an MBR-style partition table, where the single
> partition 1 will start in the **64th sector** from the start of the disk. Since the sector size is 512 bytes,
> this will *align* the start of partition 1 on a 4K-byte boundry.  This is required for proper
> support of so-called *Advanced Format* drives.
>
> Unless you have a specific requirement do not change this setting from the default **MBR: 4K-aligned**.

Default file system:
: <select name="defaultFsType" size="1">
  <?=mk_option($var['defaultFsType'], "btrfs", "Btrfs");?>
  <?=mk_option($var['defaultFsType'], "reiserfs", "ReiserFS");?>
  <?=mk_option($var['defaultFsType'], "xfs", "XFS");?>
  </select>

> Defines the default file system type to create when an *unmountable* array device is formatted.
>
> The default file system type for a single or multi-device cache is always Btrfs.

Shutdown time-out:
: <input type="text" name="shutdownTimeout" maxlength="10" value="<?=$var['shutdownTimeout']?>" class="narrow">

> When shutting down the server, this defines how long to wait in seconds for *graceful* shutdown before forcing
> shutdown to continue.

Tunable (poll_attributes):
: <input type="text" name="poll_attributes" maxlength="10" value="<?=$var['poll_attributes']?>" class="narrow"><?=$var['poll_attributes_status']?>

> This defines the disk SMART polling interval, in seconds.  A value of 0 disables SMART polling (not recommended).

Tunable (enable NCQ):
: <select name="queueDepth" size="1">
  <?=mk_option($var['queueDepth'], "auto", "Auto")?>
  <?=mk_option($var['queueDepth'], "0", "Yes")?>
  <?=mk_option($var['queueDepth'], "1", "No")?>
  </select>

> If set to **Yes** then *Native Command Queuing* is enabled for all array devices that support NCQ.
>
> Note: After changing from **No** to **Yes** you must reboot the server for the change to take effect.  Changing
> from **Yes* to **No** however, takes effect immediately.
>
> Most users find that overall system performance is better with NCQ disabled.
>
> *Auto* selects `No`.

Tunable (nr_requests):
: <input type="text" name="nr_requests" maxlength="10" value="<?=$var['nr_requests']?>" class="narrow"><?=$var['nr_requests_status']?>

> This defines the `nr_requests` device driver setting for all array devices.

Tunable (md_num_stripes):
: <input type="text" name="md_num_stripes" maxlength="10" value="<?=$var['md_num_stripes']?>" class="narrow"><?=$var['md_num_stripes_status']?>

Tunable (md_sync_window):
: <input type="text" name="md_sync_window" maxlength="10" value="<?=$var['md_sync_window']?>" class="narrow"><?=$var['md_sync_window_status']?>

Tunable (md_sync_thresh):
: <input type="text" name="md_sync_thresh" maxlength="10" value="<?=$var['md_sync_thresh']?>" class="narrow"><?=$var['md_sync_thresh_status']?>

> These tunables let you control certain properties of the unRAID driver.
>
> Note: For each of these settings, if you set to blank and click Apply, the setting is restored to its default.

Tunable (md_write_method):
: <select name="md_write_method" size="1">
  <?=mk_option($var['md_write_method'], "auto", "Auto")?>
  <?=mk_option($var['md_write_method'], "0", "read/modify/write")?>
  <?=mk_option($var['md_write_method'], "1", "reconstruct write")?>
  </select>

> Selects the method to employ when writing to enabled disk in parity protected array.
>
> *Auto* selects `read/modify/write`.

Default warning disk utilization threshold (%):
: <input type="number" min="0" max="100" name="display_warning" class="narrow" value="<?=$display['warning']?>">

> *Warning disk utilization* sets the default warning threshold for all hard disks utilization. Exceeding this threshold will result in a warning notification.
>
> When the warning threshold is set equal or greater than the critical threshold, there will be only critical notifications (warnings are not existing).
>
> A value of zero will disable the warning threshold (including notifications).

Default critical disk utilization threshold (%):
: <input type="number" min="0" max="100" name="display_critical" class="narrow" value="<?=$display['critical']?>">

> *Critical disk utilization* sets the default critical threshold for all hard disks utilization. Exceeding this threshold will result in an alert notification.
>
> A value of zero will disable the critical threshold (including notifications).

Default warning disk temperature threshold (&deg;<?=$display['unit']?>):
: <input type="number" min="0" max="300" name="display_hot" class="narrow" value="<?=displayTemp($display['hot'])?>">

> *Warning disk temperature* sets the default warning threshold for all hard disks temperature. Exceeding this threshold will result in a warning notification.
>
> A value of zero will disable the warning threshold (including notifications).

Default critical disk temperature threshold (&deg;<?=$display['unit']?>):
: <input type="number" min="0" max="300" name="display_max" class="narrow" value="<?=displayTemp($display['max'])?>">

> *Critical disk temperature* sets the default critical threshold for all hard disks temperature. Exceeding this threshold will result in an alert notification.
>
> A value of zero will disable the critical threshold (including notifications).

&nbsp;
: <input type="submit" name="changeDisk" value="Apply"><input type="button" value="Done" onclick="done()">
</form>

<div id="title"><span class="left"><img src="/webGui/icons/smartchecks.png" class="icon">Global SMART Settings</span></div>

<form markdown="1" name="smart_settings" method="POST" action="/update.php" target="progressFrame" onsubmit="prepareDiskSettings(this)">
<input type="hidden" name="#file" value="/boot/config/smart-all.cfg">
<input type="hidden" name="#include" value="webGui/include/update.smart.php">
<input type="hidden" name="smEvents" value="">
<input type="hidden" name="smIndex" value="0">
Default SMART notification value:
: <select name="smSelect" size="1">
  <?=mk_option($var['smSelect'], "0", "Raw")?>
  <?=mk_option($var['smSelect'], "1", "Normalized")?>
  </select>

> SMART notifications are generated on either an increasing RAW value of the attribute, or a decreasing NORMALIZED value which reaches a predefined threshold set by the manufacturer.
>
> This section is used to set the global settings for all disks. It is possible to adjust settings for individual disks.

Default SMART notification tolerance level:
: <select name="smLevel" size="1">
  <?=mk_option($var['smLevel'], "1.00", "Absolute")?>
  <?=mk_option($var['smLevel'], "1.05", "5%")?>
  <?=mk_option($var['smLevel'], "1.10", "10%")?>
  <?=mk_option($var['smLevel'], "1.15", "15%")?>
  <?=mk_option($var['smLevel'], "1.20", "20%")?>
  <?=mk_option($var['smLevel'], "1.25", "25%")?>
  <?=mk_option($var['smLevel'], "1.50", "50%")?>
  </select>

> A tolerance level may be given to prevent that small changes result in a notification. Setting a too high tolerance level may result in critical changes without a notification.
>
> This section is used to set the global settings for all disks. It is possible to adjust settings for individual disks.

Default SMART controller type:
: <select name="smType" size="1" onchange="setIndex(this.form)">
  <?=mk_option($var['smType'], "", "Automatic")?>
  <?=mk_option($var['smType'], "-d ata", "ATA")?>
  <?=mk_option($var['smType'], "-d sat", "SATA")?>
  <?=mk_option($var['smType'], "-d scsi", "SCSI")?>
  <?=mk_option($var['smType'], "-d 3ware", "3Ware")?>
  <?=mk_option($var['smType'], "-d areca", "Areca")?>
  <?=mk_option($var['smType'], "-d hpt", "HighPoint")?>
  <?=mk_option($var['smType'], "-d marvell", "Marvell")?>
  <?=mk_option($var['smType'], "-d megaraid", "MegaRAID")?>
  </select>

> By default automatic controller selection is done by smartctl to read the SMART information. Certain controllers however need specific settings for smartctl to work.
> Use this setting to select your controller type and fill-in the specific disk index and device name for your situation. Use the manufacturer's documentation to find the relevant information.
>
> This section is used to set the global settings for all disks. It is possible to adjust settings for individual disks.

Default SMART attribute notifications:
: <input type="text" name="smCustom" value="<?=$var['smCustom']?>" class="narrow">Custom attributes (use comma to separate numbers)

  <?for ($x = 0; $x < count($preselect); $x++):?>
&nbsp;
: <input type="checkbox" name="at<?=$x?>" value="<?=$preselect[$x]['code']?>"<?=in_array($preselect[$x]['code'],$events)?' checked':''?>><span style="display:inline-block;width:136px"><?=$preselect[$x]['code']?></span><?=$preselect[$x]['text']?>
  <?endfor;?>

> The user can enable or disable notifications for the given SMART attributes. It is recommended to keep the default, which is ALL selected attributes,
> when certain attributes are not present on your hard disk or do not provide the correct information, these may be excluded.
> In addition custom SMART attributes can be entered to generate notifications. Be careful in this selection,
> it may cause an avalance of notifcations if inappropriate SMART attributes are chosen.
>
> This section is used to set the global settings for all disks. It is possible to adjust settings for individual disks.

<input type="submit" name="#default" value="Default">
: <input type="submit" name="#apply" value="Apply"><input type="button" value="Done" onclick="done()">
</form>
