]>
git.ipfire.org Git - thirdparty/dracut.git/blob - modules.d/95nvmf/nvmf-autoconnect.sh
2 # Argument $1 is "settled", "online", or "timeout", indicating
3 # the queue from which the script is called.
4 # In the "timeout" case, try everything.
5 # Otherwise, try options according to the priorities below.
7 [ "$RD_DEBUG" != yes ] ||
set -x
9 if [ "$1" = timeout
]; then
10 [ ! -f /sys
/class
/fc
/fc_udev_device
/nvme_discovery
] \
11 ||
echo add
> /sys
/class
/fc
/fc_udev_device
/nvme_discovery
12 /usr
/sbin
/nvme connect-all
17 [ ! -f "/etc/nvme/hostnqn" ] ||
[ ! -f "/etc/nvme/hostid" ] || NVMF_HOSTNQN_OK
=1
19 # Only nvme-cli 2.5 or newer supports the options --nbft and --no-nbft
20 # for the connect-all command.
21 # Make sure we don't use unsupported options with earlier versions.
23 # shellcheck disable=SC2016
24 /usr
/sbin
/nvme connect-all
--help 2>&1 |
sed -n '/[[:space:]]--nbft[[:space:]]/q1;$q0' \
27 if [ -e /tmp
/nvmf-fc-auto
] && [ "$NVMF_HOSTNQN_OK" ] \
28 && [ -f /sys
/class
/fc
/fc_udev_device
/nvme_discovery
]; then
29 # prio 1: cmdline override "rd.nvmf.discovery=fc,auto"
30 echo add
> /sys
/class
/fc
/fc_udev_device
/nvme_discovery
33 if [ "$NBFT_SUPPORTED" ] && [ -e /tmp
/valid_nbft_entry_found
]; then
35 /usr
/sbin
/nvme connect-all
--nbft
38 if [ -f /etc
/nvme
/discovery.conf
] ||
[ -f /etc
/nvme
/config.json
] \
39 && [ "$NVMF_HOSTNQN_OK" ]; then
40 # prio 3: configuration from initrd and/or kernel command line
41 # We can get here even if "rd.nvmf.nonbft" was given, thus use --no-nbft
42 if [ "$NBFT_SUPPORTED" ]; then
43 /usr
/sbin
/nvme connect-all
--no-nbft
45 /usr
/sbin
/nvme connect-all
49 if [ "$NVMF_HOSTNQN_OK" ] \
50 && [ -f /sys
/class
/fc
/fc_udev_device
/nvme_discovery
]; then
51 # prio 4: no discovery entries, try NVMeoFC autoconnect
52 echo add
> /sys
/class
/fc
/fc_udev_device
/nvme_discovery