Shrinking a Ganeti Instance Disk

Thanks to Phil Regnauld for the clues. In this example, we use as the instance name. Of course you will want to change that.


Shutdown the VM

gnt-instance shutdown

We need to get the uuid of the volume to be reduced

# gnt-instance info | grep primary
    - primary:
          on primary: /dev/ganeti/a5ce213c-d455-4cee-a173-4c3c72d81e68.disk0_data (253:10)
          on primary: /dev/ganeti/a5ce213c-d455-4cee-a173-4c3c72d81e68.disk0_meta (253:12)

Oops! See that disk0_meta? This means there is a drbd secondary. We never figured out how to deal with that, so you have to convert the instance to plain before proceeding.

gnt-instance modify -t plain --no-wait-for-sync

Tell Ganeti to Chill

First we need to stop ganeti and backup the config file on the master

service ganeti stop
rsync /var/lib/ganeti/ /var/lib/ganeti/

Actually Shrink the Volume(s)

Then we can lvreduce the disk on the node where the instance lives. Note that the size parameter may be either an abusolute new size or the amount to be reduced. Here we do the latter, on the instance's primary node, of course.

lvreduce —-size -8GB /dev/ganeti/a5ce213c-d455-4cee-a173-4c3c72d81e68.disk0_data

Tell Ganeti's Config About the Change

Now is the grotty hack; we have to change the size in the ganeti Find the JSON for the file UUID of the disk. In this case, the JSON looked like

"params": {}, "uuid": "a70acc51-586b-4a83-9a8c-ff884ef0c5b4", "size": 45056}, {"dev_type": "plain", "logical_id": ["ganeti", "a5ce213c-d455-4cee-a173-4c3c72d81e68.disk0_meta"]

Note the size, 45056, which is 45056/1024 = 44G. I wanted to reduce by 8G, so 45056-(8*1024) = 36864

"params": {}, "uuid": "a70acc51-586b-4a83-9a8c-ff884ef0c5b4", "size": 36864}, {"dev_type": "plain", "logical_id": ["ganeti", "a5ce213c-d455-4cee-a173-4c3c72d81e68.disk0_meta"]

Phil prefers to de-JSON the config to make it easier to see before hacking

python -mjson.tool < /var/lib/ganeti/ > /tmp/config

Restart Ganeti

Restart Ganeti and redistribute the modified configuration

service ganeti start
gnt-cluster redist-conf

Clean Up

If the instance was of type drbd, remember to convert it back from plain.

gnt-instance modify -t drbd --no-wait-for-sync -n vm2
gnt-instance start

And Bob's your uncle.

Last modified 4 years ago Last modified on Dec 2, 2015, 3:24:24 PM