[英]How to identify the mapping between aws ebs block volume name and the actual device name(rhel) created via terraform?
I have attached the below ebs volumes in my aws ec2 instance我在我的 aws ec2 实例中附加了以下 ebs 卷
resource "aws_volume_attachment" "dbdata-vol-atch" {
device_name = "/dev/sdc"
id = "xxxx"
instance_id = "yyyy"
volume_id = "zzzz"
}
# module.mongo-vm-instances.aws_volume_attachment.dblog-vol-atch["MongoA"]:
resource "aws_volume_attachment" "dblog-vol-atch" {
device_name = "/dev/sdd"
id = "xxxx"
instance_id = "yyyy"
volume_id = "zzzz"
}
# module.mongo-vm-instances.aws_volume_attachment.dbwsp-vol-atch["MongoA"]:
resource "aws_volume_attachment" "dbwsp-vol-atch" {
device_name = "/dev/sde"
id = "xxxx"
instance_id = "yyyy"
volume_id = "zzzz"
}
But if i check in instance i'm seeing as below and not able to see the device name which i have mentioned in terraform(/dev/sd*)但是如果我检查实例我看到如下并且无法看到我在 terraform(/dev/sd*) 中提到的设备名称
[ec2-user@MongoA ~]$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
nvme1n1 259:0 0 30G 0 disk
nvme0n1 259:1 0 10G 0 disk
├─nvme0n1p1 259:2 0 1M 0 part
└─nvme0n1p2 259:3 0 10G 0 part /
nvme2n1 259:4 0 50G 0 disk
nvme3n1 259:5 0 30G 0 disk
nvme4n1 259:6 0 500G 0 disk
nvme5n1 259:7 0 30G 0 disk
Tried below but no luck to see the device name在下面尝试但没有看到设备名称
[ec2-user@MongoM-1 ~]$ sudo nvme list
Node SN Model Namespace Usage Format FW Rev
---------------- -------------------- ---------------------------------------- --------- -------------------------- ---------------- --------
/dev/nvme0n1 volxxxxxxxxxxxxx Amazon Elastic Block Store 1 0.00 B / 10.74 GB 512 B + 0 B 1.0
/dev/nvme1n1 volxxxxxxxxxxxxx Amazon Elastic Block Store 1 0.00 B / 32.21 GB 512 B + 0 B 1.0
/dev/nvme2n1 volxxxxxxxxxxxxx Amazon Elastic Block Store 1 0.00 B / 53.69 GB 512 B + 0 B 1.0
/dev/nvme3n1 volxxxxxxxxxxxxx Amazon Elastic Block Store 1 0.00 B / 32.21 GB 512 B + 0 B 1.0
/dev/nvme4n1 volxxxxxxxxxxxxx Amazon Elastic Block Store 1 0.00 B / 536.87 GB 512 B + 0 B 1.0
/dev/nvme5n1 volxxxxxxxxxxxxx Amazon Elastic Block Store 1 0.00 B / 32.21 GB 512 B + 0 B 1.0
Could you please advice.Since using that dev name,i have to create a shell script to run mount command for respective device name to respective directory(mount /dev/sdb /data/...etc)你能给我建议吗。因为使用那个开发名称,我必须创建一个 shell 脚本来为各自的设备名称运行挂载命令到各自的目录(mount /dev/sdb /data/...等)
Looks similar to the SO question: AWS Terraform automation of multiple nvme<x>看起来类似于 SO 问题: AWS Terraform automation of multiple nvme<x>
Also, you can create a symbolic link for NVMe devices to /dev/* devices using cloud-init, example: https://github.com/leboncoin/terraform-aws-nvme-example/blob/master/scripts/ebs_alias.sh.tpl此外,您可以使用 cloud-init 为 NVMe 设备创建到 /dev/* 设备的符号链接,例如: https://github.com/leboncoin/terraform-aws-nvme-example/blob/master/scripts/ebs_alias。 sh.tpl
lsblk,nvme helped me to get the mapping device names.Got the results by writing a small for loop as below lsblk,nvme 帮助我获取映射设备名称。通过编写一个小的 for 循环得到结果,如下所示
for i in $(lsblk|awk '{print $1}'|grep -v p|grep -i -v name) ; do
ALIAS=$(nvme id-ctrl -v /dev/$i| grep -Po '/dev/(sd[b-z]|xvd[b-z])');
mkfs -t xfs /dev/$i
vol_id=$(blkid -s UUID -o value /dev/$i)
echo $i $ALIAS $vol_id>>/tmp/mnt.log
done
Note: Need to install nvme-cli by using yum -y install nvme-cli to use nvme command注意:需要安装 nvme-cli 使用 yum -y install nvme-cli 才能使用 nvme 命令
Check if you have the NVMe drivers installed:检查您是否安装了 NVMe 驱动程序:
To confirm that your instance has the NVMe driver
You can confirm that your instance has the NVMe driver and check the driver version using the following command. If the instance has the NVMe driver, the command returns information about the driver.
$ modinfo nvme
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/nvme-ebs-volumes.html#install-nvme-driver . https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/nvme-ebs-volumes.html#install-nvme-driver 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.