Leap 15.6/16 on an external (USB) SSD - Swap Partition

I have a 500 GB portable SSD on which 15.6 is installed. Pretty useful in emergencies. However, it uses the Swap partition on the internal SSD. So it could be possibly used only on PCs which have linux already installed. What if I create a Swap partition on the external drive itself? That should enable running it on practically any PC or Laptop. Will it interfere with the internal Swap partition on units having Linux installed? I sort of remember that some data is retained in Swap on shut down.

Of course you can place a Swap aprtition where you want it. You should however tell the system where it is. So change the corresponding entry in /etc/fstab and maybe in the resume= stanza in the kernel parameters.

Please consider also that a SWAP is not strictly needed for a Linux system to run, so for an “emergency” system you might just delete the relevant entries in /etc/fstab and the resume= in the kernel command line.

No data is retained in swap on shutdown but a memory image is retained in swap upon “suspend to disk” AKA “hibernate” but that might not even be enabled by default. With your current setup if the system using the internal disk was “suspended to disk” and you boot the “emergency” system in the external SSD, you erase the RAM image saved to swap by the suspend operation and the “internal” system will never resume to its previous state.

That may indeed be the most stable choice for a rescue system.

Because this looks very strange to me. When you use it on some unknown system, how do you know what/where Swap is? And when you do not know, how can the /etc/fstab entry in your rescue system be garanteed correct?

Just taking lunch and in the mean time thinking about this.

What you do is potentially very dangerous. Depending on what the Swap entry in your rescue system’s fstab point to, on a random system it can point to a random partition of that system. And thus overwrite any file system there, including the / file system.

When you have a rescue system, it should be self sufficient. Thus either Swap on the same “live” device, or no Swap at all.

@PrakashC just switch to zram instead?

I have used the external SSD 15.6 only on the PC on which it was created. So it knows where to look for SWAP. You have rightly pointed out the dangers where the SWAP is in a different place or missing. In fact if the SWAP place is changed for any reason on the ‘mother’ PC itself using the external SSD would mess up the whole system! Thanks for the alert. And yes, therefore it makes sense to have the SWAP on the external SSD itself. Thanks.

No, when you boot from the external SSD the system looks for the swap defined (if any) on the /etc/fstab stored on the root partition of that same external SSD. If the “mother” swap was changed, the UUIDs don’t match and the system boots without a swap after waiting for 1m30s looking for an UUID that it cannot find.

That is a relief. So SWAP is not strictly essential.
I will anyway try installation keeping SWAP on the external SSD.

Thanks hcvv and OrsoBruno. Your inputs have clarified the matter and solved the problem.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.