From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id WFYcEpImumJ8LgEAbAwnHQ (envelope-from ) for ; Mon, 27 Jun 2022 23:52:18 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id iH0vEZImumIjPQAAG6o9tA (envelope-from ) for ; Mon, 27 Jun 2022 23:52:18 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 5E6943F56F for ; Mon, 27 Jun 2022 23:52:17 +0200 (CEST) Received: from localhost ([::1]:53750 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o5weW-0007W1-GE for larch@yhetil.org; Mon, 27 Jun 2022 17:52:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36712) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o5weJ-0007VE-2s for bug-guix@gnu.org; Mon, 27 Jun 2022 17:52:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:59638) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o5weI-0000ql-Ad for bug-guix@gnu.org; Mon, 27 Jun 2022 17:52:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1o5weI-0001NE-9o for bug-guix@gnu.org; Mon, 27 Jun 2022 17:52:02 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#56209: Shepherd 0.9 not cleanly unmounting root Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Mon, 27 Jun 2022 21:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56209 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: angry rectangle Cc: 56209@debbugs.gnu.org Received: via spool by 56209-submit@debbugs.gnu.org id=B56209.16563666725210 (code B ref 56209); Mon, 27 Jun 2022 21:52:02 +0000 Received: (at 56209) by debbugs.gnu.org; 27 Jun 2022 21:51:12 +0000 Received: from localhost ([127.0.0.1]:53531 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o5wdU-0001Lx-77 for submit@debbugs.gnu.org; Mon, 27 Jun 2022 17:51:12 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51510) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o5wdP-0001Lg-FU for 56209@debbugs.gnu.org; Mon, 27 Jun 2022 17:51:10 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:44832) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o5wdJ-0000kC-8R; Mon, 27 Jun 2022 17:51:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=a6gToIQLvat0ruyROqKuQBia4F9v9+tAB3YCgsf4hP0=; b=NROQozvqfYwS1qjOt4q1 hAHG0KgUHJPYJlbm6OiAn+57JowP6p+1JuGbmHogKGWP7380f0Qu7hiuwfc/sp/ckDHdju+S1OsF4 sOFQzivz0tKygczxHaQ7fgkvkY806SsmB4TOVoDQBiZocvSXjURv7K+JBGgZKVWiWFePdqrt1wg/S uLaD5sXGE4JYeUAKH5ccYuLvygov38HxdZkTWrQ/bUuzH//qCUup1R7liJ/8GkRqECd/kpBRZmwaI wMIT97IY6H5TVpTz6tAx0WER61lhQh0AQ1mkx7OVznhb4azBXnmNOpHDeIEDtcd7KnUmXtpu84+uF hKCknPkXshFjsw==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:58408 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o5wdI-0004DL-Rq; Mon, 27 Jun 2022 17:51:01 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <87a6a1fgpn.fsf@cock.li> Date: Mon, 27 Jun 2022 23:50:58 +0200 In-Reply-To: <87a6a1fgpn.fsf@cock.li> (angry rectangle's message of "Sat, 25 Jun 2022 01:27:02 -0400") Message-ID: <87mtdxg4hp.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1656366737; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=a6gToIQLvat0ruyROqKuQBia4F9v9+tAB3YCgsf4hP0=; b=HSkaKGLDAj9T0E7xNox9FCCENLJUuK+jbQhomSb1F5S61MW7OYfAUc6epGRA6dWtGL6RYg Xf5yCarTAz7xobMW++lbXfP8sf0pd+TqmsBr2QNMkFkRwuyDAJma/cYgdYKS2jDFcr6+QQ eOskmy+ahtkubVAf/V0Ai91mWC179NZqh5pGLXMoszsyCVvJX1uhAO7vKXbze+VW2V5u6d 8ic6pGNQFb3yiYvH4tp6OaEbEAorRTYfz0tefd/u2KvhaunoGHu5mMy45wR7GenHDkuD3k YPhA9ClJAxJJAsqCcLv6zKtQ07bPyAH3UzKZrXOr58CcZ12YtmG8QULeViB84Q== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1656366737; a=rsa-sha256; cv=none; b=pkp3jGXy3Y0zQeQBQC0GQ2btAFom/znv2s+9m8SnfUc2LfwrMckuo1hLbOMuae9zZGjB+F B5BB0cZsT8NveoYPrfydJX5IJoSYuktWxxc3qGbOEuPsxWv2dLSaQSkPij52yPPILfa9ck 9OJmNH5ACjrc7FSk0SIJ9kpAvdvqLG3jvJ7tehReGBAosTscrVB/CAmE+PlrufpdJgR88p m7uOxIfKfipKtHT+OTzNDE9Eg7Gf+soC0FN4jHyLdnHet6271pDpywHXFTepTvrzlNddNh FdEWg1tQtFsIVhH97aO01yFMR4YVZttbrcAzlejLjYA9Z6oOwxhwTmwm6QuuOA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=NROQozvq; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.75 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=NROQozvq; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 5E6943F56F X-Spam-Score: -3.75 X-Migadu-Scanner: scn0.migadu.com X-TUID: 8+DWu4Ate+mK --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi, angry rectangle skribis: > Since the upgrade to shepherd 0.9, I get "recovering journal" every singl= e time I start my computer. > To be specific, "recovering journal" appears after I enter my encryption = password in the initrd. > I assume this means the filesystem wasn't cleanly unmounted. > I am doing a proper shutdown, using either "reboot" or "halt."=20 I can see that as well. > The guix commit 400c9ed3d779308e56038305d40cd93acb496180 is the specific = commit that upgrades shepherd and causes me this problem. The previous comm= it is fine. > I'm can confirm that it's still broken on recent commits. I'm on 696e2cc3= 45f015c32f211bf0d0330c04b1cf5f15. Preliminary investigation suggests this is because shepherd doesn=E2=80=99t close log files beforehand (in 0.9, those specified as #:log-file to =E2=80=98make-forkexec-constructor=E2=80=99 & co. are opened by PID=C2=A01;= conversely, shepherd 0.8 would open them in the child process.) To be continued=E2=80=A6 Thanks for reporting the issue and finding the offending commit! Ludo=E2=80=99. PS: Below my (ugly) debugging tricks for posterity. To see those messages, you typically need to start a VM with =E2=80=98-serial stdio= =E2=80=99 and pass =E2=80=9Cconsole=3DttyS0=E2=80=9D to the kernel. (It=E2=80=99s be= st to start a standalone VM with an image created by =E2=80=98guix system image -t qcow2=E2=80=99.) --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff --git a/gnu/services/base.scm b/gnu/services/base.scm index d58afb27e3..25d747d226 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -299,6 +299,9 @@ (define %root-file-system-shepherd-service (stop #~(lambda _ ;; Return #f if successfully stopped. (sync) + (call-with-port (open-file "/dev/console" "w0") + (lambda (port) + (display "This is my last message.\n" port))) (call-with-blocked-asyncs (lambda () @@ -314,11 +317,24 @@ (define %root-file-system-shepherd-service ;; Close /dev/console. (for-each close-fdes '(0 1 2)) - ;; At this point, there are no open files left, so the - ;; root file system can be re-mounted read-only. - (mount #f "/" #f - (logior MS_REMOUNT MS_RDONLY) - #:update-mtab? #f) + (open-fdes "/dev/null" O_RDONLY) + (open-fdes "/dev/console" O_WRONLY) + (open-fdes "/dev/console" O_WRONLY) + (current-output-port (fdopen 1 "w0")) + (current-error-port (fdopen 2 "w0")) + (pk 'umount-root) + + (catch 'system-error + (lambda () + ;; At this point, there are no open files left, so the + ;; root file system can be re-mounted read-only. + (mount #f "/" #f + (logior MS_REMOUNT MS_RDONLY) + #:update-mtab? #f)) + (lambda args + (pk 'umount-root-error args) + #f)) + (pk 'done-umount-root) #f))))) (respawn? #f))) @@ -406,7 +422,28 @@ (define (file-system-shepherd-service file-system) ;; Make sure PID 1 doesn't keep TARGET busy. (chdir "/") - (umount #$target) + (call-with-port (open-file "/dev/console" "w0") + (lambda (port) + (parameterize ((current-output-port port) + (current-error-port port)) + (pk 'umount #$target) + #$(if (file-system-mount-may-fail? file-system) + #~(catch 'system-error + (lambda () + (umount #$target)) + (const #f)) + #~(catch 'system-error + (lambda () + (umount #$target)) + (lambda args + (pk 'umount-error args) + (system* #$(file-append (@ (gnu + packages + lsof) + lsof) + "/bin/lsof")) + #f))) + (pk 'done-umount #$target)))) #f)) ;; We need additional modules. diff --git a/gnu/system/examples/bare-bones.tmpl b/gnu/system/examples/bare-bones.tmpl index 387e4b12ba..1f9012c167 100644 --- a/gnu/system/examples/bare-bones.tmpl +++ b/gnu/system/examples/bare-bones.tmpl @@ -2,8 +2,8 @@ ;; for a "bare bones" setup, with no X11 display server. (use-modules (gnu)) -(use-service-modules networking ssh) -(use-package-modules screen ssh) +(use-service-modules networking ssh shepherd) +(use-package-modules screen ssh admin) (operating-system (host-name "komputilo") @@ -38,6 +38,13 @@ "audio" "video"))) %base-user-accounts)) + (essential-services + (modify-services (operating-system-default-essential-services + this-operating-system) + (shepherd-root-service-type + config => (shepherd-configuration + (shepherd shepherd-0.8))))) + ;; Globally-installed packages. (packages (cons screen %base-packages)) --=-=-=--