1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: BSD-3-Clause
5 Make the create-ebs-volume script work with nvme devices.
7 diff --git a/bin/create-ebs-volume b/bin/create-ebs-volume
8 index 6857564..efeac35 100755
9 --- a/create-ebs-volume
10 +++ b/create-ebs-volume
11 @@ -149,10 +149,11 @@ function get_next_logical_device() {
12 for letter in ${alphabet[@]}; do
13 # use /dev/xvdb* device names to avoid contention for /dev/sd* and /dev/xvda names
14 # only supported by HVM instances
15 - if [ ! -b "/dev/xvdb${letter}" ]; then
16 + if [[ $created_volumes =~ .*/dev/xvdb${letter}.* ]]; then
19 echo "/dev/xvdb${letter}"
25 @@ -322,13 +323,21 @@ function create_and_attach_volume() {
28 logthis "waiting for volume $volume_id on filesystem"
31 - if [ -e "$device" ]; then
32 - logthis "volume $volume_id on filesystem as $device"
33 + # AWS returns e.g. vol-00338247831716a7b4, the kernel changes that to vol00338247831716a7b
34 + valid_volume_id=`echo $volume_id |sed -e 's/[^a-zA-Z0-9]//'`
35 + # example lsblk output:
36 + # nvme4n1 259:7 0 150G 0 disk vol00338247831716a7b
37 + LSBLK=`lsblk -o +SERIAL |grep $valid_volume_id`
38 + if [[ $? -eq 0 ]]; then
39 + nvme_device=`echo $LSBLK|cut -f1 -d' '|xargs -I {} echo "/dev/{}"`
40 + logthis "volume $volume_id on filesystem as $nvme_device (aws device $device)"
47 # set volume delete on termination
48 aws ec2 modify-instance-attribute \
49 @@ -338,7 +347,7 @@ function create_and_attach_volume() {
51 logthis "volume $volume_id DeleteOnTermination ENABLED"
57 create_and_attach_volume