From b71de6b53716e7c7d2670b88de09aa7db7f4e547 Mon Sep 17 00:00:00 2001 From: Niclas Berglind Date: Wed, 15 Oct 2014 20:53:13 +0200 Subject: [PATCH] Create GPT label before creating/expanding pools. Signed-off-by: Niclas Berglind --- gui/rpc/zfs.inc | 6 ++++++ src/Utils.php | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/gui/rpc/zfs.inc b/gui/rpc/zfs.inc index 9ab61a2..22011e4 100644 --- a/gui/rpc/zfs.inc +++ b/gui/rpc/zfs.inc @@ -79,6 +79,9 @@ class OMVRpcServiceZFS extends OMVRpcServiceAbstract { } $disks = preg_split("/[,;]/", $params['devices']); + foreach ($disks as $disk) { + OMVModuleZFSUtil::setGPTLabel($disk); + } //Use /dev/disk/by-path as suggested in ZoL FAQ. if ($params['diskpath']) { try { @@ -583,6 +586,9 @@ class OMVRpcServiceZFS extends OMVRpcServiceAbstract { $opts .= "-f "; } $disks = preg_split("/[,;]/", $params['devices']); + foreach ($disks as $disk) { + OMVModuleZFSUtil::setGPTLabel($disk); + } //Use /dev/disk/by-path as suggested in ZoL FAQ. if ($params['diskpath']) { try { diff --git a/src/Utils.php b/src/Utils.php index c7049dc..4ccf60f 100644 --- a/src/Utils.php +++ b/src/Utils.php @@ -11,6 +11,16 @@ require_once("Zpool.php"); */ class OMVModuleZFSUtil { + /** + * Sets a GPT label on a disk to prevent the zpool command from generating + * errors. + * + */ + public static function setGPTLabel($disk) { + $cmd = "parted " . $disk . " mklabel gpt 2>&1"; + OMVModuleZFSUtil::exec($cmd,$out,$res); + } + /** * Manages relocation of ZFS filesystem mountpoints in the OMV backend. * Needed when the user changes mountpoint of a filesystem in the GUI. -- 2.39.2