Subject: Re: initialization order & permanently mounting USB drives?
To: Steven M. Bellovin <smb@cs.columbia.edu>
From: James Hartley <jjhartley@gmail.com>
List: netbsd-users
Date: 09/13/2007 15:47:27
On 9/10/07, Steven M. Bellovin <smb@cs.columbia.edu> wrote:
> On Mon, 10 Sep 2007 00:29:36 -0700
> "James Hartley" <jjhartley@gmail.com> wrote:
> > ...
> > I'd like to mount multiple partitions on a USB drive at system
> > startup.  If I add the appropriate entries to /etc/fstab, the order of
> > initialization appears to check /etc/fstab before the USB drive is
> > detected.
> > ...
> ...
> For fun, put the following into /etc/rc.conf.d/fsck and see what
> happens:
>
> start_precmd=fsck_precmd
> fsck_precmd() {
>         echo -n "fsck delay:"
>         # Could use seq(1), but it's in /usr/bin which may not be there
>         for i in 5 10 15 20 25 30 35 40 45 50 55 60
>         do
>                 sleep 5
>                 echo -n " $i"
>         done
>         echo
> }

To recap, the above suggestion worked in delaying fsck(8)'s checking
until the USB partitions had been properly mounted.  Thank you Steven
for mentioning it.

Given that I had a swap partition defined on the same drive, I boldly
placed an appropriate entry in /etc/fstab to increase the amount of
swap space available to the system.  Given that swapctl(8) initializes
all swap partitions before fsck performs its checks, I saw...

swapctl: adding /dev/sd0b as swap device at priority 0
swapctl: /dev/sd1b: Device not configured

During shutdown, I would see:

swapctl: removing /dev/sd0b as swap space
swapctl: /dev/sd1b: Device not configured

...where sd0 is the boot drive & sd1 is the USB drive.

Naively, I experimented by adding /etc/rc.conf.d/swapctl containing
the following:

$ cd /etc/rc.conf.d
$ cat swapctl
start_precmd=swapctl_precmd
swapctl_precmd() {
    n=30
    echo -n "delaying swapctl for $n seconds..."
    sleep $n
    echo
}
$

...but I see no evidence that this function is executed at all.  The
output during initialization is the same as before.

Is there a way to delay swapctl(8) during boot time?  Likewise, is
there a list of what utilities can be modified at boot time?  I
haven't found anything yet through Google...

Thanks for any candor shared.

Jim