From owner-freebsd-current@freebsd.org Tue May 22 14:48:14 2018 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8EFF6EF8BE5 for ; Tue, 22 May 2018 14:48:14 +0000 (UTC) (envelope-from freebsd-rwg@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E3D1378F18 for ; Tue, 22 May 2018 14:48:13 +0000 (UTC) (envelope-from freebsd-rwg@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (localhost [127.0.0.1]) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3) with ESMTP id w4MEm9fr030595; Tue, 22 May 2018 07:48:09 -0700 (PDT) (envelope-from freebsd-rwg@pdx.rh.CN85.dnsmgr.net) Received: (from freebsd-rwg@localhost) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3/Submit) id w4MEm9ra030594; Tue, 22 May 2018 07:48:09 -0700 (PDT) (envelope-from freebsd-rwg) From: "Rodney W. Grimes" Message-Id: <201805221448.w4MEm9ra030594@pdx.rh.CN85.dnsmgr.net> Subject: Re: How to check if not clean shutdown? In-Reply-To: To: Johannes Lundberg Date: Tue, 22 May 2018 07:48:09 -0700 (PDT) CC: Warner Losh , freebsd-current X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 May 2018 14:48:14 -0000 > On Tue, May 22, 2018 at 3:30 PM, Warner Losh wrote: > > > You can't, in general. By the time the boot loader starts, all knowledge > > of past boots is gone, unless specific counter-measures were put in place. > > > > However, if root is UFS and read/write in your box, it will be unclean on > > anything but a clean shutdown/reboot. If it's read-only, ZFS or NFS > > mounted, then you can't use this method. > > > > If you have UEFI, you can set a UEFI variable on shutdown and clear it on > > boot. If it's not there on boot, you had an unclean shutdown. You could do > > the same with a file in a r/w filesystem that doesn't record clean/unclean > > (like ZFS or NFS). > > > > Locally, we have hacks to IPMI to record kernel crashes in the IPMI log, > > but that's kinda specific to the BMC we have on our boards... > > > > Warner > > > > I see. Thanks for the quick reply. > I guess I can add a dummy file somewhere that I delete in a shutdown hook. utmp has one attempt at keeping track of this by recording a shutdown record. > > On Tue, May 22, 2018 at 7:57 AM, Johannes Lundberg > > wrote: > > > >> Hi > >> > >> In the boot process on my test machines I'd like to do different things > >> depending on the last run was a clean shutdown or kernel panic. Where/How > >> can I get this information? > >> > >> Thanks! > >> _______________________________________________ > >> freebsd-current@freebsd.org mailing list > >> https://lists.freebsd.org/mailman/listinfo/freebsd-current > >> To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org > >> " > >> > > > > > _______________________________________________ > freebsd-current@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org" > -- Rod Grimes rgrimes@freebsd.org