Use vol_id to calculate volume UUIDs
authorGuido Trotter <ultrotter@google.com>
Tue, 26 Aug 2008 13:32:47 +0000 (13:32 +0000)
committerGuido Trotter <ultrotter@google.com>
Tue, 26 Aug 2008 13:32:47 +0000 (13:32 +0000)
This allows the UUID to be calculated in a standard way no matter what
the filesystem in use is. It requires udev to be installed.

Reviewed-by: imsnah

create.in
import

index 123e081..8426d92 100755 (executable)
--- a/create.in
+++ b/create.in
@@ -71,10 +71,11 @@ if [ -z "$instance" -o -z "$blockdev" -o -z "$swapdev" ]; then
   exit 1
 fi
 
-swap_uuid=$(mkswap $swapdev | grep 'UUID' | sed -re 's/.*UUID=//')
+mkswap $swapdev
 mke2fs -Fjq $blockdev
-root_uuid=$(dumpe2fs -h $blockdev | grep '^Filesystem UUID:' \
-            | sed -re 's/.*UUID:\s*//')
+swap_uuid=$(/sbin/vol_id --uuid $swapdev )
+root_uuid=$(/sbin/vol_id --uuid $blockdev )
+
 TMPDIR=`mktemp -d` || exit 1
 trap "umount $TMPDIR; rmdir $TMPDIR" EXIT
 
diff --git a/import b/import
index 0f4691b..90fd7ff 100755 (executable)
--- a/import
+++ b/import
@@ -44,10 +44,10 @@ if [ -z "$instance" -o -z "$blockdev" -o -z "$swapdev" ]; then
        exit 1
 fi
 
-swap_uuid=$(mkswap $swapdev | grep 'UUID' | sed -re 's/.*UUID=//')
+mkswap $swapdev
 mke2fs -Fjq $blockdev
-root_uuid=$(dumpe2fs -h $blockdev | grep '^Filesystem UUID:' \
-            | sed -re 's/.*UUID:\s*//')
+swap_uuid=$(/sbin/vol_id --uuid $swapdev )
+root_uuid=$(/sbin/vol_id --uuid $blockdev )
 
 TMPDIR=`mktemp -d` || exit 1
 trap "umount $TMPDIR; rmdir $TMPDIR" EXIT