From ba6ae34e8b49630fb2a2d7b236c588382ea15f1e Mon Sep 17 00:00:00 2001 From: dlandon Date: Fri, 18 Oct 2024 18:30:23 -0500 Subject: [PATCH 1/2] Add Update Pool button to zfs devices to update zfs volume to latest version. --- emhttp/plugins/dynamix/DeviceInfo.page | 43 +++++++++++++++- .../plugins/dynamix/include/zfs_upgrade.php | 51 +++++++++++++++++++ 2 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 emhttp/plugins/dynamix/include/zfs_upgrade.php diff --git a/emhttp/plugins/dynamix/DeviceInfo.page b/emhttp/plugins/dynamix/DeviceInfo.page index 92cd59bd0..dce6dc91d 100755 --- a/emhttp/plugins/dynamix/DeviceInfo.page +++ b/emhttp/plugins/dynamix/DeviceInfo.page @@ -111,6 +111,14 @@ function isPool($name) { global $pools; return in_array($name,$pools); } +/* Check to see if a pool has already been upgraded. */ +function is_upgraded_ZFS_pool($pool_name) { + + /* See if the pool is aready upgraded. */ + $upgrade = trim(shell_exec("/usr/sbin/zpool status ".escapeshellarg($pool_name)." | /usr/bin/grep 'Enable all features using.'") ?? ""); + + return ($upgrade ? false : true); +} ?> "> "> @@ -603,7 +611,7 @@ function eraseDisk(name) { text:"

_(Existing content is permanently lost)_

", html:true, type:'input', - inputPlaceholder:"", + inputPlaceholder:"", showCancelButton:true, closeOnConfirm:false, confirmButtonText:"_(Proceed)_", @@ -631,7 +639,7 @@ function deletePool(name) { text:"", html:true, type:'input', - inputPlaceholder:"", + inputPlaceholder:"", showCancelButton:true, closeOnConfirm:false, confirmButtonText:"_(Proceed)_", @@ -653,6 +661,34 @@ function deletePool(name) { } }); } +function upgradeZpool(name) { + swal({ + title:"_(Upgrade ZFS Pool)_?", + text:"_(This operation cannot be reversed)_. _(After upgrading the volume may not be mountable in previous versions of Unraid)_.

_(The ZFS volume will be upgraded)_

", + html:true, + type:'input', + inputPlaceholder:"", + showCancelButton:true, + closeOnConfirm:false, + confirmButtonText:"_(Proceed)_", + cancelButtonText:"_(Cancel)_" + }, + function(confirm){ + if (confirm == "") { + swal.close(); + $('#doneButton').prop('disabled',true); + $('#eraseButton').prop('disabled',true); + $('#deleteButton').prop('disabled',true); + $('div.spinner.fixed').show(); + $.post("/webGui/include/zfs_upgrade.php",{name:name},function(){ + $('div.spinner.fixed').hide(); + refresh(); + }); + } else { + if (confirm.length) swal({title:"_(Incorrect confirmation)_",text:"_(Please try again)_!",type:'error',html:true,confirmButtonText:"_(Ok)_"}); + } + }); +}
@@ -1090,6 +1126,9 @@ _(zfs pool status)_:   : + + + :info_zfs_scrub_help: diff --git a/emhttp/plugins/dynamix/include/zfs_upgrade.php b/emhttp/plugins/dynamix/include/zfs_upgrade.php new file mode 100644 index 000000000..0396ddb37 --- /dev/null +++ b/emhttp/plugins/dynamix/include/zfs_upgrade.php @@ -0,0 +1,51 @@ + + +/dev/null"; + exec($command, $output, $return_var); + + /* Check if the command was successful */ + if ($return_var === 0) { + my_logger("ZFS pool '$poolName' upgraded successfully."); + } else { + my_logger("Failed to upgrade ZFS pool '$poolName'."); + } + } else { + my_logger("ZFS pool '$poolName' is already upgraded."); + } +} else { + my_logger("No pool name provided."); +} + +?> From 0ee5caf8acacf6f2b88c4d48424de832fb17c273 Mon Sep 17 00:00:00 2001 From: dlandon Date: Fri, 18 Oct 2024 18:31:21 -0500 Subject: [PATCH 2/2] Add zfs update and additional btrfs scrub help text. --- emhttp/languages/en_US/helptext.txt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/emhttp/languages/en_US/helptext.txt b/emhttp/languages/en_US/helptext.txt index 33d9f9b77..02acad6d0 100644 --- a/emhttp/languages/en_US/helptext.txt +++ b/emhttp/languages/en_US/helptext.txt @@ -269,7 +269,14 @@ For more complete documentation, please refer to the btrfs-balance [Manpage](htt **Scrub** runs the *btrfs scrub* program which will read all data and metadata blocks from all devices and verify checksums. -If *Repair corrupted blocks* is checked, *btrfs scrub* will repair corrupted blocks if there’s a correct copy available. +*btrfs scrub* will repair corrupted blocks if there is a correct copy available. +:end + +:info_zfs_scrub_help: +**Scrub** runs the *zfs scrub* program which will read all data and metadata blocks from all +devices and verify checksums. + +Click the **Upgrade Pool** button to upgrade the ZFS pool to enable the latest ZFS features. :end :info_scrub_cancel_help: @@ -282,6 +289,10 @@ If *Repair corrupted blocks* is checked, *btrfs scrub* will repair corrupted blo The *Options* field is initialized with *--readonly* which specifies check-only. If repair is needed, you should run a second Check pass, setting the *Options* to *--repair*; this will permit *btrfs check* to fix the file system. +WARNING: **Do not use** *--repair* unless you are advised to do so by a developer or an experienced user, +and then only after having accepted that no fsck successfully repair all types of filesystem corruption. +E.g. some other software or hardware bugs can fatally damage a volume. + After starting a Check, you should Refresh to monitor progress and status. Depending on how large the file system is, and what errors might be present, the operation can take **a long time** to finish (hours). Not much info is printed in the window, but you can verify the operation is running by observing the read/write counters