From owner-freebsd-current@freebsd.org Tue May 22 14:36:19 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 F3A70EF8395 for ; Tue, 22 May 2018 14:36:18 +0000 (UTC) (envelope-from johalun0@gmail.com) Received: from mail-wm0-x22c.google.com (mail-wm0-x22c.google.com [IPv6:2a00:1450:400c:c09::22c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7095A784B7 for ; Tue, 22 May 2018 14:36:18 +0000 (UTC) (envelope-from johalun0@gmail.com) Received: by mail-wm0-x22c.google.com with SMTP id o78-v6so465317wmg.0 for ; Tue, 22 May 2018 07:36:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=T7WfPU0bXzNIOD/M3+bCCnuY7XxRpDiLbG9nB73YXPw=; b=Ffwa5HQb74qq5YicnOkceJa3ge983n/suX5sYoPRAASZ+e6HHKlQWcrRL6x8yNWEzI WS2VSzd3KUv+liMhZrLzpQWswtsg2IWVNsgPXseXXzl+9KzSmwudmqOdKRVNbv9tCUoX HQze+pXnx7ktNdKwXLh28AWI65cfGHMnGSIX1xkBCgGYevS11/T74TXY7i7tbv6kTC3s holFK0tur3K2KhRc0bfgxtcuFsBSJfb102edifV7ZnWTor4iEvQ4U8qDxSz6ANJMwIij ZGY4fJyVcc03ewj07/5yCzuCTqyRe/wrc4EsjwD1qojFx/mzsNQbH+hbC/KMIKgF4y1M S/oQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=T7WfPU0bXzNIOD/M3+bCCnuY7XxRpDiLbG9nB73YXPw=; b=ujDNIcxPRHhgYdPpizqBxj+O/Mx0cT/XoF2AGdn/K/Wc3QRDcohE8QjOoT+wcH5TUX hTKURZsNfqRlD+Oi57H73pbNy+En9bovIEQQKx5k74w8OICuMMHvQU4ilKtF90Hill12 AkLCbemf/R0YDuHzz+/nQLZM9fmCVUbiawfBtHd+ZgX11km5/QqbFIGfRjoGG/iZjywa eyguF05UhQrQe9c710fVi3NK3sYSMFKIKpPZ0Rj90bQqzuiNQ74V3nsyh3Te0zfIUOt5 OdhLIGIzaVwR4GQjE4aFY3K22IcHOxUuL3lqwanuCZBJLY8lMpP+EHnPSHHegbnc+eQR rR6Q== X-Gm-Message-State: ALKqPwfW0BhLqN9ubQGcaLXYJF9miWVAffj4lluUOiTbjmt0l8+HZWKo +58X8yffNMD1Nk10S6+cfZN7EKG/r/NHSABgoEu/Rg== X-Google-Smtp-Source: AB8JxZoD88da1kNco4GHqfBV79p1JpI0F3Vy1VvJRU6aHwEkNCiK2ZTYhB8bQmAKi7t0GjgzjguPG/lRtpOz2uMkUHI= X-Received: by 2002:a1c:be0f:: with SMTP id o15-v6mr1529927wmf.104.1526999777422; Tue, 22 May 2018 07:36:17 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.167.137 with HTTP; Tue, 22 May 2018 07:35:37 -0700 (PDT) In-Reply-To: References: From: Johannes Lundberg Date: Tue, 22 May 2018 15:35:37 +0100 Message-ID: Subject: Re: How to check if not clean shutdown? To: Warner Losh Cc: freebsd-current Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.26 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:36:19 -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. > > > 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 >> " >> > >