How to make sure a swapfile is on the external HDD after it is mounted and not before in the according directory?

I want to put the swapfile on an external HDD which is mounted on startup.

My /etc/dphys-swapfile is


and my /etc/fstab is

UUID=... /home/shares ext4 rw,auto,defaults,nofail,x-systemd.device-timeout=3 0 2 

The swap.file gets placed into the unmounted folder. Apart from the question how bad it is to have a swapfile in a folder that gets a mount afterwards I want to make sure it is not on the SD card (I am running a Raspberry Pi).

Also not sure if a debian question is right for askubuntu, but I think it is more general than just a Raspberry Pi question.

Ubuntu Studio 19.04: How to enable hibernation with swapfile

So, I installed Ubuntu Studio on a laptop that has 16G of RAM. By default, Ubuntu Studio partitioned it with a single ext4 partition, no swap partition, but with a 2G /swapfile.

I noticed that hibernation isn’t enabled, so I tried to get it enabled. What I’ve done so far:

  • Resized /swapfile to 16G and used mkswap to reformat the swapfile, then activated it with swapon. Now, free -m shows 16G of swap space.

  • Installed pm-utils. Tried to use pm-hibernate, but that didn’t work.

  • Followed instructions from this link (Instructions for Debian, thought this might work for Ubuntu Studio too, since it’s based on Debian):

  • After installing uswsusp from above link, verified I was able to hibernate by manually running s2disk from command line as root.

  • But, now I’m not sure how to get Xfce Power Manager and the Xfce Shutdown menu to give me a hibernation option – Xfce Power Manager says that the hibernate option is not supported.

Ubuntu doesn’t boot after install, huge swapfile

Was working without issue within Ubuntu 18.04 on a dual-boot machine.

Installed a tex ide via the command line:

sudo apt-get install texmaker 

which appeared to complete successfully. I subsequently clicked on the first gummi link in a response on this SE page, which lanched a new tab, appeared to be resolving, but never fully resolved after a minute or so. I closed it, launched a new tab and searched, never successfully getting to the page.

I wasn’t doing much otherwise, just watching a youtube vid on an adjacent screen and realized my memory was blocked up after getting errors to cd via the command line. I tried a df on my home directory to see what might be causing it and showed most dirs with normal memory allocations, but a huge swapfile, multiple gigs. I tried restarting to clear it, but haven’t been able to get back in.

I’d allocated 40GB for the Ubuntu partition, and don’t save anything substantial there barring a couple GB movie files in the last couple days, without issue, so I wouldn’t expect the recent install of texmaker would have changed things, even at 1GB+. Checking Windows disk manager shows 100% free, not sure whether that’s good or bad (partition 5):

enter image description here

Any thoughts on how to diagnose and fix.

Edit (with additional boot detail): I’m able to boot, select Ubuntu from within the grub dialogue, and ultimately end up on a command-line looking screen with a version of:

/dev/p5 clean 234234/2342234 files, 234234/2324234 blocks 

after which it hangs.