[linux-lvm] balooning/dynamic snapshots?
Brian J. Murrell
brian at interlinx.bc.ca
Tue Nov 13 20:27:21 UTC 2007
On Tue, 2007-11-13 at 18:13 +0100, Tomasz Chmielewski wrote:
>
> Is it possible to make a "balooning", or dynamic LVM snapshot? That is,
> if the snapshot reaches its maximum, it will be automatically resized,
> provided we still have space on the medium.
Yeah, that is something I wanted at one time. In it's absence, I hacked
up the following brute-force solution. I don't like the concept, but it
works.
#!/usr/bin/ruby
threshold=80.0
increase_factor=0.5
IO.popen("/testsuite/ltest-boulder/acceptance/common/timed_run 10 /usr/sbin/lvs") do |f|
f.each_line do |line|
j,volume,j,j,size,j,used = line.chomp.split(/\s+/)
if used.to_f > threshold then
# by bytes
#size = eval(size.sub(/G$/, ' * 1024 * 1024 * 1024'))
re = /([\d\.]+)([GM])/
md = re.match(size)
size = md[1]
units = md[2]
expand_by = size.to_f * increase_factor
system("echo \"lv #{volume} was #{size}#{units} big and #{used} full and was expaned +#{expand_by}#{units}\" | mail -s \"snap expanded\" root")
system("/testsuite/ltest-boulder/acceptance/common/timed_run 60 /usr/sbin/lvextend -L+#{expand_by}#{units} /dev/vg0/#{volume}")
end
end
end
Put it in cron and run at an appropriate frequency.
b.
More information about the linux-lvm
mailing list