forked from cperciva/ec2-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ec2_ephemeral_diskseen
44 lines (35 loc) · 1.14 KB
/
ec2_ephemeral_diskseen
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
#!/bin/sh
# REQUIRE: FILESYSTEMS
# PROVIDE: ec2_ephemeral_diskseen
# KEYWORD: shutdown
# This script is *on by default* because it's essential to collect a list
# of ephemeral disks at boot time for reference the next time the system
# boots -- otherwise if the system administrator enables ec2_ephemeralswap
# and reboots, any data stored on the ephemeral disks may be lost.
# DISABLE THIS AT YOUR OWN RISK!
: ${ec2_ephemeral_diskseen_enable=YES}
. /etc/rc.subr
name="ec2_ephemeral_diskseen"
rcvar=ec2_ephemeral_diskseen_enable
start_cmd="ec2_ephemeral_diskseen_run"
stop_cmd=":"
EBSNVMEID=/usr/local/sbin/ebsnvme-id
ec2_ephemeral_diskseen_run()
{
# We could use the /dev/aws/disk/* tree, but that's generated by
# dev_aws_disk which might be turned off. Instead, check out all
# the disks by running ebsnvme-id ourselves.
: > /var/db/ec2_ephemeral_diskseen
for DISK in `ls /dev/nda* /dev/nvd*`; do
if [ -L $DISK ]; then
continue
fi
case `${EBSNVMEID} -m $DISK 2>/dev/null` in
"Amazon EC2 NVMe Instance Storage")
${EBSNVMEID} -s $DISK >> /var/db/ec2_ephemeral_diskseen
;;
esac
done
}
load_rc_config $name
run_rc_command "$1"