geom vs. removable disks/cards (was: Re: random problem with 8.3 from yesterday)

Ian Lepore freebsd at
Sat Feb 25 18:23:04 UTC 2012

On Sat, 2012-02-25 at 07:55 +0100, Juergen Lock wrote:
> In article <1330126840.7317.60.camel at revolution.hippie.lan> you write:
> >On Sat, 2012-02-25 at 00:39 +0200, Andriy Gapon wrote:
> >> on 24/02/2012 18:23 Ian Lepore said the following:
> >> > I've always
> >> > suspected something in the geom layer isn't noticing that a CF or SD
> >> > card in the reader got removed/inserted/reformatted, and un-/re-plugging
> >> > the whole reader (making the cam layer destroy and recreate the devices)
> >> > makes geom aware of the change.
> >> 
> >> This is a fact, actually.  Nothing in GEOM layer (and below it) notices a silent
> >> card change, since most hardware doesn't have any notification for the change
> >> and FreeBSD disk stack doesn't do any polling for changes.
> >> 
> >
> >If the hardware did have change notification, is there a mechanism that
> >would communicate that to geom?  That's a precursor question to my real
> >question:  is there a way to manually kick geom when necessary?  If the
> >api exists but there's no userland app to make the needed calls, I'll
> >write some code -- just point me at a manpage or header file.
> scsi has a mechanism called unit attention to report things like
> media changes, not sure usb devices use that tho since the host can
> only poll them...
>  Anyway, the usual workaround is to force a geom retaste by opening
> the device for writing without actually writing anything, e.g.:
> 	# : >/dev/da0
>  Btw this can't be Erich's problem I'd say since he said he's
> plugging in a thumbdrive not a card into a reader (and also writing
> /dev/zero to it) so geom _should_ already taste it.  (Unless the
> write fails since the thumbdrive is too slow initializing or something
> like that...)
>  HTH,
> 	Juergen

I was a bit concerned that the similarities between Erich's symptoms and
mine were purely superficial, with different underlying causes.  I've
never seen the stale geom data problem I described on a thumb drive,
except when I've used dd to zero out the beginning of a drive that was
gpt-formatted but left the backup partition table at the end of the
drive -- that always causes me problems that only get fixed by using
gpart destroy -F.

Thanks for the tip about forcing a re-taste, I think I'll be using that
a bunch.

-- Ian

More information about the freebsd-stable mailing list