Using Rocky 8.5 parted in emergency mode, it somehow deleted the wrong partition.
I used grub menu edit to log in using single user emergency node to make sure nothing was mounted on any of the devices I was working on.
Connect to parted interactive and issue ‘print’ to ensure it’s the correct device, the only connected device which has an MBR partition table. This device is not used for booting or o/s.
parted /dev/sda print
looks good, correct device
p3 has gone, we see free space at end as expected
p2 has gone, we see free space increase at end
looks good, still using /dev/sda
it’s deleted p1 from /dev/sdb, instead of from /dev/sda!
I thought using interactive mode would be safer; the p1 partition deleted from /dev/sdb contained an LVM setup. It didn’t just delete the partition, it also trahsed the GPT partition table and started reporting it as MBR.
I tried to use parted rescue on /dev/sdb to recover the deleted p1 partition on sdb, but it didn’t work; it treated it as an MBR disk instead of a GPT disk.
In the end, I was able to recover the lost p1 partition on sdb using gdisk, which correctly found a backup copy of the GPT and restored it.
So I thought from the RHEL 8 docs that parted was the correct tool to use, even for GPT disks, but now I don’t know; I’ll probably switch to using gdisk…