]> git.datanom.net - omvzfs.git/commitdiff
Create GPT label before creating/expanding pools.
authorNiclas Berglind <nb@kjam.se>
Wed, 15 Oct 2014 18:53:13 +0000 (20:53 +0200)
committerMichael Rasmussen <mir@datanom.net>
Wed, 15 Oct 2014 19:58:52 +0000 (21:58 +0200)
Signed-off-by: Niclas Berglind <nb@kjam.se>
gui/rpc/zfs.inc
src/Utils.php

index 9ab61a2e7c8d60e844cd6bc2de8fa31374a7c971..22011e4ada941ab42311e14d103a9e052cff146a 100644 (file)
@@ -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 {
index c7049dc752a570042ac2cb799e15db8ea689f2c3..4ccf60f8f58b776dbcd48814d51ae7419040bb5f 100644 (file)
@@ -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.
This page took 0.033639 seconds and 5 git commands to generate.