I have to OS on my drive. On installation each OS received its own swap. How do I know which swap is used by which OS?
I have to OS on my drive. On installation each OS received its own swap. How do I know which swap is used by which OS?
Swap file or swap partition?
Swap partitions. I didn't even know about swap files until about an hour ago and I still do not understand them. My question for now is, can I delete one of the swap partitions. I think the OS just looks for one and uses it. In other words having two swaps is just redundancy. In fact, I think that swap is not even required to operate the system. Is this true?
Yes, swap isn't required and the more RAM you have the less need for swap. That said, it's good to have some. Since some releases ago Ubuntu uses a swapfile instead of a swap partition by default, more or less how Windows does with its pagefile. The swapfile is a dynamic file in the root file system.
So, first thing to understand is that unless you manually partitioned in advance and then selected "something else" during Ubuntu installation and chose all the required partitions including swap, the installer won't create any additional partition for swap like it did before. Assuming that you did do this sort of manual installation then you should know which is which. Anyway you should look at fstab to make sure which swap partition or swapfile the OS is actually using.
You can see swap partition with this:
sudo parted -l
or this which also shows UUID if a partition.
lsblk -f
Swap mounted by fstab:
cat /etc/fstab
If swap partition it will be something like this, using your UUID & partition:
# swap was on /dev/sda4 during installation
UUID=3af6a910-59f8-4719-b58c-2e7484d435f0 none swap sw 0 0
If swap file:
/swapfile none swap sw 0 0
More info on swap:
man swapon
Code:fred@z170-focal-k:~$ sudo swapon --show [sudo] password for fred: NAME TYPE SIZE USED PRIO /swapfile file 1.4G 0B -2
UEFI boot install & repair info - Regularly Updated :
https://ubuntuforums.org/showthread.php?t=2147295
Please use Thread Tools above first post to change to [Solved] when/if answered completely.
Following on from what CelticWarrior said - During that manual install process we tell the installer which partition to use as swap and from then on the OS will look for that partition using its UUID number. Delete the partition and it will slow down the loading of the OS as it tries repeatedly to find its swap partition before finally giving up.
It is possible to direct different installs of Linux to use the same partition as swap. I would advise against formatting that partition. I recently made the mistake of allowing a Debian install to share a swap partition with two Ubuntu installs and I allowed it to format the partition and some how the partitions UUID number got changed and now those two Ubuntu installs take a long time to load.
And yes, I did correct the UUIDs in fstab. It did not solve the problem. But then again this is not my thread.
We can only run one OS at a time, so it does not break any rules for more than one OS to look to the same partition to use it as swap.
Regards
It is a machine. It is more stupid than we are. It will not stop us from doing stupid things.
Ubuntu user #33,200. Linux user #530,530
My system is dual boot (18.04 & the current development system which is hirsute currently) and I use both; swap partition & swap files, and don't see the two as redundancy.
Swap partition saves me disk space, as both my OSes can use the one swap partition (as long as I don't hibernate which I don't) as if using only swap files, that would mean two swap files on disk of largish size.
The swap partition isn't easily changed, so when I need more or less swap I just adjust the swap file for the system that needs the altered space (which adds extra to my shared swap partition). I like the flexibility of being able to use both.
Is swap needed to operate?
No, but there can be consequences without it (it'll depend on your resources, plus what you do)
I stole some RAM from a system (for testing purposes in a different box) and didn't expect any side-effects, but the system wasn't using swap & the system slowed to a crawl after I stole the ram. I quickly added swap, and performance increased back to what it was... In my opinion that box for sure needed swap (at least until I returned it's normal amount of RAM) though technically it was still working (just slowly) without the swap.
The default will depend on what system you're using, what release etc.. There are some releases that default to installing without swap (the box I stole RAM from was a setup of a Lubuntu release that installed without swap by default) but others default with swap (most do).
Operating systems are on sda(5) and sda(8). sda(5) is disfubctional and sda(8) is what I am using. I want to delete the swap that is used by sda(5) but I do not see how to match the swaps up with the coorosponding OS.Code:$ sudo swapon --show NAME TYPE SIZE USED PRIO /swapfile file 1.4G 53.3M -2 $ sudo parted -l Model: ATA WD easystore 240 (scsi) Disk /dev/sda: 240GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 2 1048kB 165GB 165GB extended boot 5 1049kB 47.0GB 47.0GB logical ext4 7 47.0GB 47.5GB 537MB logical fat32 8 47.5GB 79.6GB 32.0GB logical ext4 6 79.6GB 149GB 69.0GB logical ext4 3 240GB 240GB 537MB primary fat32 $ ls -al /dev/disk/by-uuid/ total 0 drwxr-xr-x 2 root root 140 Apr 15 19:26 . drwxr-xr-x 7 root root 140 Apr 15 19:26 .. lrwxrwxrwx 1 root root 10 Apr 15 19:27 899C-4EDA -> ../../sda7 lrwxrwxrwx 1 root root 10 Apr 15 19:27 a7db5469-f563-43c9-834e-8f6d116c13fb -> ../../sda6 lrwxrwxrwx 1 root root 10 Apr 15 19:27 AB92-2888 -> ../../sda3 lrwxrwxrwx 1 root root 10 Apr 15 19:27 b8115106-222d-4a3d-9a13-b0075492c0aa -> ../../sda8 lrwxrwxrwx 1 root root 10 Apr 15 19:27 ba2d1bc6-43be-4376-b31b-c7d2b898d614 -> ../../sda5
You're using a swapfile. None of your partitions is swap.
Holy cow! Life just keeps getting more confusing. Then what are the two 537 mb partitions that were created when I did the installs? Partitions 7 and 3.
Last edited by sofasurfer; April 17th, 2021 at 11:41 PM.
Bookmarks