[one-users] Set root disk size at runtime
Ricardo Duarte
rjtd21 at hotmail.com
Thu Sep 27 11:10:44 PDT 2012
Hi Jaime,
Great suggestion.
And if I use virt-resize, it should even be easier as it resizes both the vdisk and the partitions inside:
http://libguestfs.org/virt-resize.1.html
Regards,
Ricardo
From: jmelis at opennebula.org
Date: Tue, 25 Sep 2012 11:32:04 +0200
Subject: Re: [one-users] Set root disk size at runtime
To: rjtd21 at hotmail.com
CC: users at lists.opennebula.org
Hi Ricardo,
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.
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.
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.
After this step you will need to resize the image to the specified SIZE:
"tm/ssh/clone" [2]:Right after line 66 add something like:ssh_exec_and_log "$DST_HOST" "qemu-img resize $DST_PATH $SIZE" "Error: could not resize"
"tm/shared/clone" [3]:Substitute line 67 with: "cd $DST_DIR; cp -r $SRC_PATH $DST_PATH; qemu-img resize $DST_PATH $SIZE" \
Once you have implemented this, you will be able to do in your VM/templates:DISK = [ IMAGE_ID = <ID>, SIZE = <NEW_SIZE> ]
Keep the following things in mind though:
- There might be a errors, this has not been tested, written off the top of my head- Quotas and accounting won't be aware of the dynamic resizing- You will need to use images understood by qemu-img. Of course you can substitute that command for whatever you like.
[1] https://github.com/OpenNebula/one/blob/master/src/tm_mad/lvm/clone#52 lines 52-62[2] https://github.com/OpenNebula/one/blob/one-3.6/src/tm_mad/ssh/clone#L66
[3] https://github.com/OpenNebula/one/blob/one-3.6/src/tm_mad/shared/clone#L67
regards,
Jaime
On Mon, Sep 24, 2012 at 1:01 PM, Ricardo Duarte <rjtd21 at hotmail.com> wrote:
Hi there,
I had a look at cloud-init, and also other cloud softwares, and this is what they do:
- The images themselves are very small in size
- 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).
- The virtual disk is grown to the size selected when launching the instance. Partition size inside is kept.
- 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
Is this currently possible to do with existing OpenNebula functionality?
Thanks,
Ricardo
_______________________________________________
Users mailing list
Users at lists.opennebula.org
http://lists.opennebula.org/listinfo.cgi/users-opennebula.org
--
Jaime Melis
Project Engineer
OpenNebula - The Open Source Toolkit for Cloud Computing
www.OpenNebula.org | jmelis at opennebula.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opennebula.org/pipermail/users-opennebula.org/attachments/20120927/e301cb2c/attachment-0002.htm>
More information about the Users
mailing list