From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BEED6C433DB for ; Wed, 20 Jan 2021 16:55:16 +0000 (UTC) Received: from mail.server123.net (mail.server123.net [78.46.64.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 23C7D23358 for ; Wed, 20 Jan 2021 16:55:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 23C7D23358 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=wagner.name Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-crypt-bounces@saout.de X-Virus-Scanned: amavisd-new at saout.de Received-SPF: None (mailfrom) identity=mailfrom; client-ip=84.19.178.47; helo=v1.tansi.org; envelope-from=arno@wagner.name; receiver= Received: from v1.tansi.org (mail.tansi.org [84.19.178.47]) by mail.server123.net (Postfix) with ESMTP for ; Wed, 20 Jan 2021 17:54:23 +0100 (CET) Received: from gatewagner.dyndns.org (81-6-44-245.init7.net [81.6.44.245]) by v1.tansi.org (Postfix) with ESMTPA id 8DFD4140047 for ; Wed, 20 Jan 2021 17:54:23 +0100 (CET) Received: by gatewagner.dyndns.org (Postfix, from userid 1000) id BD0A217A22E; Wed, 20 Jan 2021 17:54:22 +0100 (CET) Date: Wed, 20 Jan 2021 17:54:22 +0100 From: Arno Wagner To: dm-crypt@saout.de Message-ID: <20210120165422.GA13151@tansi.org> Mail-Followup-To: dm-crypt@saout.de References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Subject: Re: [dm-crypt] Recover from Spontaneous Ejection X-BeenThere: dm-crypt@saout.de X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dm-crypt-bounces@saout.de Sender: "dm-crypt" You may run into the issue where that SD cards (like SSDs) may actually use larger block-sizes than exposed at the interface. Hence interrupting a write may damage parts that were not requested to be written. SSDs have that mostly under control now, I think, probably by adding some more complex commit schemes. But SD cards have far less comuting power and may not do that. Regards, Arno On Wed, Jan 20, 2021 at 12:06:24 CET, Frederick Gotham wrote: > > I'm developing a product running embedded Linux. > > We have an SDcard with one partition on it, and this partition is an > encrypted LUKS volume. > > While the SDcard is mounted, the user can spontaneously eject the > SDcard. I have successfully altered the UDEV script to handle this > eventuality, as follows: > > umount /mnt/sdcard > cryptsetup luksClose cryptocard > > Then when the user re-inserts the SDcard after a spontaneous ejection, > I try to re-mount it again. So the entire process from start to finish > goes as follows: > > echo -n password | cryptsetup luksOpen /dev/sdb1 cryptocard - > mount /dev/mapper/cryptocard /mnt/sdcard > [ User spontaneously ejects SDcard ] > umount /mnt/sdcard > cryptsetup luksClose cryptocard > [ ... ... ... 1 minute goes by ... ... ... ] > [ User re-inserts SD card ] > echo -n password | cryptsetup luksOpen /dev/sdb1 cryptocard - > mount /dev/mapper/cryptocard /mnt/sdcard > > This appears to work just fine, however when I try to do more complex > write operations, it starts to freak out a little (files that were > previously visible are no longer visible). When I reboot the machine, > everything's working fine again. > > So it seems that the system is not adequately recovering from the > spontaneous ejection of the SDcard. Do I need to somehow "flush out" > the LUKS system in order to successfully re-mount the volume? Is it > possible to 'restart' the LUKS subsystem to get this to work properly > again? I only ever have one LUKS volume open at a time so I don't have > to worry about closing other volumes before 'flushing out'. > > Frederick > _______________________________________________ > dm-crypt mailing list > dm-crypt@saout.de > https://www.saout.de/mailman/listinfo/dm-crypt -- Arno Wagner, Dr. sc. techn., Dipl. Inform., Email: arno@wagner.name GnuPG: ID: CB5D9718 FP: 12D6 C03B 1B30 33BB 13CF B774 E35C 5FA1 CB5D 9718 ---- A good decision is based on knowledge and not on numbers. -- Plato If it's in the news, don't worry about it. The very definition of "news" is "something that hardly ever happens." -- Bruce Schneier _______________________________________________ dm-crypt mailing list dm-crypt@saout.de https://www.saout.de/mailman/listinfo/dm-crypt