<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>Hi Jaime,<br><br>Great suggestion.<br>And if I use virt-resize, it should even be easier as it resizes both the vdisk and the partitions inside:<br><br>http://libguestfs.org/virt-resize.1.html<br><br>Regards,<br>Ricardo <br><div><div id="SkyDrivePlaceholder"></div><hr id="stopSpelling">From: jmelis@opennebula.org<br>Date: Tue, 25 Sep 2012 11:32:04 +0200<br>Subject: Re: [one-users] Set root disk size at runtime<br>To: rjtd21@hotmail.com<br>CC: users@lists.opennebula.org<br><br>Hi Ricardo,<div><br></div><div>in case you did want to resize the main OS disk, you need to do a tiny bit of coding. Let me walk you through it.</div><div><br></div><div>You will need to edit the "clone" script located in "/var/lib/one/remotes/tm/<your_tm>/clone" where <your_tm> will be either "shared","ssh", or whatever TM_MAD you're using in your datastores.</div>


<div><br></div><div>In that file you will need to grab the SIZE attribute of the disk. You can grab that bit of code from tm/lvm/clone [1]. Be careful because DEFAULT_SIZE won't be declared, so you will need to hardcode it.</div>


<div><br></div><div>After this step you will need to resize the image to the specified SIZE:</div><div><br></div><div>"tm/ssh/clone" [2]:</div><div>Right after line 66 add something like:</div><div><font face="courier new, monospace">ssh_exec_and_log "$DST_HOST" "qemu-img resize $DST_PATH $SIZE" "Error: could not resize"</font></div>


<div><br></div><div>"tm/shared/clone" [3]:</div><div>Substitute line 67 with:</div><div><div><font face="courier new, monospace">    "cd $DST_DIR; cp -r $SRC_PATH $DST_PATH; qemu-img resize $DST_PATH $SIZE" \</font></div>

</div><div><br></div><div>
Once you have implemented this, you will be able to do in your VM/templates:</div><div><font face="courier new, monospace">DISK = [ IMAGE_ID = <ID>, SIZE = <NEW_SIZE> ]</font></div><div><br></div><div>Keep the following things in mind though:</div>

<div>
- There might be a errors, this has not been tested, written off the top of my head</div><div>- Quotas and accounting won't be aware of the dynamic resizing</div><div>- You will need to use images understood by qemu-img. Of course you can substitute that command for whatever you like.</div>


<div><br></div><div>[1] <a href="https://github.com/OpenNebula/one/blob/master/src/tm_mad/lvm/clone#52" target="_blank">https://github.com/OpenNebula/one/blob/master/src/tm_mad/lvm/clone#52</a> lines 52-62</div><div>[2] <a href="https://github.com/OpenNebula/one/blob/one-3.6/src/tm_mad/ssh/clone#L66" target="_blank">https://github.com/OpenNebula/one/blob/one-3.6/src/tm_mad/ssh/clone#L66</a><br>


<div>[3] <a href="https://github.com/OpenNebula/one/blob/one-3.6/src/tm_mad/shared/clone#L67" target="_blank">https://github.com/OpenNebula/one/blob/one-3.6/src/tm_mad/shared/clone#L67</a></div><div><br></div><div>regards,<br>

Jaime</div>
<div><br><div class="ecxgmail_quote">On Mon, Sep 24, 2012 at 1:01 PM, Ricardo Duarte <span dir="ltr"><<a href="mailto:rjtd21@hotmail.com">rjtd21@hotmail.com</a>></span> wrote:<br><blockquote class="ecxgmail_quote" style="border-left:1px #ccc solid;padding-left:1ex">





<div><div dir="ltr">Hi there,<br><br>I had a look at cloud-init, and also other cloud softwares, and this is what they do:<br><br>- The images themselves are very small in size<br>- The size of the root disk is selected when launching a instance, and as so, it can be part of the service offering (ex.: small 8GB, medium 10GB, etc).<br>


- The virtual disk is grown to the size selected when launching the instance. Partition size inside is kept.<br>- Cloud-init, inside the guest, resizes the partition on first boot, by using resize2fs. This is just a small command, so it could be done without cloud-init quite easily<br>


<br>Is this currently possible to do with existing OpenNebula functionality?<br><br>Thanks,<br>Ricardo<br>                                          </div></div>
<br>_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opennebula.org">Users@lists.opennebula.org</a><br>
<a href="http://lists.opennebula.org/listinfo.cgi/users-opennebula.org" target="_blank">http://lists.opennebula.org/listinfo.cgi/users-opennebula.org</a><br>
<br></blockquote></div><br></div></div><br clear="all"><div><br></div>-- <br>Jaime Melis<br>Project Engineer<br>OpenNebula - The Open Source Toolkit for Cloud Computing<br><a href="http://www.OpenNebula.org" target="_blank">www.OpenNebula.org</a> | <a href="mailto:jmelis@opennebula.org">jmelis@opennebula.org</a><br></div>                                       </div></body>
</html>