<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Clone on Amit Agarwal Linux Blog</title>
    <link>/tags/clone/</link>
    <description>Recent content in Clone on Amit Agarwal Linux Blog</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <lastBuildDate>Mon, 09 Apr 2018 01:00:45 +0000</lastBuildDate>
    
	<atom:link href="/tags/clone/index.xml" rel="self" type="application/rss+xml" />
    
    
    <item>
      <title>Linked clone with qemu-img</title>
      <link>/2018/04/09/linked-clone-qemu-img/</link>
      <pubDate>Mon, 09 Apr 2018 01:00:45 +0000</pubDate>
      
      <guid>/2018/04/09/linked-clone-qemu-img/</guid>
      <description>&lt;p&gt;As you would have seen in Virtualbox or vmware, there is option to create a linked clone. I wanted to use the same feature as “Snapshot” feature anyway does not look/work so great with virt-manager. So, I created a script to create a linked clone VM and here it is :&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;pre class=&#34;brush:shell&#34;&gt;#!/bin/bash - 
#===============================================================================
#
#          FILE: qcow2-linked-clone.sh
# 
#         USAGE: ./qcow2-linked-clone.sh 
# 
#   DESCRIPTION: 
# 
#       OPTIONS: ---
#  REQUIREMENTS: ---
#          BUGS: ---
#         NOTES: ---
#        AUTHOR: Amit Agarwal (aka)
#  ORGANIZATION: Mobileum
#       CREATED: 01/05/2018 09:54
# Last modified: Wed Feb 28, 2018  04:39PM
#      REVISION:  ---
#===============================================================================

set -o nounset                              # Treat unset variables as an error
UP=&#34;amitag:amitag&#34; #Here you need to put your username and group.

if [[ $# == 0 ]]
then
    read -p &#34;Enter the source path :: &#34; spath
    read -p &#34;Enter the source disk :: &#34; sdisk
    read -p &#34;Enter the destin path :: &#34; dpath
    read -p &#34;Enter the destin disk :: &#34; ddisk
    read -p &#34;Enter new VMName :: &#34; vmname
else
    spath=$(dirname $1)
    dpath=$spath
    sdisk=$(basename $1)
    ddisk=$2.qcow2
    vmname=$2
fi


sudo chown $UP &#34;$spath/$sdisk&#34;
qemu-img create -f qcow2 -b &#34;$spath/$sdisk&#34; &#34;$dpath/$ddisk&#34;

virt-install --disk $dpath/$ddisk --ram 512 \
    --virt-type kvm --vcpus 1 --name &#34;$vmname&#34; --import
&lt;/pre&gt;
&lt;p&gt;The script will create a linked qcow2 and then create a VM with that image. Running it is simple, either provide command line options or just run and it will ask you for details.&lt;/p&gt;</description>
    </item>
    
  </channel>
</rss>
