patch to improve use of ZFS volumes with vmrun.sh

John Dickinson jad at sinodun.com
Thu Jan 14 14:19:23 UTC 2016


Hi,

In case it is of use to anyone, here is a little patch to improve use of ZFS volumes with vmrun.sh


--- /usr/share/examples/bhyve/vmrun.sh	2015-08-12 15:27:20.000000000 +0000
+++ ./vmrun.sh	2016-01-14 13:17:27.972055736 +0000
@@ -166,11 +166,24 @@
 make_and_check_diskdev()
 {
     local virtio_diskdev="$1"
+    local ZVOL=0
     # Create the virtio diskdev file if needed
-    if [ ! -f ${virtio_diskdev} ]; then
+    case "${virtio_diskdev}" in
+        /dev/zvol/*) ZVOL=1 ;;
+    esac
+
+    if [ $ZVOL -eq 0 ]; then
+        if [ ! -f ${virtio_diskdev} ]; then
    	      echo "virtio disk device file \"${virtio_diskdev}\" does not exist."
             echo "Creating it ..."
             truncate -s 8G ${virtio_diskdev} > /dev/null
+        fi
+    else
+        if [ ! -c ${virtio_diskdev} ]; then
+            echo "virtio disk device volume \"${virtio_diskdev}\" does not exist."
+            echo "Please create it"
+            exit 1
+        fi
     fi
 
     if [ ! -r ${virtio_diskdev} ]; then


regards
John

John Dickinson

http://sinodun.com

Sinodun Internet Technologies Ltd.
Magdalen Centre
Oxford Science Park
Robert Robinson Avenue
Oxford OX4 4GA
U.K.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 842 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/freebsd-virtualization/attachments/20160114/e6d7abf5/attachment.sig>


More information about the freebsd-virtualization mailing list