Detach device from mirrored boot pool
I can not find an opportunity to destroy mirrored boot device. The console provides this feature via 'zpool deatach' option.
This can be useful if one of mirrored boot device has unrecoverable error.
#4 Updated by Sean Fagan almost 4 years ago
- Assignee changed from Sean Fagan to Kris Moore
None at all, I'm utterly shocked it's not already there -- Corral had it.
I was convinced FN9 had it already but sure enough, all I can do is replace. Wow. I guess the thinking was, we shouldn't let people shoot themselves in the foot if they were already walking on two feet?
Detaching is far easier than attaching (no having to wait), but we'd want to handle the case where the selected device is not visible for some reason, and the case where the pool is degraded due to other reasons.
#7 Updated by Sean Fagan almost 4 years ago
First whack would be something like:
diff --git a/gui/middleware/notifier.py b/gui/middleware/notifier.py index 1ba2ed71f..e498a35b3 100755 --- a/gui/middleware/notifier.py +++ b/gui/middleware/notifier.py @@ -5485,6 +5485,14 @@ class notifier(metaclass=HookMetaclass): return True + def bootenv_detach_disk(self, label, devname): + """Remove a disk from the bool""" + + proc = self._pipeopen("/sin/zpool detach freenas-boot %sp2" % (devname, )) + err = proc.communicate() + if proc.returncode != 0: + raise MiddlewareError('Failed to detach disk: %s' % err) + def bootenv_replace_disk(self, label, devname): """Attach a new disk to the pool"""
But I'm not sure if that's entirely right. Note that it doesn't check pool status, verify the disk is in the pool, etc.
I'd also suggest it use libzfs instead of trying to parse the output of the zfs/zpool commands, but that's just me.