Running /etc/rc.local first on boot

As zpools are not imported by default in 13.0 & openzfs I have in rc.local :
zpool import -a
zfs mount -a


rcorder /etc/rc.d/* /usr/local/etc/rc.d/*
lists local script rc.local somewhat late on boot.

How can I run rc.local in the beginning on boot ?
 
Try firstboot instead of rc.local
rc.local is meant to run last by design.

Checkout /etc/rc.d/growfs for an example of firstboot.
 
Some of what can be run in rc.conf or rc.conf.local can be run in /boot/loader.conf only if it needs to be run before other services.
 
I had bad results with firstboot. The file /firstboot disappears even if you put do not removeflags on it.
I ended up editing /etc/rc.d/mountcritlocal and added this at the end, this works :
Code:
/bin/sleep 3
/sbin/zpool import -a
/sbin/zpool import -f 2296658633266446156
/sbin/zpool import -f 17441234428618508281
/sbin/zfs mount -a
The sleep 5 was needed because otherwise the pools are not imported because the USB disk is not fully spinned up.
I think it is an USB quirk.
[ Thought : Editing these rc shell scripts are a piece of cake]
 
As zpools are not imported by default in 13.0 & openzfs I have in rc.local :
zpool import -a
zfs mount -a


rcorder /etc/rc.d/* /usr/local/etc/rc.d/*
lists local script rc.local somewhat late on boot.

How can I run rc.local in the beginning on boot ?
You shouldn't have to do any custom scripting at all. /etc/rc.d/zpool is responsible for importing your pools.

So, first check whether you have this file and it contains zpool import -c $cachefile -a -N && break. Then, verify you have either /etc/zfs/zpool.cache or /boot/zfs/zpool.cache. Then verify the pool that isn't automatically imported actually uses the cachefile (zpool get cachefile <poolname>). If not, importing it once with e.g. zpool import -o cachefile=/boot/zfs/zpool.cache <poolname> should fix the problem. I can't verify cause I don't have a second pool in any of my machines.
 
If you want automatic mount > individual < encrypted dataset in ZFS pool, on boot:

update startup script on /etc/rc.d/zfs
- add line in block zfs_start { }
insert first line in this block
zfs mount -al

and where you system boot - ZFS ask you passphrase and continue booting another service.

zfs_enable_="yes" - it is a first line in rc.conf to RUN ZFS file system.
 
Back
Top