Deleting a swapfile that is busy
rm /swapfile fails with Device or resource busy because the file is still in use as a swap device.
Order matters:
swapoff /swapfile
rm /swapfile
sed -i '/swapfile/d' /etc/fstab
A slow swapoff means memory is tight and pages must come back; forcing the removal loses data.
If the swap entry stays in fstab, the next boot cannot find the device — Ubuntu drops into emergency mode until you comment the line out.
Afterwards free -h should show zero swap and swapon --show should print nothing.