# vm starts earlier than iSCSI-target



## Pavel Vashurin (Apr 23, 2020)

Hello!
Sorry for the bad english then google translate.
I had such a problem.
FreeNAS-11.3_U2 server with configured iscsi-target. The FreeBSD-12.1 client is configured to initiate, everything is fine with it, but vm is trying to start with me before the initiation passes and the partition is mounted. As a result, the error / usr / local / sbin / vm: ERROR: $ vm_dir has not been configured or is not a valid directory. What am I doing wrong?

-
Pavel Vashurin


----------



## usdmatt (Apr 23, 2020)

What does the output of `service -e` look like?


----------



## Pavel Vashurin (Apr 24, 2020)

After reboot

```
root@admin-pc:/home/admin # service -e
/etc/rc.d/hostid
/etc/rc.d/hostid_save
/etc/rc.d/cleanvar
/etc/rc.d/kldxref
/etc/rc.d/ip6addrctl
/etc/rc.d/netif
/etc/rc.d/devd
/etc/rc.d/resolv
/etc/rc.d/newsyslog
/etc/rc.d/syslogd
/etc/rc.d/ntpdate
/etc/rc.d/savecore
/etc/rc.d/dmesg
/etc/rc.d/iscsid
/etc/rc.d/iscsictl
/etc/rc.d/virecover
/usr/local/etc/rc.d/dbus
/usr/local/etc/rc.d/vm
/usr/local/etc/rc.d/tor
/usr/local/etc/rc.d/hald
/etc/rc.d/motd
/etc/rc.d/rctl
/usr/local/etc/rc.d/sddm
/etc/rc.d/sshd
/etc/rc.d/sendmail
/etc/rc.d/cron
/etc/rc.d/mixer
/etc/rc.d/gptboot
/etc/rc.d/devmatch
/etc/rc.d/bgfsck
root@admin-pc:/home/admin #
```


----------



## Pavel Vashurin (May 6, 2020)

What happened? No one answers, I asked a too complicated question?


----------



## usdmatt (May 6, 2020)

It's not really clear what the correct fix is. It seems that vm is set to start after iscsictl, so you would expect any iscsi devices to be mounted before vm starts, but then I have practically no experience with the iscsi client. How is the iscsi file system mounted, is it in fstab? does it have the late option set?


----------



## Eric A. Borisch (May 7, 2020)

So your configuration directory is on a file system
mounted off an iscsi device? It that correct? (I suppose you could, but it seems an overly complicated choice for a small configuration directory.)

You’ve gone through the `vm init` process described in vm(8)? And vm_dir is set in /etc/rc.conf (or /usr/local/etc/rc.conf, etc.)?


----------



## Pavel Vashurin (May 7, 2020)

/etc/rc.conf


```
vm_dir="/vmroot/bhyve"
vm_enable="YES"
vm_list=""
vm_delay="85"
iscsictl_enable="YES"
icsictl_flags="-Aa -w 10"
iscsid_enable="YES"
```

/etc/fstab

```
# Device        Mountpoint      FStype  Options Dump    Pass#
/dev/ada0s1a    /               ufs     rw      1       1
/dev/ada0s1b    none            swap    sw      0       0
/dev/da0p1      /vmroot         ufs     rw,late 0       0   #   iSCSI device
```


----------



## usdmatt (May 7, 2020)

Hmm, you have the late option and it looks like these are mourned after the normal startup of vm.

Try modifying the vm rc.d file. Remove the entries from the “BEFORE” line and set the “REQUIRE” line to just “LOGIN”.

This should force vm to start later in the boot order


----------



## Pavel Vashurin (May 8, 2020)

usdmatt said:


> Hmm, you have the late option and it looks like these are mourned after the normal startup of vm.
> 
> Try modifying the vm rc.d file. Remove the entries from the “BEFORE” line and set the “REQUIRE” line to just “LOGIN”.
> 
> This should force vm to start later in the boot order



Thanks a lot, usdmatt! Everything worked out for me.


----------

