From owner-freebsd-questions@freebsd.org Thu Jun 14 00:48:22 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 41FB01008E87 for ; Thu, 14 Jun 2018 00:48:22 +0000 (UTC) (envelope-from jd1008@gmail.com) Received: from mail-io0-x244.google.com (mail-io0-x244.google.com [IPv6:2607:f8b0:4001:c06::244]) (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 BC65086318 for ; Thu, 14 Jun 2018 00:48:21 +0000 (UTC) (envelope-from jd1008@gmail.com) Received: by mail-io0-x244.google.com with SMTP id l25-v6so5384306ioh.12 for ; Wed, 13 Jun 2018 17:48:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-transfer-encoding; bh=wu20MK6J7jAIgE1Q3Ei0W/WZk3uPadzx5R1RKKVg4fc=; b=g6X2sRiBi5C5//nGMPUlSLzLHKsYjMSKd4p3LnRwfvH1xgRUE/RyiWSylWczBo5jxh ZPz01H0+92Fgf4GWhSoysGU5vcQ/qUAy4F8f4JRyvTDHLM27tIIXwEJTtRR18WvtA35D XiuMuhSXDW+RfrBw3ibu1KWpcUl0JpTk1Z0PbluFWY5hLTGVmc3LZYbCQN++bXX2Bzr0 kR2wNS3qOotCsoC5z3xdtHEJGGG/UglxhP7nlpVlfsODxyxKmC/Kfq0VxuLPARnlIwhJ FSapdtR8D/RwAn/yrZRjIm6SXF/83s3iZLURUcUmVDFOP5/7QdwlNH+FKsdw29PTx1hd 612w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:content-transfer-encoding; bh=wu20MK6J7jAIgE1Q3Ei0W/WZk3uPadzx5R1RKKVg4fc=; b=c5WFpZviix7nrUuMEa3CDYUSalQH4bESQXz3NIjHQWbd9tWrrqRh6bCdqpnek3tgYq Vf7051hDMbd7akrfTy3Ce6bHwYApP+O+zJ7VOFmTXmtQ+hp8ryTq/+8p04cDmoIKruiu qqNMVPPhyyoMIxxBKxbb9MZmBT651L1L2+dSDK3B9hYLA3RodTjU9vO8XkCFUOHEGN9R Kk2clJ78926F5AQAL1QBLHyhktCKh4msRXVuGG1dcGFFqhYHF3gqkG3Rk9+DnLevXPUK q6jb30amXrjrLER+hW5+crJwf//RxY6z/XeoTDIgZRLISXzLDW4XpxMv9tw8EF0x359C QjXg== X-Gm-Message-State: APt69E3o3e7KUf/mUz+KvVxLj/b+9GQIpRDCXqLJMKdmAfbBKPVYCb8S aNuOcOBZY/+Ok8fS2E14yh5qUg== X-Google-Smtp-Source: ADUXVKLqAfSBLnbEZv2d9U2bchnlGGRHma96KkgnLfdnRxhbW5KjQf6nt5T6NmFWdeT2K6KUVBr7KA== X-Received: by 2002:a6b:8448:: with SMTP id g69-v6mr392296iod.251.1528937300962; Wed, 13 Jun 2018 17:48:20 -0700 (PDT) Received: from localhost.localdomain (50-243-4-3-static.hfc.comcastbusiness.net. [50.243.4.3]) by smtp.googlemail.com with ESMTPSA id h81-v6sm484854ith.2.2018.06.13.17.48.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Jun 2018 17:48:20 -0700 (PDT) Message-ID: <5B21BB53.30800@gmail.com> Date: Wed, 13 Jun 2018 18:48:19 -0600 From: JD User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: freebsd-questions@freebsd.org Subject: Re: How to detect single user mode in FreeBSD ? References: <89bc6774-aa0d-6704-71a1-6b8eea8ae3b5@yandex.com> In-Reply-To: <89bc6774-aa0d-6704-71a1-6b8eea8ae3b5@yandex.com> Content-Type: text/plain; charset=windows-1252; format=flowed 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:48:22 -0000 On 06/13/2018 06:29 PM, Manish Jain wrote: > 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 You need to realize that to run fsck on a filesystem, it has to be UNMOUNTED, unless you provide the -n option to fsck (which means no write - so the mounted fs will not be corrupted). Lynux will not allow the unmounting of / and remounting as read only. So, you will not be able to fsck the device which provides the root fs, at least in lynux. It used to be that FBSD could run in single user mode with / mounted as ro (read only), but I have not booted my FBSD machine for quite some time, so I am not sure id FBSD 10.x will let me do that.