mirror of
https://github.com/unraid/webgui.git
synced 2026-01-20 08:30:14 -06:00
Merge pull request #1286 from bergware/master
Add scheduled trimming of ZFS pools
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?PHP
|
||||
/* Copyright 2005-2022, Lime Technology
|
||||
* Copyright 2012-2022, Bergware International.
|
||||
/* Copyright 2005-2023, Lime Technology
|
||||
* Copyright 2012-2023, 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,
|
||||
@@ -20,6 +20,8 @@ if ($_POST['mode']>0) {
|
||||
$dotm = isset($_POST['dotm']) ? $_POST['dotm'] : '*';
|
||||
$day = isset($_POST['day']) ? $_POST['day'] : '*';
|
||||
$cron = "# Generated ssd trim schedule:\n$min $hour $dotm * $day /sbin/fstrim -a -v | logger &> /dev/null\n";
|
||||
exec("/usr/sbin/zpool status|grep -Po 'pool: \K.+'",$zfs_pools);
|
||||
foreach ($zfs_pools as $pool) if ($pool) $cron .= "$min $hour $dotm * $day /usr/sbin/zpool trim $pool 2> /dev/null\n";
|
||||
} else {
|
||||
$cron = "";
|
||||
}
|
||||
|
||||
@@ -38,8 +38,16 @@ function write(...$messages){
|
||||
}
|
||||
|
||||
write(_("SSD Trim started").". "._("Please wait")." ...\n");
|
||||
// trim btrfs pools
|
||||
$trim = popen('fstrim -a -v','r');
|
||||
while (!feof($trim)) write(fgets($trim));
|
||||
pclose($trim);
|
||||
|
||||
// trim zfs pools
|
||||
exec("/usr/sbin/zpool status|grep -Po 'pool: \K.+'",$zfs_pools);
|
||||
foreach ($zfs_pools as $pool) if ($pool) {
|
||||
exec("/usr/sbin/zpool trim $pool");
|
||||
write("ZFS pool: $pool trimmed\n");
|
||||
}
|
||||
write('_DONE_','');
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user