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/10/2007 14:44: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
> > ...
> > 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.)
It was/is.
> 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
> }
Adding a delay to fsck works as can be seen at end of initialization:
====8<----------
boot device: sd0
root on sd0a dumps on sd0b
root file system type: ffs
Mon Sep 10 13:20:48 GMT 2007
swapctl: adding /dev/sd0b as swap device at priority 0
Checking for botched superblock upgrades: done.
fsck delay: umass0: using SCSI over Bulk-Only
scsibus1 at umass0L 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, 76319 cyl, 64 head, 32 sec, 512 bytes/sect x 156301488 sectors
5 10 15 20 25 30 35 40 45 50 55 60
Starting file system checks:
/dev/rsd0a: file system is clean; not checking
sd1: fabricating a geometry
/dev/rsd0e: file system is clean; not checking
/dev/rsd1k: file system is clean; not checking
/dev/rsd0f: file system is clean; not checking
/dev/rsd0g: file system is clean; not checking
Setting tty flags.
Setting sysctl variables:
Starting network.
/etc/rc: WARNING: $hostname not set.
IPv6 mode: host
Configuring network interfaces:.
Adding interface aliases:
Building database...
wsdisplay0: screen 1 added (80x25, vt100 emulation)
wsdisplay0: screen 2 added (80x25, vt100 emulation)
wsdisplay0: screen 3 added (80x25, vt100 emulation)
wsdisplay0: screen 4 added (80x25, vt100 emulation)
encoding -> us
Starting syslogd.
Checking for core dump...
savecore: no core dump
Mounting all filesystems...
Clearing /tmp
Creating a.out runtime link editor directory cache.
Checking quotas: done.
Starting virecover.
Starting local daemons:.
Updating motd.
postfix: rebuilding /etc/mail/aliases (missing /etc/mail/aliases.db)
newaliases: warning: valid_hostname: empty hostname
newaliases: fatal: unable to use my own hostname
Sep 10 05:48:40 postfix/sendmail [863]: fatal: unable to use my own hostname
Starting inetd.
Starting cron.
Mon 10 Sep 05:48:40 PDT 2007
NetBSD/i386 (Amnesiac) (console)
login:
====8<----------
I don't know how writing to the console is buffered, but while the
order of running fsck(8) on the sd0 partitions appears to follow the
order found in /etc/fstab, running fsck on the USB drive's partition
does not. This isn't an issue for me, but I wonder if it would be
problematic for someone else. This also confirms your question over
whether seq(1) would be available at the time of running the
fsck_precmd function. It appears not to be so.
As a result, I have three more questions -- two related & the other not:
0. Should USB device initialization be more deterministic/serial? Or
does the addition of this delay to fsck(8) merely mask a deeper
problem?
1. Shift-PageUp & Shift-PageDown allow scrolling through console
output. Is there a way to increase the buffer size?
Thanks, both Steven & Andy for helping provide clarification.
Jim