Skip to content

Instantly share code, notes, and snippets.

@dcampano
Created March 4, 2011 02:03
Show Gist options
  • Save dcampano/854040 to your computer and use it in GitHub Desktop.
Save dcampano/854040 to your computer and use it in GitHub Desktop.
quick way to mount a bunch of disks to an ec2 instance
#!/usr/bin/env ruby
require 'rubygems'
require 'fog'
connection = Fog::Compute.new(:provider => "AWS", :region => "us-west-1")
current_instance_id = `curl http://169.254.169.254/latest/meta-data/instance-id`
current_instance = connection.servers.get(current_instance_id)
letters = 'f'..'l'
letters.to_a.each do |letter|
current_disk = "/dev/sd#{letter}"
vol = connection.volumes.new(:availability_zone => current_instance.availability_zone, :size => 75)
vol.device = current_disk
vol.server = current_instance
vol.save
p vol
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment