Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1882996

Summary: Unable to disable swap from /etc/fstab if swap is directly hosted on a GPT partition
Product: Red Hat Enterprise Linux 8 Reporter: Flos Qi Guo <qguo>
Component: systemdAssignee: systemd maint <systemd-maint>
Status: CLOSED MIGRATED QA Contact: Frantisek Sumsal <fsumsal>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 8.2CC: dtardon, systemd-maint-list
Target Milestone: rcKeywords: MigratedToJIRA
Target Release: 8.0Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-09-21 11:13:02 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Flos Qi Guo 2020-09-27 09:49:24 UTC
> Description of problem:
If a swap is directly created on a GPT partition, when comment out the mount entry of the swap, the swap will still be activated in the next boot.

> Version-Release number of selected component (if applicable):
systemd-239-31.el8_2.2.x86_64 (also tested other versions on RHEL8)

>How reproducible:
Always.

> Steps to Reproduce:
1. Fresh install a RHEL8.2 on a UEFI machine, create a single partitoin on the GPT disk to make it a swap partition.
2. After installation, comment out the mount entry from /etc/fstab.
3. Reboot

> Actual results:
The swap will be activated during boot despite the mount swap entry being disabled.

> Expected results:
The swap should obey the settings in /etc/fstab.

> Additional info:
This issue does not affect the swap on a LVM logical volume.

Comment 1 Flos Qi Guo 2020-09-27 09:57:10 UTC
Hello,

Testing data in my VM as follows:

------------------8<------------------8<------------------8<------------------
# uname -a
Linux rhel8u2-swap.example.com 4.18.0-193.el8.x86_64 #1 SMP Fri Mar 27 14:35:58 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

# cat /etc/redhat-release 
Red Hat Enterprise Linux release 8.2 (Ootpa)

# cat /proc/cmdline 
BOOT_IMAGE=(hd1,gpt2)/vmlinuz-4.18.0-193.el8.x86_64 root=/dev/mapper/rhel-root ro crashkernel=auto resume=UUID=1486bdad-4af9-425e-9747-56d51a106c06 rd.lvm.lv=rhel/root systemd.log_level=debug systemd.log_target=kmsg log_buf_len=15M

# rpm -qa | grep ^systemd
systemd-udev-239-31.el8_2.2.x86_64
systemd-libs-239-31.el8_2.2.x86_64
systemd-239-31.el8_2.2.x86_64
systemd-pam-239-31.el8_2.2.x86_64

# cat /etc/fstab 

#
# /etc/fstab
# Created by anaconda on Sun Sep 27 04:14:43 2020
#
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
/dev/mapper/rhel-root   /                       xfs     defaults        0 0
UUID=1adad4d6-152e-4ea1-bec2-501be71bda81 /boot                   xfs     defaults        0 0
UUID=9EAE-E85A          /boot/efi               vfat    umask=0077,shortname=winnt 0 2
#UUID=1486bdad-4af9-425e-9747-56d51a106c06 swap                    swap    defaults        0 0

# swapon -s
Filename				Type		Size	Used	Priority
/dev/sda3                              	partition	1048572	0	-2

# journalctl --no-pager --boot | less
Sep 27 17:24:13 rhel8u2-swap.example.com systemd-fstab-generator[579]: Parsing /etc/fstab
Sep 27 17:24:13 rhel8u2-swap.example.com systemd-fstab-generator[579]: Found entry what=/dev/mapper/rhel-root where=/ type=xfs makefs=no nofail=no noauto=no
Sep 27 17:24:13 rhel8u2-swap.example.com systemd-fstab-generator[579]: Found entry what=/dev/disk/by-uuid/1adad4d6-152e-4ea1-bec2-501be71bda81 where=/boot type=xfs makefs=no no
fail=no noauto=no
Sep 27 17:24:13 rhel8u2-swap.example.com systemd-fstab-generator[579]: Found entry what=/dev/disk/by-uuid/9EAE-E85A where=/boot/efi type=vfat makefs=no nofail=no noauto=no
Sep 27 17:24:13 rhel8u2-swap.example.com systemd-gpt-auto-generator[581]: /dev/sda4: root device /dev/sda.
Sep 27 17:24:13 rhel8u2-swap.example.com systemd-gpt-auto-generator[581]: Adding swap: /dev/sda3 <<<<------- HERE
Sep 27 17:24:13 rhel8u2-swap.example.com systemd-gpt-auto-generator[581]: /boot specified in fstab, ignoring.

# cat /run/systemd/generator.late/swap.target.wants/dev-sda3.swap 
# Automatically generated by systemd-gpt-auto-generator

[Unit]
Description=Swap Partition
Documentation=man:systemd-gpt-auto-generator(8)

[Swap]
What=/dev/sda3
------------------8<------------------8<------------------8<------------------

According to:
 - https://www.freedesktop.org/wiki/Specifications/DiscoverablePartitionsSpec/

~~~
The Discoverable Partitions Specification

TL;DR: Let's automatically discover, mount and enable the root partition, /home, /srv and the swap partitions based on GUID Partition Tables (GPT)! 
~~~

This seems a feature for the 'systemd-gpt-auto-generator', but could we disable it by default? So that we can just focus on the /etc/fstab. Thanks.

Best regards,
Flos

Comment 3 David Tardon 2020-10-05 08:41:58 UTC
(In reply to Qi Guo [Flos] from comment #1)
> This seems a feature for the 'systemd-gpt-auto-generator', but could we
> disable it by default? So that we can just focus on the /etc/fstab. Thanks.

Note that /etc/fstab is no longer the single and only source for mount/swap configuration (and it hasn't been since RHEL-7). It's just one source from which mount and swap units are generated. So an absence of a swap definition in /etc/fstab is no guarantee there is no active swap unit on the system...

That said, I tend to agree that the gpt-auto-generator should be off by default.

Comment 4 Lukáš Nykrýn 2020-10-06 14:15:42 UTC
We have agreed that we need to do some changes in documentation
1) fix the fstab manpage
2) put a comment to /etc/fstab stating that people should look at the output of systemctl list-unit-files --type mount

Comment 5 David Tardon 2020-10-06 16:17:39 UTC
(In reply to Lukáš Nykrýn from comment #4)
> systemctl list-unit-files --type mount

systemctl list-unit-files --type mount --type swap

Comment 6 David Tardon 2023-05-31 08:05:02 UTC
Some notes related to this:

1. systemd-gpt-auto-generator can be disabled by passing [rd.]systemd.gpt-auto=no on kernel command line.
2. Auto-detected (by systemd-gpt-auto-generator) swaps are ignored if there's any swap specified in fstab. Hence, adding noauto option to a swap def. in fstab instead of commenting out the line should effectively disable the swap.

Of course, what I said in comment 3 still holds.

Comment 7 RHEL Program Management 2023-09-21 11:07:50 UTC
Issue migration from Bugzilla to Jira is in process at this time. This will be the last message in Jira copied from the Bugzilla bug.

Comment 8 RHEL Program Management 2023-09-21 11:13:02 UTC
This BZ has been automatically migrated to the issues.redhat.com Red Hat Issue Tracker. All future work related to this report will be managed there.

Due to differences in account names between systems, some fields were not replicated.  Be sure to add yourself to Jira issue's "Watchers" field to continue receiving updates and add others to the "Need Info From" field to continue requesting information.

To find the migrated issue, look in the "Links" section for a direct link to the new issue location. The issue key will have an icon of 2 footprints next to it, and begin with "RHEL-" followed by an integer.  You can also find this issue by visiting https://issues.redhat.com/issues/?jql= and searching the "Bugzilla Bug" field for this BZ's number, e.g. a search like:

"Bugzilla Bug" = 1234567

In the event you have trouble locating or viewing this issue, you can file an issue by sending mail to rh-issues. You can also visit https://access.redhat.com/articles/7032570 for general account information.