I'm having trouble rooting my Samsung J320P with heimdall
Rooting doesn't need you repartitioning the phone. Just flash a custom recovery and then flash the rooting files through that recovery.

I'd suggest you to install TWRP recovery.  There is a complete guide on how to flash the recovery and rooting zip files here. Just follow CAREFULLY everything, step by step. (The guide is for Odin, I think it will work for Heimdall as well).