Subject: Re: initialization order & permanently mounting USB drives?
To: James Hartley <jjhartley@gmail.com>
From: Steven M. Bellovin <smb@cs.columbia.edu>
List: netbsd-users
Date: 09/10/2007 10:16:27
On Mon, 10 Sep 2007 00:29:36 -0700
"James Hartley" <jjhartley@gmail.com> wrote:
> Although I suspect the answer is to add mount(8) commands to
> /etc/rc.local, I'll ask anyways...
>
> 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. Below is the contents of /etc/fstab:
>
> # NetBSD /etc/fstab
> # See /usr/share/examples/fstab/ for more examples.
> /dev/sd0a / ffs rw 1 1
> /dev/sd0b none swap sw 0 0
> /dev/sd0e /usr ffs rw 1 2
> /dev/sd0f /var ffs rw 1 2
> /dev/sd0g /home ffs rw 1 2
> /dev/sd0b /tmp mfs rw,-s=263070
> kernfs /kern kernfs rw
> procfs /proc procfs rw,noauto
> /dev/sd1k /mnt ffs rw 1 2
>
> ...where the desired USB drive partition is /dev/sd1k. Yet at boot, I
> see the following at the end of the displayed dmesg:
>
> Starting file system checks:
> /dev/rsd0a: file system is clean; not checking
> Can't open /dev/sd1k: Device not configured
> CAN'T CHECK FILESYSTEM.
> /dev/rsd1k: UNEXPECTED INCONSISTENCY; RUN fsck_ffs MANUALLY.
> /dev/rsd0e: file system is clean; not checking
> /dev/rsd0f: file system is clean; not checking
> /dev/rsd0g: file system is clean; not checking
> THE FOLLOWING FILE SYSTEM HAD AN UNEXPECTED INCONSISTENCY: ffs:
> /dev/rsd1k (/mnt)
> Automatic file system check failed; help!
> Sep 9 23:12:01 init: '/bin/sh' on '/etc/rc' terminated abnormally,
> going to single user mode
> Enter pathname of shell or RETURN for /bin/sh: umass0 at uhub4 port 3
> configuration 1 interface 0
> umass0: Genesys Logic USB TO IDE, rev 2.00/0.33, addr 3
> umass0: using SCSI over Bulk-Only
> scsibus1 at umass0: 2 targets, 1 lun per target
> sd1 at scsibus1 target 0 lun 0: <ST980821, 0A, 0811> disk fixed
> sd1: fabricating a geometry
> sd1: 76319 MB, 76219 cyl, 64 head, 32 sec, 512 bytes/sect x 156301488
> sectors #
This is rather weird, since I can't think of anything that would make
it recognize the USB drive at that point and not earlier. (I assume it
was plugged in at boot time.) OTOH, it may just be a timing issue;
it's not going to recognize the USB drive until after init takes
control, I believe, and running fsck is about the first thing that will
happen after that.
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
}
If that works, you can either shorten the delay or figure out some
clever way to tell if the drive has appeared yet.
--Steve Bellovin, http://www.cs.columbia.edu/~smb