this isn't a problem by itself, but i want to know what the mechanism for it is, as i can't tell just by reading the rc script itself.
the reason i want to know is that i have a custom rc script which i use to mount a usb thumb drive, containing my zfs keys, on boot, before the
i do have this working, but it only runs once, right before and after the first invocation of
for the remount
as it turns out, everything still works because all the filesystems i need are needed during that first mounting when
this is the mounting script:
and the unmounting script:
the reason i want to know is that i have a custom rc script which i use to mount a usb thumb drive, containing my zfs keys, on boot, before the
zfskeys rc script, and then after zfskeys is run, i want to unmount the thumb drive.i do have this working, but it only runs once, right before and after the first invocation of
zfskeys. a bit after that the rc system remounts everything (i don't know why, but i assume this is a two-stage thing where critical filesystems are mounted, then at some point later all filesystems are mounted).for the remount
zfskeys is invoked again somehow, but my rc scripts which are supposed to run around zfskeys do not run and the second zfskeys invocation throws an error about being unable to load keys from my thumb drive.as it turns out, everything still works because all the filesystems i need are needed during that first mounting when
zfskeys can load things from the thumb drive, but i'd like my scripts to be more robust and i don't like having errors during boot.this is the mounting script:
sh:
#!/bin/sh
# PROVIDE: zkeysmount
# REQUIRE: zpool
# BEFORE: zfskeys
. /etc/rc.subr
name="zkeysmount"
desc="mount removable storage with zfs keys"
rcvar="zkeysmount_enable"
required_modules="zfs"
start_cmd="mount_zkeys"
stop_cmd=":"
: ${zkeysmount_device:='/dev/gpt/zkey'}
: ${zkeysmount_fstype:='msdos'}
: ${zkeysmount_options:=''}
: ${zkeysmount_mountpoint:='/zkey'}
mount_zkeys()
{
logger -t $name "mounting ${zkeysmount_device} on ${zkeysmount_mountpoint}"
mount -t "${zkeysmount_fstype}" ${zkeysmount_options} "${zkeysmount_device}" "${zkeysmount_mountpoint}"
}
load_rc_config $name
run_rc_command "$1"
and the unmounting script:
sh:
#!/bin/sh
# PROVIDE: zkeyunmount
# REQUIRE: zkeysmount zfskeys
# BEFORE: LOGIN
. /etc/rc.subr
name="zkeysunmount"
desc="unmount removable storage with zfs keys"
rcvar="zkeysmount_enable"
required_modules="zfs"
start_cmd="unmount_zkeys"
stop_cmd=":"
: ${zkeysmount_device:='/dev/gpt/zkey'}
: ${zkeysmount_fstype:='msdos'}
: ${zkeysmount_options:=''}
: ${zkeysmount_mountpoint:='/zkey'}
unmount_zkeys()
{
logger -t $name "unmounting ${zkeysmount_mountpoint}"
umount "${zkeysmount_mountpoint}"
}
load_rc_config $name
run_rc_command "$1"