2

I have a FreeBSD 10.2 server that I mount iSCSI drives to. I would like to have those drives mounted automatically in fstab so that they are persistent across reboots.

If I execute the command

mount /dev/da0p1 /mnt

It works perfectly.

mount
/dev/ada0p2 on / (ufs, local, journaled soft-updates)
devfs on /dev (devfs, local, multilabel)
/dev/da0p1 on /mnt (ufs, local, soft-updates)

However, if I put an entry in /etc/fstab the system halts its boot processes saying that /dev/dap1 is invalid. I am assuming that this is because networking and iscsi services are not up yet.

In my /etc/fstab I have added the "late" option for the filesystem I want to mount, but it dosen't have any effect.

# cat /etc/fstab
# Device    Mountpoint  FStype  Options Dump    Pass#
/dev/ada0p2     /       ufs     rw        1        1
/dev/ada0p3    none     swap    sw        0        0


#User Added Entries
#/dev/da0p1      /mnt            ufs     rw,late  3       3

What happens is that the boot process stops saying that there is "no file or directory /dev/da0p1. If I do a ls /dev/da* that directory shows up. (see image below) enter image description here

In fact, after some testing, if I just wait a few seconds, and type "exit" at the prompt in single user mode, the system continues to boot and the drives get mounted normally.

Is there a way to put in a 5 second delay to allow the iscsi device to be created so the mount doesn't fail?

3 Answers 3

2

Disclaimer: I don't know if this is the right thing to do, but it worked for me.

So, I essentially needed the startup process to take a little extra time so that networking services could finish loading and the iSCSI mounts could be created so there would be something to mount to.

What I did was add sleep 5 to the /etc/rc.d/mountlate script.

# PROVIDE: mountlate
# REQUIRE: DAEMON
# BEFORE: LOGIN
# KEYWORD: nojail

. /etc/rc.subr

name="mountlate"
start_cmd="mountlate_start"
stop_cmd=":"

mountlate_start()
{
        local err latefs
        sleep 5               <-------- Added this line
        # Mount "late" filesystems.
        #
        err=0

5 seconds seemed to be a good number for me; your mileage may vary and you will want test out different values.

Again, I don't know if this is the correct way of solving this particular issue and if someone has a better or the correct way, please post.

1

The best solution for now (requires FreeBSD 11.0+), seems to be:

  • fstab entry with:
    • 'late' option (to not slow down the boot process)
    • 'failok' option (to not go into single user mode in case of iSCSI connect error)
    • dump/pass value sets to 0
  • add "-w 10" to iscsictl_flags in rc.conf so iscsictl will wait for iscsi connection (10 secs max)

/etc/fstab:

/dev/PARTITION.journal         /mnt         ufs     rw,async,failok,late     0       0

/etc/rc.conf:

iscsictl_enable="YES"
iscsictl_flags="-Aa -w 10"
iscsid_enable="YES"

PS: I don't know why, but I'm not able to use GPT labels on iSCSI (it works on creation, but on reboot the label is here - shown by 'gpart show -l' - but not available in /dev/gpt/).

1
  • And to prevent server to go in single mode in case of mount error, you may need to add "failok" to options. May 2, 2018 at 17:29
0

I found that I did not need to add the sleep to /etc/rc.d/mountlate. Instead, I changed the dump number to 0 and the fsck pass number to 0 in /etc/fstab. No fsck is run at boot but, the partition is mounted:

/dev/da0p1      /opt            ufs     rw,late 0       0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .