# problems with fstab priorities when booting from zfs



## mamalos (Jan 9, 2012)

Hi all,

I have set up a FreeBSD server that boots from *zfs*, using this guide: https://www.dan.me.uk/blog/2010/02/08/booting-from-zfs-raid0156-in-freebsd/.

Inside my pool, I have added the following partitions:


```
zfs list
NAME              USED  AVAIL  REFER  MOUNTPOINT
zroot            8.33G   897G   668M  legacy
zroot/home         94K   897G    94K  /home
zroot/jails      3.54G   897G  3.54G  /jails
zroot/tmp        45.5K   897G  45.5K  /tmp
zroot/usr        4.03G   897G   311M  /usr
zroot/usr/local   210M   897G   210M  /usr/local
zroot/usr/obj    2.43G   897G  2.43G  /usr/obj
zroot/usr/ports   428M   897G   428M  /usr/ports
zroot/usr/src     691M   897G   691M  /usr/src
zroot/var         103M   897G   102M  /var
zroot/var/crash  31.5K   897G  31.5K  /var/crash
zroot/var/log     553K   897G   553K  /var/log
zroot/var/run      73K   897G    73K  /var/run
```

On my /etc/fstab I have some entries that perform *nullfs* mounting of some jailed filesystems, like this:


```
head -10 /etc/fstab
# Device	Mountpoint	FStype	Options	Dump	Pass#
/dev/gpt/swap0	none		swap	sw	0	0
/dev/gpt/swap1	none		swap	sw	0	0

/jails/j/mroot		/jails/j/redmine	nullfs	ro	0	0
/jails/j/mroot		/jails/j/ftp		nullfs	ro	0	0
/jails/j/mroot		/jails/j/apache		nullfs	ro	0	0

/jails/s/apache		/jails/j/apache/s	nullfs	ro	0	0
```

The thing is that when the system boots and *init* tries to mount these filesystems, it fails by giving me the following error:


```
...blabla
Mounting local file systems: mount: /jails/j: No such file or directory
.
Mounting /etc/fstab filesystems failed, startup aborted
...blabla
Enter full pathname of shell or RETURN for /bin/sh:
```

When I press RETURN and give: 

`#  zfs mount -a && mount -a && exit`

everything works just fine.

This means that my /etc/fstab entries are fine, but when the system tries to find /jail it fails because it is not mounted at that time. If I comment all entries in /etc/fstab that have to do with my jail setup, all my *zfs* filesystems are mounted as should.

excerpt from /etc/rc.conf:

```
zfs_enable="YES"
```

/boot/loader.conf reads:

```
vfs.zfs.prefetch_disable="1"
vfs.root.mountfrom="zfs:zroot"
zfs_load="YES"
```

Thank you all for your time in advance.


----------



## SirDice (Jan 9, 2012)

Add the keyword *late* to /etc/fstab for the filesystems that need to be mounted 'later'.

Another option, which I use myself, is to move all the filesystems that belong to a jail to the jail's fstab.

For example, if you have a jail named *redmine* in /etc/rc.conf create a file called /etc/fstab.redmine and add this to it:

```
/jails/j/mroot /jails/j/redmine nullfs ro 0 0
```
This will mount that filesystem when the jail starts.


----------



## mamalos (Jan 9, 2012)

Bravo SirDice, always helpful and to the point .


----------

