Support blktype as an alternative to vol_id
authorGuido Trotter <ultrotter@google.com>
Mon, 19 Oct 2009 23:18:07 +0000 (19:18 -0400)
committerGuido Trotter <ultrotter@google.com>
Tue, 20 Oct 2009 15:50:51 +0000 (11:50 -0400)
This is needed to run when the node os is debian squeeze or ubuntu
karmik. Since blktype and vol_id need different options, we include the
options in the command variable. Moreover we add a new VOL_TYPE command,
for that usage of vol_id/blktype.

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

common.sh.in
create
export
import

index 2acab86..6c6c3b9 100644 (file)
@@ -160,15 +160,21 @@ CACHE_DIR="@localstatedir@/cache/ganeti-instance-debootstrap"
 
 SCRIPT_NAME=$(basename $0)
 
-for dir in /lib/udev /sbin; do
-  if [ -f $dir/vol_id -a -x $dir/vol_id ]; then
-    VOL_ID=$dir/vol_id
-  fi
-done
+if [ -f /sbin/blkid -a -x /sbin/blkid ]; then
+  VOL_ID="/sbin/blkid -o value -s UUID"
+  VOL_TYPE="/sbin/blkid -o value -s TYPE"
+else
+  for dir in /lib/udev /sbin; do
+    if [ -f $dir/vol_id -a -x $dir/vol_id ]; then
+      VOL_ID="$dir/vol_id -u"
+      VOL_TYPE="$dir/vol_id -t"
+    fi
+  done
+fi
 
 if [ -z "$VOL_ID" ]; then
-    log_error "vol_id not found, please install udev"
-    exit 1
+  log_error "vol_id or blkid not found, please install udev or util-linux"
+  exit 1
 fi
 
 if [ -z "$OS_API_VERSION" -o "$OS_API_VERSION" = "5" ]; then
diff --git a/create b/create
index 5933f0b..252a512 100755 (executable)
--- a/create
+++ b/create
@@ -49,11 +49,11 @@ else
 fi
 
 mke2fs -Fjq $filesystem_dev
-root_uuid=$($VOL_ID -u $filesystem_dev )
+root_uuid=$($VOL_ID $filesystem_dev )
 
 if [ -n "$swapdev" ]; then
   mkswap $swapdev
-  swap_uuid=$($VOL_ID -u $swapdev || true )
+  swap_uuid=$($VOL_ID $swapdev || true )
 fi
 
 TMPDIR=`mktemp -d` || exit 1
diff --git a/export b/export
index b127754..fccf4b0 100755 (executable)
--- a/export
+++ b/export
@@ -39,7 +39,7 @@ else
   exit 1
 fi
 
-vol_type=$($VOL_ID -t $filesystem_dev)
+vol_type=$($VOL_TYPE $filesystem_dev)
 
 if [ "$vol_type" = "ext3" -o "$vol_type" = "ext2" ]; then
   dump -0 -q -f - "$filesystem_dev"
diff --git a/import b/import
index 0d95450..2d9b58e 100755 (executable)
--- a/import
+++ b/import
@@ -42,11 +42,11 @@ else
 fi
 
 mke2fs -Fjq $filesystem_dev
-root_uuid=$($VOL_ID -u $filesystem_dev )
+root_uuid=$($VOL_ID $filesystem_dev )
 
 if [ -n "$swapdev" ]; then
   mkswap $swapdev
-  swap_uuid=$($VOL_ID -u $swapdev || true )
+  swap_uuid=$($VOL_ID $swapdev || true )
 fi
 
 TMPDIR=`mktemp -d` || exit 1