]> git.datanom.net - omvzfs.git/commitdiff
Use /dev/disk/by-path as default for new pools as suggested by ZoL FAQ.
authorNiclas Berglind <nb@kjam.se>
Tue, 16 Sep 2014 19:47:28 +0000 (21:47 +0200)
committerMichael Rasmussen <mir@datanom.net>
Tue, 16 Sep 2014 20:30:07 +0000 (22:30 +0200)
Signed-off-by: Niclas Berglind <nb@kjam.se>
gui/rpc/zfs.inc
src/Utils.php

index beaefa49e3e6b21921ca3bbbdd7f9ddd4d581d33..84fa26d9c481f0b5c08107862bce15ec313ae5ab 100644 (file)
@@ -63,7 +63,16 @@ class OMVRpcServiceZFS extends OMVRpcServiceAbstract {
                        $opts .= "-m " . $params['mountpoint'] . " ";
                }
 
+               //Use /dev/disk/by-path as deafult when creating new pools as suggested in ZoL FAQ.
                $disks = preg_split("/[,;]/", $params['devices']);
+               if (file_exists("/dev/disk/by-path/")) {
+                       $tmp_disks = array();
+                       foreach ($disks as $disk) {
+                               $tmp_disks[] = OMVModuleZFSUtil::getDiskPath($disk);
+                       }
+                       $disks = $tmp_disks;
+               }
+
                $vdev = new OMVModuleZFSVdev($params['name'], $pooltype, $disks);
                $pool = new OMVModuleZFSZpool($vdev, $opts);
                //Ugly fix to solve the problem of blkid not displaying info on newly created pools
index cc0814bdbc474f2383a9d7569c5ef2b88939cfb0..4d577f8d26c3039e7caf91ebadd192722cc85f56 100644 (file)
@@ -8,6 +8,22 @@ require_once("Dataset.php");
  */
 class OMVModuleZFSUtil {
 
+       /**
+        * Get /dev/disk/by-path from /dev/sdX
+        *
+        * @return string Disk identifier
+        */
+       public static function getDiskPath($disk) {
+               preg_match("/^.*\/([A-Za-z0-9]+)$/", $disk, $identifier);
+               $cmd = "ls -la /dev/disk/by-path | grep '$identifier[1]$'";
+               OMVModuleZFSUtil::exec($cmd, $out, $res);
+               if (is_array($out)) {
+                       $cols = preg_split('/[\s]+/', $out[0]);
+                       return($cols[count($cols)-3]);
+               }
+       }
+
+
        /**
         * Get poolname from name of dataset/volume etc.
         *
This page took 0.034847 seconds and 5 git commands to generate.