]> gitweb.fluxo.info Git - kvmx.git/commitdiff
Fix partition handling for device image_types at kvmx-create
authorSilvio Rhatto <rhatto@riseup.net>
Wed, 13 Jun 2018 22:22:09 +0000 (19:22 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Wed, 13 Jun 2018 22:22:09 +0000 (19:22 -0300)
kvmx-create

index 4c1ee0b198a14f862c5da3493b194ad07c9869f7..2d3e8b87a4465d8a0c8039ae7af429ab4241722a 100755 (executable)
@@ -238,10 +238,12 @@ function kvmx_create_custom {
     #kvmx_sudo_run dd if=/dev/zero of=$image bs=$size count=1
     kvmx_sudo_run qemu-img create -f raw $image $size
     device="`sudo losetup --find --show $image`"
+    partition_prefix="p"
   elif [ -e "$image" ]; then
-    device="$image"
+    device="`readlink $image || echo $image`"
   else
     echo "$BASENAME: image device $image does not exist"
+    exit 1
   fi
 
   echo "Partitioning image at $device..."
@@ -250,8 +252,8 @@ function kvmx_create_custom {
   kvmx_sudo_run parted -s -- $device set     1  bios_grub on
   kvmx_sudo_run parted -s -- $device unit    MB mkpart    ext2   3 -1
   kvmx_sudo_run parted -s -- $device set     2  boot on
-  kvmx_sudo_run mkfs.ext4 ${device}p2
-  kvmx_sudo_run mount ${device}p2 $WORK/
+  kvmx_sudo_run mkfs.ext4 ${device}${partition_prefix}2
+  kvmx_sudo_run mount ${device}${partition_prefix}2 $WORK/
 
   # Non-interactive installation
   APT_INSTALL="kvmx_sudo_run LC_ALL=C DEBIAN_FRONTEND=noninteractive chroot $WORK/ apt-get install -y"