tar2vm: use UUID, prepare for virtio as well

Forward-port of b84182c5cb684afbd30ed1f9e5b6f89f55b4b53f
commit extended to handle /boot as well.
This commit is contained in:
Gleb Fotengauer-Malinovskiy 2014-03-20 19:46:53 +04:00 committed by Michael Shigorin
parent b0df203272
commit e177121ddf

View File

@ -167,6 +167,20 @@ if [ -n "$BOOTPART" ]; then
mkfs."$BOOTFSTYPE" "$LOOPBOOT"
fi
ROOTUUID="$(blkid -s UUID -o value -c /dev/null "$LOOPROOT")"
if [ -n "$ROOTUUID" ]; then
ROOTDEV="UUID=$ROOTUUID"
else
ROOTDEV="$LOOPROOT"
fi
if [ -n "$BOOTPART" ]; then
BOOTUUID="$(blkid -s UUID -o value -c /dev/null "$LOOPBOOT")"
if [ -n "$ROOTUUID" ]; then
BOOTDEV="UUID=$BOOTUUID"
fi
fi
# mount and populate it
mkdir -pm755 "$ROOTFS"
mount "$LOOPROOT" "$ROOTFS"
@ -180,7 +194,7 @@ tar -C "$ROOTFS" --numeric-owner -xf "$TAR"
for i in /dev /proc /sys; do mount --bind "$i" "$ROOTFS$i"; done
# loop device so lilo could work...
echo "$LOOPROOT / $ROOTFSTYPE relatime 1 1" >> "$ROOTFS/etc/fstab"
echo "$ROOTDEV / $ROOTFSTYPE relatime 1 1" >> "$ROOTFS/etc/fstab"
# target device at once
if [ -n "$BOOTPART" ]; then