Score:0

Can I utilize multiple swap files in linux on different devices for enhanced throughput?

cc flag

I would like to use two swap files, if possible: one on the SSD and one on an USB pendrive. I hope this way I can get an enhanced, two combined channel throughput.

sudodus avatar
jp flag
You can use multiple swap files or partitions in linux on different devices, but the standard setup is that they are given different priority, so i *think* they will not be run parallel. Anyway, the USB pendrive will probably be very slow, so slow, that it will seem that the computer is stalled.
Doug Smythies avatar
gn flag
Have a look at [this thread](https://ubuntuforums.org/showthread.php?t=2467637) over on Ubuntu forums, where multiple swap files was the cause of system slow down.
Score:1
cn flag

Yes, you can use multiple swapspaces, but that as such does not contribute to enhanced throughput, only to increased swap space. You can set up multiple swap spaces (partitions or files). These can have the same priority, or they can have a different priority. This is what man swapon says about how priority influences use:

Swap pages are allocated from areas in priority order, highest priority first. For areas with different priorities, a higher-priority area is exhausted before using a lower-priority area. If two or more areas have the same priority, and it is the highest priority available, pages are allocated on a round-robin basis between them.

The way to enhance throughput is to place swapfiles:

  1. On the fastest possible medium: this is obvious: the faster the drive, the faster it will read and write swap data. SSD drives obviously are the best choice in this respect, although that comes at the cost of longevity of these drives.
  2. On a medium different from your system or data hard drive: different drives that work in parallel can deliver speedier data than a single drive that needs to be accessed for different purposes.
Score:0
jo flag

This, Sir, sounds pervert in any way... But yes... You're able to create a swap file on any Device. My Advice - Dont do stuff like this... Anyway:

You have to replace the path for the swapfile (/swapfile with your personal needs - like /mountpointofdevice/swapfile and can set the size (1G) to your personal advice... .. you also can repeat this step for any device...)

        #Create a empty file on your target device
        sudo fallocate -l 1G /swapfile

        #set permissions for root r/w only
        sudo chmod 600 /swapfile

        #mark it as swap
        sudo mkswap /swapfile

        #enable swap
        sudo swapon /swapfile
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.