LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 04-29-2021, 05:52 PM   #1
Grobe
Member
 
Registered: Aug 2019
Location: Close to north
Distribution: Fedora
Posts: 124

Rep: Reputation: Disabled
Multiple swap partitions on two or more hdd


Hi.

I'm currently in a process of reviving an old computer from 2005, RAM limits to 2GB.

The computer will - when I'm done setting it up - consist of multiple HDD's (no ssd's).

Therefore I have the ability to spread the swap over more than one hdd, however I have some questions in that regard:
  1. Can one get (slightly) better swap performance (i.e. from user perspective) by having multiple swap partitions over two or more hdd's ?
  2. Can there be some issues by using two or more swap partitions ?
I already know that it's optimal to put swap partition on beginning of the hdd and preferably on another drive than the location of /

Thanks in advance for any advice on this
 
Old 04-29-2021, 05:59 PM   #2
jefro
Moderator
 
Registered: Mar 2008
Posts: 22,150

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Depends on how old the computer is. Some of the older ones share the hard drive adapter so it may not show as much improvement. Modernish computers can use more direct so the multiple swap area (files, partitions) improves.

There is no substitute for ram.

I think swap would be faster in middle but that was how OS/2 put it's file information.

Very common to have multiple swap in any number of configurations and swappiness values. Swap raid is used too.

Last edited by jefro; 04-29-2021 at 06:00 PM.
 
Old 04-29-2021, 06:28 PM   #3
Grobe
Member
 
Registered: Aug 2019
Location: Close to north
Distribution: Fedora
Posts: 124

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by jefro View Post
Depends on how old the computer is. Some of the older ones share the hard drive adapter so it may not show as much improvement. Modernish computers can use more direct so the multiple swap area (files, partitions) improves.
Good point, You're referring to PATA hdd's that can have one master and one slave drive on the same flat cable.

Quote:
Originally Posted by jefro View Post
There is no substitute for ram.
True - but I won't spend any money on this one, I've already replaced two capacitors on it's motherboard to lengthen it's life span.

Quote:
Originally Posted by jefro View Post
I think swap would be faster in middle but that was how OS/2 put it's file information.
In the middle ?

Quote:
Originally Posted by jefro View Post
Very common to have multiple swap in any number of configurations and swappiness values. Swap raid is used too.
Ok, swap raid are new for me. Doesn't that require that the HDD are of same model - as for normal raid (to not loose performance) ? Btw - this computer will have hard drives that happens to still be usable and I don't have two that are equal to each other.
 
Old 04-29-2021, 06:40 PM   #4
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,838

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
Quote:
Originally Posted by Grobe View Post

[snip]

Therefore I have the ability to spread the swap over more than one hdd, however I have some questions in that regard:
  1. Can one get (slightly) better swap performance (i.e. from user perspective) by having multiple swap partitions over two or more hdd's ?
  2. Can there be some issues by using two or more swap partitions ?
I already know that it's optimal to put swap partition on beginning of the hdd and preferably on another drive than the location of /
I've been placing swap partitions in the middle of the drive to reduce head seek time; seems to work fine. Splitting up today's huge disks with a swap partition in the middle doesn't stick you with small partitions surrounding it. I set all swap partitions to the same priority in /etc/fstab so that a single partition isn't getting hammered.

HTH...
 
Old 04-29-2021, 06:47 PM   #5
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,838

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
Quote:
Originally Posted by Grobe View Post
In the middle ?
Cuts seek time (on average) in half.

Historical perspective: VMS's ODS-2 disk format gave you the option of placing the disk directory -- when the disk was initialized -- in the middle of the disk. It was especially useful for disks that would hold a lot of small, frequently-used files; having the directory in the middle sped up disk lookup and open times. For disks that held large files, you could place the directory at the "edge" of the disk so it would be less likely that big files would need to non-contiguous (i.e. fragmented).

Cheers...
 
Old 04-29-2021, 06:57 PM   #6
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,272

Rep: Reputation: 4164Reputation: 4164Reputation: 4164Reputation: 4164Reputation: 4164Reputation: 4164Reputation: 4164Reputation: 4164Reputation: 4164Reputation: 4164Reputation: 4164
Note this is not swap RAID. Merely multiple extents.
I've never placed much credence in the debate over placement on the physical disk. The swap I/O is handled by the standard I/O scheduler so isn't any more a driver of head movement than anything else. Unless you're really swapping heavily, and then you're in a whole 'nuther world of pain anyway.
Also be aware that swap rate is a much more important metric than swap occupancy.

I retired an old Pentium4 with only 1Gig and it ran a full gnome2 desktop with only minimal swapping. Bit slow and only used for mail and a bit of web surfing, but worked. You may be worrying unnecessarily depending on expected usage.
 
Old 04-29-2021, 09:14 PM   #7
jefro
Moderator
 
Registered: Mar 2008
Posts: 22,150

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Yes, I meant that various forms of swap exist. Two are treated as one usually if swappiness is same.

Yes, a lot of this discussion is more theory than actual return for home user but bits are bits.

If I had a drive that did most of the I/O then I'd put entire swap on other drive. Or place emphasis on lesser I/O drive swap area.
 
Old 04-29-2021, 10:42 PM   #8
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,633
Blog Entries: 28

Rep: Reputation: 6231Reputation: 6231Reputation: 6231Reputation: 6231Reputation: 6231Reputation: 6231Reputation: 6231Reputation: 6231Reputation: 6231Reputation: 6231Reputation: 6231
This older LQ thread would seem to be germane: https://www.linuxquestions.org/quest...ks-4175577418/
 
1 members found this post helpful.
Old 04-30-2021, 04:15 AM   #9
mrmazda
LQ Guru
 
Registered: Aug 2016
Location: SE USA
Distribution: openSUSE 24/7; Debian, Knoppix, Mageia, Fedora, others
Posts: 6,188
Blog Entries: 1

Rep: Reputation: 2159Reputation: 2159Reputation: 2159Reputation: 2159Reputation: 2159Reputation: 2159Reputation: 2159Reputation: 2159Reputation: 2159Reputation: 2159Reputation: 2159
Quote:
Originally Posted by Grobe View Post
In the middle ?
Very roughly. Fastest is a combination of head stroke and sectors per track being denser near the start. So it can be somewhere in the vicinity of 1/3 from the front that turns out to be fastest.
 
Old 04-30-2021, 11:32 AM   #10
Grobe
Member
 
Registered: Aug 2019
Location: Close to north
Distribution: Fedora
Posts: 124

Original Poster
Rep: Reputation: Disabled
Thumbs up Thank you for responding

Appreciate for answers.

Quote:
Originally Posted by frankbell View Post
This older LQ thread would seem to be germane: https://www.linuxquestions.org/quest...ks-4175577418/
Thank you for finding this thread. I read through it and this is what I could piece together based on my usecase:


I think this two posts pretty much answers what I questioned for
Quote:
Originally Posted by chrism01 View Post
. . . . Hypothetically, I can see if you have a LOT of disks on a system and you know you'll need swap, you could spread the load over multiple drives. This prevents I/O bottlenecking... in fact you'd want to spread the I/O load over multiple disk controller cards / buses, not necessarily just the drives.
. . . .
Quote:
Originally Posted by lazardo View Post
If a disk is heavily used it is not a good pick for swap.


And the thread also contains mostly discussion about performance as swap file vs. swap partition. This is not relevant for me, I'll use partitions anyway.

Quote:
Originally Posted by lazardo View Post
Swap uses disk blocks without any filesystem. It can use a whole unformatted disk or an unformatted partition.
Quote:
Originally Posted by jpollard View Post
I don't think the swap file has to be contiguous.

There are NO guarantees in any native Linux filesystem that a file be contiguous, in fact, doing so makes it slower (not to mention that when the size crosses block cluster units it has to skip the cluster allocation sectors, and thus is not contiguous anyway).

It does need to be fully allocated - but that is only due to the filesystem supporting the swap file causing paging activity to allocate blocks in a sparse file (and hence a possible deadlock).
 
Old 04-30-2021, 06:12 PM   #11
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,675

Rep: Reputation: Disabled
I ran a mini computer with 2GB of RAM for years, as a nettop, it did not do excessive swapping. I did not open too many websites at once, and everything was fine. I had Gentoo in it, and this probably reduced RAM usage somewhat compared to a regular distro. (Couldn't compile anything in it, had to use NFS chroot.)
 
Old 05-03-2021, 03:50 PM   #12
jefro
Moderator
 
Registered: Mar 2008
Posts: 22,150

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
"Swap uses disk blocks without any filesystem. It can use a whole unformatted disk or an unformatted partition"

Actually you have to format it as swap. It used to be easy/common to use storage as raw and you still can but it is depreciated.

I doubt any current test of speed between swap file and swap partition would yield any difference. Certainly not for home use.
 
Old 05-04-2021, 01:48 PM   #13
leclerc78
Member
 
Registered: Dec 2020
Posts: 170

Rep: Reputation: Disabled
I propose running a light distro (Puppy, antiX...) and no swapping.
It's good for our sanity.
 
Old 05-04-2021, 03:15 PM   #14
Grobe
Member
 
Registered: Aug 2019
Location: Close to north
Distribution: Fedora
Posts: 124

Original Poster
Rep: Reputation: Disabled
Post example of spreading swap file over multiple disks

Thank you for good answers.

On an old computer, now installed Linux Mint XFCE edition, I've set up the swap as following:
  • Three 500GB hdd's (old and used), the first 1,8GB partition as swap.
  • On another very old 30GB hdd, there is a 4GB partition for swap (in case I run out of swap space on the 3 other disks)

And the fstab file (the part that define swap partitions) look like this:
Code:
# <file system>                       <mount point>      <type>  <options>   <dump>  <pass>
# NEW SWAP SETTINGS
# Located on the old 30GB drive
UUID=6de9ffd9-af1a-467e-a31c-5f83f18f1546 none            swap    sw,pri=2        0       0
#/dev/sda1
UUID=f1705931-3d6c-46d7-93e7-7409c2aaea55 none            swap    sw,pri=1        0       0
#/dev/sdb1
UUID=814403ca-ff0c-4a1e-947c-1f45d4890d61 none            swap    sw,pri=1        0       0
#/dev/sde1
UUID=22ccaec4-cd0a-4821-99c0-22ca644d7345 none            swap    sw,pri=1        0       0
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Use cases for multiple swap partitions on single and multiple disks? fanoflq Linux - Newbie 16 04-16-2016 10:21 AM
Is it possible to use two swap partitions for multiple uses? texasone Linux - General 9 09-07-2011 07:32 AM
if any utility available for copy one HDD to two more HDD simultaneously? mdfakkeer Linux - General 3 02-07-2010 07:07 AM
Join two swap partitions rpagnin Linux - Newbie 3 10-27-2006 08:05 AM
Partitions, partitions, partitions..... Clueless in VA Linux - Newbie 7 08-08-2001 04:01 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 05:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration