From aa32e81467b40a2c2c9c118c6ab48d3e51deb897 Mon Sep 17 00:00:00 2001 From: Yukikoo Date: Fri, 12 Apr 2019 22:41:09 +0200 Subject: [PATCH] Create mount_lvm_image.sh --- code/OS-administration/mount_lvm_image.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 code/OS-administration/mount_lvm_image.sh diff --git a/code/OS-administration/mount_lvm_image.sh b/code/OS-administration/mount_lvm_image.sh new file mode 100644 index 0000000..41e836c --- /dev/null +++ b/code/OS-administration/mount_lvm_image.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +######################################################## +# Make a LVM image appear in qvm-block +# Create a disposable VM +# Attach the image to the newly created disposable VM +# Wait until the disposable VM is destroyed +# Remove the LVM image from the qvm-block list +###################################################### + +image=${1?Image file is required, exemple "/dev/qubes_dom0/vm-debian-9-tmp-root"} +dvm=${2?DVM template name is required, example: "fedora-29-dvm"} +dev=$(basename $(readlink "$image")) +qubesdb-write /qubes-block-devices/$dev/desc "$image" +list_before=$(qvm-ls | cut -d " " -f1 | sort) +qvm-run -v --dispvm=$dvm --service qubes.StartApp+xterm & +sleep 5 +list_after=$(qvm-ls | cut -d " " -f1 | sort) +diff=$(comm -3 <(echo "$list_before") <(echo "$list_after")) +qvm-block attach $diff dom0:$dev +wait +qubesdb-rm /qubes-block-devices/$dev/