Disk swap issues in Rocky

We are seeing disk swapping when adding disks in Rocky. We have not faced this issue in Centos. We have provisioned lot of VMs out of ISO Rocky and made a template out of it. Whenever we add a new additional disk from vcenter to the VM out of template, swap is happening and sometimes not. Swap also happens when the servers are rebooted. How to avoid disk swapping which impacts application.

Example: sda becomes sdb and sdb becomes sdd

You should be mounting and using disk partitions via their UUID. Use blkid from the console. This is how it works nowawdays, not just on Rocky.

For example on mine:

[root@rocky9 ~]# blkid
/dev/sda2: UUID="38479e8a-9cfd-4445-a8a4-ee04ae9448da" TYPE="xfs" PARTUUID="60e9665a-4f69-4420-8c11-e208498d1475"
/dev/sda1: UUID="94DB-E59E" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="75cf07c3-00f4-43f8-9b69-84d3452a1983"

and fstab:

UUID=38479e8a-9cfd-4445-a8a4-ee04ae9448da /                       xfs     noatime,defaults        0 0
UUID=94DB-E59E          /boot/efi               vfat    umask=0077,shortname=winnt 0 2

you do not mount using ```/dev/sdX`` now, since mounting via UUID means that even if disk ordering changes, the system will always boot.

We are already using UUID to mount the file systems and seeing these issues.

Disk udev rules seems not setting properly by default.

Not possible, you must be using references to sda or sdb somewhere if something is not mounting, or eg if swap is not available because of it. UUID’s do not cause problems, I have taken a disk out of one laptop and placed it in another and the disks sda/sdb changed places and the system still booted because it wasn’t using references to sda or sdb to mount something.

The problem you are experiencing can only happen when using /dev/sda or /dev/sdb or whatever.

If the systems mount everything successfully, and the disk changes position and you are seeing this, at this point it’s purely cosmetic since everything mounted. You won’t be able to do anything about that you will not be able to control what is sda and what is sdb. Better concentrate on mounting partitions.

Post your /etc/fstab so we can see the full content, and also post the content of /boot/grub2/grub.cfg since either of these are most likely referencing sda or sdb or whatever. Also post the content of /etc/default/grub.