From 17b5b2da0af36d75dc47d545cdf46eb0a0fc0d93 Mon Sep 17 00:00:00 2001 From: Guido Trotter Date: Mon, 19 Oct 2009 19:18:07 -0400 Subject: [PATCH] Support blktype as an alternative to vol_id 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 Reviewed-by: Michael Hanselmann --- common.sh.in | 20 +++++++++++++------- create | 4 ++-- export | 2 +- import | 4 ++-- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/common.sh.in b/common.sh.in index 2acab86..6c6c3b9 100644 --- a/common.sh.in +++ b/common.sh.in @@ -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 --- 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 --- 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 --- 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 -- 1.7.2.5