From owner-freebsd-current@freebsd.org Tue May 22 14:30:34 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 97B90EF7F91 for ; Tue, 22 May 2018 14:30:34 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-it0-x22c.google.com (mail-it0-x22c.google.com [IPv6:2607:f8b0:4001:c0b::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 2B40377D27 for ; Tue, 22 May 2018 14:30:34 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-it0-x22c.google.com with SMTP id q72-v6so199339itc.0 for ; Tue, 22 May 2018 07:30:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=uu90DQHvkrlDcEHgRjzYD2kEVvKMMJb2CyXVP5weo1M=; b=S3CK0+TlpQsTew/e4HKKRDlTQgnCpBYjDiu3iTrdT0IA8S+OLJeAiT2E8l4M5fSAS1 STgLGR18gfeMLRc6uZZUXlaqHopLSFm0Ex+DWmt+XrAwKw21UIQR4vueTg0CR6hPplD3 tvjoF9JmiFUZSrCTAAQa4CT4Vl1nLeqr5QtGqsitgS7XNydlaZ1O5WGEq5QkpRBs+n+n 4tKYiMlGeNi3pUM8gRqUvJPSt3oq9fwOrNYjGHG4O4y9K3XxPIiUFu5qTmVEzE98JgBj +4xjOyqwvPBcSWzxJ6QV1n6G2+SWwDStWiqqG5Yn6398//hw1tBkNcixTUPsTZ69UMpl Vhfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=uu90DQHvkrlDcEHgRjzYD2kEVvKMMJb2CyXVP5weo1M=; b=YxziXdTQSk+dgXDQZo3QRKg0+zBz1G5gP7S0eQvBTVWHfGnCM8XO/nHfL8qmMAoeN0 jw1HlTfLZgfUxIzU22fpuAnYDrS6Fo2Ymq6bL0Xw7zGFzPtZHuWYkFxMxFP2oAoFzOgV 02LauyhvWvI0JSeQT9i4L4LF4UcNzH2y5cE2i+5s+V7lVyMPcnv2Cv05xUUM8a/QM1xV FoENfYaGms8YfuuimiCfFwsMGoV9hSOQf9m0fvlzQFg9WTyZZP4qynygq/zYy92NuMo6 pIL5AN08vYsvv3bJG9pB4PzkuMb6WqgS80PT82aRsBq/TIO+llpKES7D2RL0vlN6bXzl xyCQ== X-Gm-Message-State: ALKqPwcyZQXOvHgyi9M7D/C7kSaVzUhEocyVgFmG4LiVggkTmyDZ3uxi rB/Q2oYnpyLsrXPPTBLn9KRzzAMcbckaPkWKI33Iyg== X-Google-Smtp-Source: ADUXVKKRSVx3mu9i4nudFYKnw40jDXQ+bR8ErJBaHHXLpRCYvRHbkD1zYb5Q1tC0TuOHYvT8Rr5G7Vf6EU1nu0u0+PA= X-Received: by 2002:a24:42c6:: with SMTP id i189-v6mr1480015itb.73.1526999433357; Tue, 22 May 2018 07:30:33 -0700 (PDT) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 2002:a4f:a649:0:0:0:0:0 with HTTP; Tue, 22 May 2018 07:30:32 -0700 (PDT) X-Originating-IP: [2603:300b:6:5100:1052:acc7:f9de:2b6d] In-Reply-To: References: From: Warner Losh Date: Tue, 22 May 2018 08:30:32 -0600 X-Google-Sender-Auth: zLP6fccwiyMmajW7kPNTMgQIF5U Message-ID: Subject: Re: How to check if not clean shutdown? To: Johannes Lundberg 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:30:34 -0000 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 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" >