From: Niclas Berglind Date: Wed, 15 Oct 2014 18:53:13 +0000 (+0200) Subject: Create GPT label before creating/expanding pools. X-Git-Url: http://git.datanom.net/omvzfs.git/commitdiff_plain/b71de6b53716e7c7d2670b88de09aa7db7f4e547 Create GPT label before creating/expanding pools. Signed-off-by: Niclas Berglind --- 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.