From nobody Sun Dec 26 22:47:09 2021 X-Original-To: freebsd-arm@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id EEC921920F26 for ; Sun, 26 Dec 2021 22:47:11 +0000 (UTC) (envelope-from fbsd@www.zefox.net) Received: from www.zefox.net (www.zefox.net [50.1.20.27]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "www.zefox.com", Issuer "www.zefox.com" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JMbXH4gp1z4pKc for ; Sun, 26 Dec 2021 22:47:11 +0000 (UTC) (envelope-from fbsd@www.zefox.net) Received: from www.zefox.net (localhost [127.0.0.1]) by www.zefox.net (8.16.1/8.15.2) with ESMTPS id 1BQMlAvx016907 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sun, 26 Dec 2021 14:47:10 -0800 (PST) (envelope-from fbsd@www.zefox.net) Received: (from fbsd@localhost) by www.zefox.net (8.16.1/8.15.2/Submit) id 1BQMlABS016906; Sun, 26 Dec 2021 14:47:10 -0800 (PST) (envelope-from fbsd) Date: Sun, 26 Dec 2021 14:47:09 -0800 From: bob prohaska To: marklmi@yahoo.com Cc: freebsd-arm@freebsd.org Subject: Re: Hot-plugging microSD on Raspberry Pi under FreeBSD Message-ID: <20211226224709.GB16188@www.zefox.net> References: <20211226192338.GA16188@www.zefox.net> <91D4CF6B-5690-413D-A873-2DB50CAF9637@yahoo.com> List-Id: Porting FreeBSD to ARM processors List-Archive: https://lists.freebsd.org/archives/freebsd-arm List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-arm@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <91D4CF6B-5690-413D-A873-2DB50CAF9637@yahoo.com> X-Rspamd-Queue-Id: 4JMbXH4gp1z4pKc X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N On Sun, Dec 26, 2021 at 01:00:38PM -0800, Mark Millard via freebsd-arm wrote: > On 2021-Dec-26, at 11:23, bob prohaska wrote: > > > > > Obviously filesystems have to be gracefully unmounted, but is > > that all? Can the kernel be "aware" of an unused device and > > get confused if it goes away? > > As I remember, for FreeBSD, > > A) The built-in microsd card slot works fine for swapping > media that are not mounted at the time. Ok, that's reassuring. I observed corruption of microSD card FAT partitionss and wondered if hot-plugging might be the cause. > > but, for example (no mounts involved, RPi4B 8GiByte test context), > > B.0) Plug-in the USB reader, no media present. (USB3 example here.) > B.1) Insert a 128 GiByte media to the reader. > B.2) Remove that media. > B.3) Insert a 32 GiByte media to the reader > (same slot in the reader). > > Result: > > (da4:umass-sim1:1:0:3): READ(10). CDB: 28 00 0e e2 af ff 00 00 01 00 [...disk errors snipped....] Was the Pi4 running from a USB hard disk? I ask because plugging in a USB reader to my RasPiOS Pi4 while booted from a USB hard disk seems to disrupt communication with the boot drive. It doesn't crash immediately but can't be gracefully rebooted. > If you do the 32 GiByte first instead, then for the 128 GiByte you > get notices from GEOM_PART about "was automatically resized" > but it does not "address out of range". That seems like the "confusion" I was wondering about. The kernel notices the first card insertion, fails to notice the removal and then mis-attributes the change to a partition resize. > I expect that swapping two media of the same capacity would > be less likely to generate any messages, but that does not > mean that such a swap would be handled fully correctly. > > So I unplug the whole reader to swap media. This is messier > if multiple slots are in use (more unmounts and later > remounts). That chain of events crashes my RasPiOS Pi4, at least when it's also booted from a USB drive. Thanks for writing! bob prohaska