编辑和TL;DR:
ubuntu@ip-172-31-19-77:~/.aws$ aws ec2 describe-instances | jq . | grep -i device
"BlockDeviceMappings": [],
"RootDeviceType": "ebs",
"RootDeviceName": "/dev/sda1",
"DeviceIndex": 0,
"BlockDeviceMappings": [
"DeviceName": "/dev/sda1",
"DeviceName": "/dev/xvdb",
"RootDeviceType": "ebs",
"RootDeviceName": "/dev/sda1",
"DeviceIndex": 0,
"BlockDeviceMappings": [
"DeviceName": "/dev/sda1",
"RootDeviceType": "ebs",
"RootDeviceName": "/dev/sda1",
"DeviceIndex": 0,
"BlockDeviceMappings": [
"DeviceName": "/dev/xvda",
"RootDeviceType": "ebs",
"RootDeviceName": "/dev/xvda",
"DeviceIndex": 0,
"BlockDeviceMappings": [
"DeviceName": "/dev/sda1",
"DeviceName": "/dev/sdf",
"RootDeviceType": "ebs",
"RootDeviceName": "/dev/sda1",
ubuntu@ip-172-31-19-77:~/.aws$ aws ec2 describe-volumes | jq . | grep -i device
"Device": "/dev/sda1"
"Device": "/dev/sdf"
"Device": "/dev/xvda"
"Device": "/dev/sda1"
"Device": "/dev/xvdb"
"Device": "/dev/sda1"
ubuntu@ip-172-31-19-77:~/.aws$ ls /dev/sd*
ls: cannot access '/dev/sd*': No such file or directory
ubuntu@ip-172-31-19-77:~/.aws$ ls /dev/xv*
ls: cannot access '/dev/xv*': No such file or directory
ubuntu@ip-172-31-19-77:~/.aws$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
nvme0n1 259:0 0 1G 0 disk
nvme1n1 259:1 0 8G 0 disk
└─nvme1n1p1 259:2 0 8G 0 part /
解释:
我想提前知道特定 AWS 实例应该具有后连接的块设备。
很遗憾,2007 年引入的块设备的实例元数据端点 https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html#instancedata-data-categories似乎不再可靠地工作了?
这是一个例子t2.medium
我正在运行的实例最新的 Ubuntu (17.10) AMI https://console.aws.amazon.com/ec2/home?region=ap-southeast-2#launchAmi=ami-8610dee4在撰写本文时(不是亚马逊 Linux https://aws.amazon.com/amazon-linux-ami/):
EBS 模块不仅显示在控制台中,而且似乎已正确连接:
据官方称有关块设备映射的 AWS 文档 https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html#instancedata-data-categories:
block-device-mapping/ebsN
:与 Amazon EBS 卷关联的虚拟设备(如果存在)。 Amazon EBS 卷仅在启动时或实例上次启动时存在的情况下在元数据中可用。 N 表示 Amazon EBS 卷的索引(例如 ebs1 或 ebs2)。2007-12-15
但不幸的是,在实例完全启动并运行后,不存在这样的端点并附加所有 EBS 卷:
$ curl http://169.254.169.254/latest/meta-data/block-device-mapping/
ami
ephemeral0
ephemeral1
$ curl http://169.254.169.254/latest/meta-data/block-device-mapping/ami
/dev/sda1
$ curl http://169.254.169.254/latest/meta-data/block-device-mapping/ebs1
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>404 - Not Found</title>
</head>
<body>
<h1>404 - Not Found</h1>
</body>
</html>
$ curl http://169.254.169.254/latest/meta-data/block-device-mapping/ebs2
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>404 - Not Found</title>
</head>
<body>
<h1>404 - Not Found</h1>
</body>
</html>
另一方面,操作系统(在 XEN 设备方案下)通过以下方式公开卷xvdXX
设备:
$ ls /dev/xvd*
/dev/xvda /dev/xvda1 /dev/xvdf /dev/xvdg
所以这给我留下了一个糟糕的解决方案只是假设哪个块设备将取决于哪个实例 https://github.com/brainstorm/pcgr-deploy/blob/master/ansible/group_vars/all#L16我正在跑步,可以预见的是,它会中断一次,例如,亚马逊推出新熨斗 https://aws.amazon.com/about-aws/whats-new/2017/11/introducing-amazon-ec2-m5-instances/具有完全不同的底层块设备命名方案,例如/dev/nvme0n1p1
:
https://twitter.com/braincode/status/968005482102190080 https://twitter.com/braincode/status/968005482102190080
以下是附加 EBS 卷的新实例化 M5 实例上发生的情况:
$ curl http://169.254.169.254/latest/meta-data/block-device-mapping/
ami
ebs2
root
$ curl http://169.254.169.254/latest/meta-data/block-device-mapping/ebs2
sdf
- 为什么只是
ebs2
列出的和未列出的ebs1
?
-
sdf
?
没有一个sd*
在 m5 实例的操作系统上:
$ ls /dev/sd*
ls: cannot access '/dev/sd*': No such file or directory
我究竟做错了什么?这是一个已知的错误? people/boot/cloud init 模块如何处理这个问题?