7

I'm trying to create an AMI from an instance store-back instance but I'm getting "Invalid device name" error at the time when I try to register the AMI.

I'm following this document:

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/create-instance-store-ami.html#amazon_linux_instructions

This is my current instance state:

[root@ip-172-29-1-29 ~]# lsblk
NAME    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
xvda    202:0    0   500G  0 disk
└─xvda1 202:1    0   500G  0 part /
xvdb    202:16   0 745.2G  0 disk
└─xvdb1 202:17   0 745.2G  0 part /media/ephemeral0
xvdc    202:32   0 745.2G  0 disk
└─xvdc1 202:33   0 745.2G  0 part /media/ephemeral1

[root@ip-172-29-1-29 ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/xvda1      493G  4.9G  488G   1% /
devtmpfs         61G  108K   61G   1% /dev
tmpfs            61G     0   61G   0% /dev/shm
/dev/xvdb1      734G   69M  697G   1% /media/ephemeral0
/dev/xvdc1      734G   69M  697G   1% /media/ephemeral1

Here is my fstab:

[root@ip-172-29-1-29 ~]# cat /etc/fstab
#
LABEL=/     /           ext4    defaults,noatime  1   1
tmpfs       /dev/shm    tmpfs   defaults        0   0
devpts      /dev/pts    devpts  gid=5,mode=620  0   0
sysfs       /sys        sysfs   defaults        0   0
proc        /proc       proc    defaults        0   0
/dev/xvdb1   /media/ephemeral0       ext4    defaults,noatime,nodiratime,nofail 0   2
/dev/xvdc1   /media/ephemeral1       ext4    defaults,noatime,nodiratime,nofail 0   2

And here is the manifest file I'm getting:

<machine_configuration>
    <architecture>x86_64</architecture>
    <block_device_mapping>
      <mapping>
        <virtual>ami</virtual>
        <device>xvda</device>
      </mapping>
      <mapping>
        <virtual>ephemeral0</virtual>
        <device>xvdb</device>
      </mapping>
      <mapping>
        <virtual>ephemeral1</virtual>
        <device>xvdc</device>
      </mapping>
      <mapping>
        <virtual>root</virtual>
        <device>/dev/xvda1</device>
      </mapping>
    </block_device_mapping>
  </machine_configuration>

At the end when I try to register AMI, I get the following error:

An error occurred (InvalidManifest) when calling the RegisterImage operation: Invalid block device mapping: Invalid device name '/dev/xvda1'

I tried with "/dev/xvda" or "xvda" also, but not sure what's the expected device name I should be using for root.

dreamer
  • 171
  • 1
  • 1
  • 3
  • 7
    Try using `/dev/sda1`. – Matt Houser Sep 09 '16 at 17:06
  • 1
    @MattHouser Thanks for your response. Just wanted to know, why "/dev/sda1" where I don't see that device when I do "lsblk"? – dreamer Sep 09 '16 at 17:10
  • 7
    Sometimes, externally the block device is listed as `/dev/sda1` and internally it's `/dev/xvda`. Check your EC2 instance information for the block device name (using the AWS Managment Console). – Matt Houser Sep 09 '16 at 17:23
  • 6
    The actual device naming is determined by the kernel, but AWS APIs seem to standardize around the /dev/sd[A-F] convention, even if the kernel on the running machine changes it to /dev/xvd[A-F]. http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/device_naming.html – Canuteson Sep 10 '16 at 04:41
  • 2
    for centos 7 image I had to use `/dev/sda1` for the root volume. – Felipe Alvarez May 11 '17 at 06:00

1 Answers1

3

As suggested in comments to the OP's question, the root device is either /dev/sda1 or /dev/xvda, and AWS's device naming docs specify what names can be used for other devices.

The way I understand it, naming has more to do with how the hypervisor sees the device than it does with how the OS sees the device.

Dale C. Anderson
  • 587
  • 1
  • 5
  • 13