I use the Ruby AWS-SDK to create EC2 instances like this :

instance = ec2.instances.create({
  :image_id        => WORKER_AMI,
  :instance_type   => instance_type,
  :key_name        => 'cloud',
  :security_groups => 'worker',
  :user_data       => user_data_script,
  :count           => 1,

  :block_device_mappings => [
     :device_name => "/dev/sda1",
     :ebs         => { :volume_size => 50, :delete_on_termination => true }

When doing that, I get a 50 Gb root volume. But I also get a 360G ephemeral disk I don't need. In the AWS console, you can remove it in the wizard when you launch an instance. But how to do it via the SDK ?

1 Answer 1



seems to indicate the following should work:-

:block_device_mappings => 
    {ebs device},
    {:deviceName => '/dev/sdb', :virtual_name => :ephemeral0, :no_device => ""}

The code seems to say it doesn't look like it matters what the value of :no_devices is, as long as it's there...

Alternatively, see if you can find an ami which doesn't have those devices in it's default block mapping. To do this see http://docs.aws.amazon.com/AWSEC2/latest/CommandLineReference/ApiReference-cmd-CreateImage.html

 ec2-create-image instance_id --name name -b /dev/sdb=none /dev/sdc=none etc...
  • Thanks. This strange param should do the trick, I'll try and update this page.
    – aurels
    Sep 26, 2013 at 14:41
  • For your other suggestion, I use a custom AMI of mine. Do you know if it's possible to remove the device from it easily ? Creating an instance from the AMI in the console, removing the device in the wizard, and then creating a new AMI from the resulting instance should work, right ?
    – aurels
    Sep 26, 2013 at 14:43
  • Answer updated to include block-devive-mapping override for create image.
    – Decado
    Sep 27, 2013 at 8:01
  • Can't make it work : { :device_name => '/dev/xvdb', :virtual_name => 'ephemeral0', :no_device => '' }
    – aurels
    Sep 27, 2013 at 9:15
  • If you pass something to :no_device it raises an error.
    – aurels
    Sep 27, 2013 at 9:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.