From owner-freebsd-questions@freebsd.org Thu Jun 14 00:30:56 2018 Return-Path: Delivered-To: freebsd-questions@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 AC7B210073C2 for ; Thu, 14 Jun 2018 00:30:56 +0000 (UTC) (envelope-from jude.obscure@yandex.com) Received: from forward102j.mail.yandex.net (forward102j.mail.yandex.net [5.45.198.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "forwards.mail.yandex.net", Issuer "Yandex CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D00D685764 for ; Thu, 14 Jun 2018 00:30:55 +0000 (UTC) (envelope-from jude.obscure@yandex.com) Received: from mxback8o.mail.yandex.net (mxback8o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::22]) by forward102j.mail.yandex.net (Yandex) with ESMTP id 36CE2560538D; Thu, 14 Jun 2018 03:30:47 +0300 (MSK) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:7]) by mxback8o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id TUmzGEgdN3-Ulpagk89; Thu, 14 Jun 2018 03:30:47 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.com; s=mail; t=1528936247; bh=gNZvxPTwLhoMIRps//P6B1kUEWpYrM9aWWTdGyaCmoY=; h=Subject:To:Cc:References:From:Message-ID:Date:In-Reply-To; b=iT1r8+QaUJE9LF8U8colxjPl8caM6kGeCtpb10GqI1BGQUjjx0irVp5a6RCO0sHqN gPPHG0caZ53TZ8rpAbAicC6AdIwjuT9q5L9JG71wwwjwuw+o903QGzK8zSOGjwG5Ew /aihrcrW2CsiKd2+udl2BUcqP3u3cbWXvYToA8ZE= Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id fKx9EJc1b3-UjQuZEJ5; Thu, 14 Jun 2018 03:30:46 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.com; s=mail; t=1528936246; bh=gNZvxPTwLhoMIRps//P6B1kUEWpYrM9aWWTdGyaCmoY=; h=Subject:To:Cc:References:From:Message-ID:Date:In-Reply-To; b=FWR4xdXRzDAU1RnukNAfvdiKWxFTQ5HE2546+Wo53/dxLZObW1MZoVOsbS+R497dy MyPpHd839+QoxeJreLUv/K5TsA4FbJR4iAExXMiFjOAdQRrzC3EmKkyoSKC9AAiOUr 4BiOeU92DGkA1PXkZoFSGiK+wuTfbJsS9MgZPwrI= Authentication-Results: smtp2p.mail.yandex.net; dkim=pass header.i=@yandex.com Subject: Re: How to detect single user mode in FreeBSD ? To: jungle Boogie Cc: FreeBSD Questions References: From: Manish Jain Message-ID: <89bc6774-aa0d-6704-71a1-6b8eea8ae3b5@yandex.com> Date: Thu, 14 Jun 2018 05:59:16 +0530 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jun 2018 00:30:56 -0000 On 06/14/18 05:09, jungle Boogie wrote: > Describe the problem you want to solve, not how. The problem is this: I am writing a shell script which can run fsck on all UFS / ext2 /ext4 hard disk partitions listed in /etc/fstab. The script should be portable and be able to run no matter whether the OS running is FreeBSD or Linux. The only thing that matters is that the commands fsck_ufs / fsck.ext2 and fsck.ext4 are available. Ideally, the script should run only under single user mode, or else bail out immediately. Linux has a clean way to find out whether the system is in single user mode. I would think, no matter what others on this list have said, sysctl under FreeBSD too should have a variable for indicating single user mode. But there currently is not any. Tx and Regards Manish Jain