-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaws-attach-volume-to-instance.txt
544 lines (468 loc) · 23.3 KB
/
aws-attach-volume-to-instance.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
[ec2-user@ip-172-31-24-248 ~]$ sudo ls -lh /etc/udev/rules.d/
total 20K
-rw-r--r-- 1 root root 640 May 8 2014 51-ec2-hvm-devices.rules
-rw-r--r-- 1 root root 641 May 8 2014 52-ec2-vcpu.rules
-rw-r--r-- 1 root root 724 May 8 2014 53-ec2-network-interfaces.rules
-rw-r--r-- 1 root root 326 Jul 9 2014 60-raw.rules
-rw-r--r-- 1 root root 1.4K May 8 2014 75-persistent-net-generator.rules
[ec2-user@ip-172-31-24-248 ~]$ sudo cat /etc/udev/rules.d/51-ec2-hvm-devices.rules
# Copyright (C) 2006-2014 Amazon.com, Inc. or its affiliates.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
# OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the
# License.
KERNEL=="xvd*", PROGRAM="/sbin/ec2udev-vbd %k", SYMLINK+="%c"
[ec2-user@ip-172-31-24-248 ~]$ sudo cat /sbin/ec2udev-vbd
#!/bin/bash
# Copyright (C) 2006-2014 Amazon.com, Inc. or its affiliates.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
# OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the
# License.
# Maintain consistent naming scheme with current EC2 instances
if [ "$#" -ne 1 ] ; then
echo "$0 <device>" >&2
exit 1
else
if echo "$1"|grep -qE 'xvd[a-z][0-9]?' ; then
echo "$1" | sed -e 's/xvd/sd/'
else
echo "$1"
fi
fi
[ec2-user@ip-172-31-24-248 ~]$ sudo cat /etc/udev/rules.d/60-raw.rules
#
# Enter raw device bindings here.
#
# An example would be:
# ACTION=="add", KERNEL=="sda", RUN+="/usr/bin/raw /dev/raw/raw1 %N"
# to bind /dev/raw/raw1 to /dev/sda, or
# ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="1", RUN+="/usr/bin/raw /dev/raw/raw2 %M %m"
# to bind /dev/raw/raw2 to the device with major 8, minor 1.
[ec2-user@ip-172-31-24-248 ~]$ sudo cat /etc/udev/rules.d/52-ec2-vcpu.rules
# Copyright (C) 2014 Amazon.com, Inc. or its affiliates.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
# OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the
# License.
SUBSYSTEM=="cpu", ACTION=="add", RUN+="/sbin/ec2udev-vcpu $devpath"
[ec2-user@ip-172-31-24-248 ~]$ sudo cat /etc/udev/rules.d/53-ec2-network-interfaces.rules
# Copyright (C) 2012 Amazon.com, Inc. or its affiliates.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
# OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the
# License.
ACTION=="add", SUBSYSTEM=="net", KERNEL=="eth*", IMPORT{program}="/bin/sleep 1"
SUBSYSTEM=="net", RUN+="/etc/sysconfig/network-scripts/ec2net.hotplug"
[ec2-user@ip-172-31-24-248 ~]$ sudo cat /etc/udev/rules.d/75-persistent-net-generator.rules
# Copyright (C) 2012 Amazon.com, Inc. or its affiliates.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
# OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the
# License.
# these rules generate rules for persistent network device naming
SUBSYSTEM!="net", GOTO="persistent_net_generator_end"
KERNEL!="eth*", GOTO="persistent_net_generator_end"
ACTION!="add", GOTO="persistent_net_generator_end"
NAME=="?*", GOTO="persistent_net_generator_end"
# do not create rule for eth0
ENV{INTERFACE}=="eth0", GOTO="persistent_net_generator_end"
# read MAC address
ENV{MATCHADDR}="$attr{address}"
# do not use empty address
ENV{MATCHADDR}=="00:00:00:00:00:00", GOTO="persistent_net_generator_end"
# discard any interface name not generated by our rules
ENV{INTERFACE_NAME}=="?*", ENV{INTERFACE_NAME}=""
# default comment
ENV{COMMENT}="elastic network interface"
# write rule
IMPORT{program}="write_net_rules"
# rename interface if needed
ENV{INTERFACE_NEW}=="?*", NAME="$env{INTERFACE_NEW}"
LABEL="persistent_net_generator_end"
attach a volume dmesg log:
Aug 27 13:28:34 ip-172-31-24-248 kernel: [286073.819561] blkfront: xvdf: barrier or flush: disabled; persistent grants: disabled; indirect descriptors: enabled;
Aug 27 13:28:34 ip-172-31-24-248 kernel: [286073.836337] xvdf: unknown partition table
[ec2-user@ip-172-31-24-248 ~]$ sudo fdisk -l
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Disk /dev/xvda: 8589 MB, 8589934592 bytes, 16777216 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt
# Start End Size Type Name
1 4096 16777182 8G Linux filesyste Linux
128 2048 4095 1M BIOS boot parti BIOS Boot Partition
Disk /dev/xvdf: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
[ec2-user@ip-172-31-24-248 ~]$ sudo ls -lh /dev/disk/by-path/*
lrwxrwxrwx 1 root root 10 Aug 24 06:01 /dev/disk/by-path/xen-vbd-51712 -> ../../xvda
lrwxrwxrwx 1 root root 11 Aug 24 06:01 /dev/disk/by-path/xen-vbd-51712-part1 -> ../../xvda1
lrwxrwxrwx 1 root root 10 Aug 27 13:28 /dev/disk/by-path/xen-vbd-51792 -> ../../xvdf
[ec2-user@ip-172-31-24-248 ~]$ ls -lh /dev/sd*
lrwxrwxrwx 1 root root 4 Aug 24 06:01 /dev/sda -> xvda
lrwxrwxrwx 1 root root 5 Aug 24 06:01 /dev/sda1 -> xvda1
lrwxrwxrwx 1 root root 4 Aug 27 13:28 /dev/sdf -> xvdf
[ec2-user@ip-172-31-24-248 ~]$ sudo rpm -qa | grep ec2
aws-apitools-ec2-1.7.3.0-1.0.amzn1.noarch
ec2-utils-0.4-1.22.amzn1.noarch
ec2-net-utils-0.4-1.22.amzn1.noarch
aws-amitools-ec2-1.5.6-1.1.amzn1.noarch
[ec2-user@ip-172-31-24-248 ~]$ sudo rpm -ql ec2-utils-0.4-1.22.amzn1.noarch
/etc/udev/rules.d/51-ec2-hvm-devices.rules
/etc/udev/rules.d/52-ec2-vcpu.rules
/opt/aws/bin/ec2-metadata
/sbin/ec2udev-vbd
/sbin/ec2udev-vcpu
[ec2-user@ip-172-31-24-248 ~]$ sudo rpm -ql ec2-net-utils-0.4-1.22.amzn1.noarch
/etc/dhcp/dhclient.d/ec2dhcp.sh
/etc/init/elastic-network-interfaces.conf
/etc/modprobe.d/ixgbevf.conf
/etc/sysconfig/modules/acpiphp.modules
/etc/sysconfig/network-scripts/ec2net-functions
/etc/sysconfig/network-scripts/ec2net.hotplug
/etc/udev/rules.d/53-ec2-network-interfaces.rules
/etc/udev/rules.d/75-persistent-net-generator.rules
/sbin/ec2ifdown
/sbin/ec2ifscan
/sbin/ec2ifup
/usr/share/man/man8/ec2ifdown.8.gz
/usr/share/man/man8/ec2ifscan.8.gz
/usr/share/man/man8/ec2ifup.8.gz
[ec2-user@ip-172-31-24-248 ~]$ sudo cat /opt/aws/bin/ec2-metadata
#!/bin/bash
# Copyright (C) 2006-2012 Amazon.com, Inc. or its affiliates.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
# OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the
# License.
function print_help()
{
echo "ec2-metadata v0.1.2
Use to retrieve EC2 instance metadata from within a running EC2 instance.
e.g. to retrieve instance id: ec2-metadata -i
to retrieve ami id: ec2-metadata -a
to get help: ec2-metadata --help
For more information on Amazon EC2 instance meta-data, refer to the documentation at
http://docs.amazonwebservices.com/AWSEC2/2008-05-05/DeveloperGuide/AESDG-chapter-instancedata.html
Usage: ec2-metadata <option>
Options:
--all Show all metadata information for this host (also default).
-a/--ami-id The AMI ID used to launch this instance
-l/--ami-launch-index The index of this instance in the reservation (per AMI).
-m/--ami-manifest-path The manifest path of the AMI with which the instance was launched.
-n/--ancestor-ami-ids The AMI IDs of any instances that were rebundled to create this AMI.
-b/--block-device-mapping Defines native device names to use when exposing virtual devices.
-i/--instance-id The ID of this instance
-t/--instance-type The type of instance to launch. For more information, see Instance Types.
-h/--local-hostname The local hostname of the instance.
-o/--local-ipv4 Public IP address if launched with direct addressing; private IP address if launched with public addressing.
-k/--kernel-id The ID of the kernel launched with this instance, if applicable.
-z/--availability-zone The availability zone in which the instance launched. Same as placement
-c/--product-codes Product codes associated with this instance.
-p/--public-hostname The public hostname of the instance.
-v/--public-ipv4 NATted public IP Address
-u/--public-keys Public keys. Only available if supplied at instance launch time
-r/--ramdisk-id The ID of the RAM disk launched with this instance, if applicable.
-e/--reservation-id ID of the reservation.
-s/--security-groups Names of the security groups the instance is launched in. Only available if supplied at instance launch time
-d/--user-data User-supplied data.Only available if supplied at instance launch time."
}
#check some basic configurations before running the code
function chk_config()
{
#check if run inside an ec2-instance
x=$(curl -sq http://169.254.169.254/)
if [ $? -gt 0 ]; then
echo '[ERROR] Command not valid outside EC2 instance. Please run this command within a running EC2 instance.'
exit 1
fi
}
#print standard metric
function print_normal_metric() {
metric_path=$2
echo -n $1": "
RESPONSE=$(curl -fsq http://169.254.169.254/latest/${metric_path}/)
if [ $? == 0 ]; then
echo $RESPONSE
else
echo not available
fi
}
#print block-device-mapping
function print_block-device-mapping()
{
echo 'block-device-mapping: '
x=$(curl -fsq http://169.254.169.254/latest/meta-data/block-device-mapping/)
if [ $? -eq 0 ]; then
for i in $x; do
echo -e '\t' $i: $(curl -sq http://169.254.169.254/latest/meta-data/block-device-mapping/$i)
done
else
echo not available
fi
}
#print public-keys
function print_public-keys()
{
echo 'public-keys: '
x=$(curl -fsq http://169.254.169.254/latest/meta-data/public-keys/)
if [ $? -eq 0 ]; then
for i in $x; do
index=$(echo $i|cut -d = -f 1)
keyname=$(echo $i|cut -d = -f 2)
echo keyname:$keyname
echo index:$index
format=$(curl -sq http://169.254.169.254/latest/meta-data/public-keys/$index/)
echo format:$format
echo 'key:(begins from next line)'
echo $(curl -sq http://169.254.169.254/latest/meta-data/public-keys/$index/$format)
done
else
echo not available
fi
}
function print_all()
{
print_normal_metric ami-id meta-data/ami-id
print_normal_metric ami-launch-index meta-data/ami-launch-index
print_normal_metric ami-manifest-path meta-data/ami-manifest-path
print_normal_metric ancestor-ami-ids meta-data/ancestor-ami-ids
print_block-device-mapping
print_normal_metric instance-id meta-data/instance-id
print_normal_metric instance-type meta-data/instance-type
print_normal_metric local-hostname meta-data/local-hostname
print_normal_metric local-ipv4 meta-data/local-ipv4
print_normal_metric kernel-id meta-data/kernel-id
print_normal_metric placement meta-data/placement/availability-zone
print_normal_metric product-codes meta-data/product-codes
print_normal_metric public-hostname meta-data/public-hostname
print_normal_metric public-ipv4 meta-data/public-ipv4
print_public-keys
print_normal_metric ramdisk-id /meta-data/ramdisk-id
print_normal_metric reservation-id /meta-data/reservation-id
print_normal_metric security-groups meta-data/security-groups
print_normal_metric user-data user-data
}
#check if run inside an EC2 instance
chk_config
#command called in default mode
if [ "$#" -eq 0 ]; then
print_all
fi
#start processing command line arguments
while [ "$1" != "" ]; do
case $1 in
-a | --ami-id ) print_normal_metric ami-id meta-data/ami-id
;;
-l | --ami-launch-index ) print_normal_metric ami-launch-index meta-data/ami-launch-index
;;
-m | --ami-manifest-path ) print_normal_metric ami-manifest-path meta-data/ami-manifest-path
;;
-n | --ancestor-ami-ids ) print_normal_metric ancestor-ami-ids meta-data/ancestor-ami-ids
;;
-b | --block-device-mapping ) print_block-device-mapping
;;
-i | --instance-id ) print_normal_metric instance-id meta-data/instance-id
;;
-t | --instance-type ) print_normal_metric instance-type meta-data/instance-type
;;
-h | --local-hostname ) print_normal_metric local-hostname meta-data/local-hostname
;;
-o | --local-ipv4 ) print_normal_metric local-ipv4 meta-data/local-ipv4
;;
-k | --kernel-id ) print_normal_metric kernel-id meta-data/kernel-id
;;
-z | --availability-zone ) print_normal_metric placement meta-data/placement/availability-zone
;;
-c | --product-codes ) print_normal_metric product-codes meta-data/product-codes
;;
-p | --public-hostname ) print_normal_metric public-hostname meta-data/public-hostname
;;
-v | --public-ipv4 ) print_normal_metric public-ipv4 meta-data/public-ipv4
;;
-u | --public-keys ) print_public-keys
;;
-r | --ramdisk-id ) print_normal_metric ramdisk-id /meta-data/ramdisk-id
;;
-e | --reservation-id ) print_normal_metric reservation-id /meta-data/reservation-id
;;
-s | --security-groups ) print_normal_metric security-groups meta-data/security-groups
;;
-d | --user-data ) print_normal_metric user-data user-data
;;
-h | --help ) print_help
exit
;;
--all ) print_all
exit
;;
* ) print_help
exit 1
esac
shift
done
[ec2-user@ip-172-31-24-248 ~]$ sudo cat /etc/sysconfig/network-scripts/ec2net.hotplug
#!/bin/bash
# Copyright (C) 2012 Amazon.com, Inc. or its affiliates.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
# OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the
# License.
# During init and before the network service is started, metadata is not
# available. Exit without attempting to configure the elastic interface.
if [ ! -f /var/lock/subsys/network ]; then
exit
fi
if [ -f /dev/.in_sysinit ]; then
exit
fi
. /etc/sysconfig/network-scripts/ec2net-functions
case $ACTION in
add)
plug_interface
;;
remove)
unplug_interface
;;
esac
after dettach the volume.
[ec2-user@ip-172-31-24-248 ~]$ sudo fdisk -l
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Disk /dev/xvda: 8589 MB, 8589934592 bytes, 16777216 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt
# Start End Size Type Name
1 4096 16777182 8G Linux filesyste Linux
128 2048 4095 1M BIOS boot parti BIOS Boot Partition
[ec2-user@ip-172-31-24-248 ~]$ sudo ls -lh /dev/disk/by-path/*
lrwxrwxrwx 1 root root 10 Aug 24 06:01 /dev/disk/by-path/xen-vbd-51712 -> ../../xvda
lrwxrwxrwx 1 root root 11 Aug 24 06:01 /dev/disk/by-path/xen-vbd-51712-part1 -> ../../xvda1
[ec2-user@ip-172-31-24-248 ~]$ sudo ls -lh /dev/sd*
lrwxrwxrwx 1 root root 4 Aug 24 06:01 /dev/sda -> xvda
lrwxrwxrwx 1 root root 5 Aug 24 06:01 /dev/sda1 -> xvda1
attach-a-sde-disk-dmesg-log:
Aug 27 14:14:27 ip-172-31-24-248 kernel: [288826.732292] blkfront: xvde: barrier or flush: disabled; persistent grants: disabled; indirect descriptors: enabled;
Aug 27 14:14:27 ip-172-31-24-248 kernel: [288826.746452] xvde: unknown partition table
[ec2-user@ip-172-31-24-248 ~]$ sudo ls -lh /dev/disk/by-path/*
lrwxrwxrwx 1 root root 10 Aug 24 06:01 /dev/disk/by-path/xen-vbd-51712 -> ../../xvda
lrwxrwxrwx 1 root root 11 Aug 24 06:01 /dev/disk/by-path/xen-vbd-51712-part1 -> ../../xvda1
lrwxrwxrwx 1 root root 10 Aug 27 14:14 /dev/disk/by-path/xen-vbd-51776 -> ../../xvde
[ec2-user@ip-172-31-24-248 ~]$ sudo ls -lh /dev/sd*
lrwxrwxrwx 1 root root 4 Aug 24 06:01 /dev/sda -> xvda
lrwxrwxrwx 1 root root 5 Aug 24 06:01 /dev/sda1 -> xvda1
lrwxrwxrwx 1 root root 4 Aug 27 14:14 /dev/sde -> xvde
[ec2-user@ip-172-31-24-248 ~]$ sudo fdisk -l
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Disk /dev/xvda: 8589 MB, 8589934592 bytes, 16777216 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt
# Start End Size Type Name
1 4096 16777182 8G Linux filesyste Linux
128 2048 4095 1M BIOS boot parti BIOS Boot Partition
Disk /dev/xvde: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
[ec2-user@ip-172-31-24-248 ~]$ sudo /sbin/ec2udev-vbd /dev/xvde
/dev/sde
[ec2-user@ip-172-31-24-248 ~]$ sudo /sbin/ec2udev-vbd xvde
sde
[ec2-user@ip-172-31-24-248 ~]$ sudo /sbin/ec2udev-vbd /dev/sde
/dev/sde
[ec2-user@ip-172-31-24-248 ~]$ sudo /sbin/ec2udev-vbd sde
sde
[ec2-user@ip-172-31-24-248 ~]$ sudo /sbin/ec2udev-vbd /dev/sdf
/dev/sdf
[ec2-user@ip-172-31-24-248 ~]$ sudo /sbin/ec2udev-vbd /dev/sdgg
/dev/sdgg
[ec2-user@ip-172-31-24-248 ~]$ sudo /sbin/ec2udev-vbd /dev/ddd
/dev/ddd
[ec2-user@ip-172-31-24-248 ~]$ sudo /sbin/ec2udev-vbd /dev/xvdg
/dev/sdg
[ec2-user@ip-172-31-24-248 ~]$ sudo /sbin/ec2udev-vbd /dev/xvdgg
/dev/sdgg
[ec2-user@ip-172-31-24-248 ~]$ sudo /sbin/ec2udev-vbd /dev/xvdggggg1111
/dev/sdggggg1111
[ec2-user@ip-172-31-24-248 ~]$ sudo /sbin/ec2udev-vbd /dev/xggg
/dev/xggg
[ec2-user@ip-172-31-24-248 ~]$ sudo /sbin/ec2udev-vbd /dev/xv123
/dev/xv123
[ec2-user@ip-172-31-24-248 ~]$ sudo /sbin/ec2udev-vbd /dev/xvd123
/dev/xvd123
[ec2-user@ip-172-31-24-248 ~]$ sudo /sbin/ec2udev-vbd /dev/xvda123
/dev/sda123
[ec2-user@ip-172-31-24-248 ~]$ sudo /sbin/ec2udev-vbd /dev/sdbb
/dev/sdbb
[ec2-user@ip-172-31-24-248 ~]$ sudo /sbin/ec2udev-vbd /dev/sd1234
/dev/sd1234
http://blog.csdn.net/gaoxingnengjisuan/article/details/9157977