0
votes

I was trying to add several EBS to an EC2 instance, I use something like that:

  block_map = BlockDeviceMapping()
  xvdf = EBSBlockDeviceType()
  xvdf.delete_on_termination = True
  xvdf.size = opts.ebs_vol_size
  block_map['/dev/xvdf'] = xvdf
  req = conn.request_spot_instances(key_name=opts.key_pair,
                                  price=opts.price,
                                  image_id=ami,
                                  security_groups=[instance_group],
                                  instance_type=opts.instance_type,
                                  block_device_map=block_map,
                                  count=count
                                  )

EBS are created as I could see them within the EC2 instance in the AWS console. Beside that, I'm 100% sure they are created as I can list them with the lsblk command once I log into the EC2 instance. I also added a couple of entries to my /etc/fstab so that the EBS volumes at mounted at creation time.

However, they are not mounted. If I run the command mount -a the following error shows up: mount: wrong fs type, bad option, bad superblock on /dev/xvdf, missing codepage or helper program, or other error In some cases useful info is found in syslog - try dmesg | tail or so

So, it seems EBS volumes are created but not formatted with EBSBlockDeviceType. After I formatted, I can run mount -a again and they are already mounted.

My question is, if is possible to create and format a volume within the EBSBlockDeviceType() constructor, so that I can mount it.

Another option I think I might have is attach an already formatted EBS snapshot usign the snapshot_id field in the boto.ec2.blockdevicemapping.BlockDeviceType class.

Thank you!

1

1 Answers

1
votes

mount command fails for a newly allocated volume because there is no file system on it. BlockDeviceType (or EBSBlockDeviceType) does not have an option to chose a file system for the underlying EBS volume. Once the volume is allocated, user can create a file system of choice.

However, for a volume created from a formatted EBS snapshot (created from a volume having file system), there is no need to create file system again. You can use file -s <device name> to find out if the device already has a file system.

More details at: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-using-volumes.html