Suggestions for working with unstable nvme dev names in AWS

Matthew Seaman matthew at
Wed May 15 08:05:37 UTC 2019

On 14/05/2019 22:01, George Hartzell wrote:
> But when I boot, I find that I have two devices (in addition to the
> root device), `/dev/nvme1` and `/dev/nvme2`.  There's no way to know
> which is the big-slow one that I wanted to call `/dev/sdh` and which
> is the small-fast `/dev/sdz`.  In fact, if I reboot the machine,
> sometimes the big-slow one will be `/dev/nvme1` and sometimes it will
> be `/dev/nvme2`.
> Given that situation, how do you write an automated script that will
> label the big-slow one `backups` and the small-fast one `speedy`?

This is a pretty difficult problem.  Unless AWS can supply some sort of
identification of the device beyond the /dev/nvme1 device specials or
else somehow guarantee ordering so the device names are consistent
across multiple EC2 instances then about your only possible choice is to
develop some heuristics like "if the device is 300MB in size then it's
the special high-IOPS device I want to use for my separate zlog."

You should be able to do that with the facts generated by ansible for
example.  You can use '{{ jinja2 }}' contexts to pretty much run
arbitrary code within your playbooks based on those facts, so you can
eg. generate a label name based on the disk size.

It's not ideal, and it means that if you ever amend the spec for the
instances you're running up, then you will probably need to
simultaneously modify your heuristics.

Hmmm.... camcontrol(8) might be a possibility.  You'll have to
experiment though -- e.g.  see if 'camcontrol inquiry' or 'camcontrol
devlist' gives  you enough information to distinguish the different
types of devices you can specify.

Another thing to investigate is devd(8) which you can use to trigger an
arbitrary command based on parameters discovered when the kernel probes
the device.  Again, it's not clear if there will be suitable information
in the kernel probe results for you to make the sort of distinction you
want to.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 963 bytes
Desc: OpenPGP digital signature
URL: <>

More information about the freebsd-questions mailing list