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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
04-29-2021, 05:52 PM
|
#1
|
Member
Registered: Aug 2019
Location: Close to north
Distribution: Fedora
Posts: 124
Rep:
|
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: - Can one get (slightly) better swap performance (i.e. from user perspective) by having multiple swap partitions over two or more hdd's ?
- 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
|
|
|
04-29-2021, 05:59 PM
|
#2
|
Moderator
Registered: Mar 2008
Posts: 22,150
|
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.
|
|
|
04-29-2021, 06:28 PM
|
#3
|
Member
Registered: Aug 2019
Location: Close to north
Distribution: Fedora
Posts: 124
Original Poster
Rep:
|
Quote:
Originally Posted by jefro
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
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
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
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.
|
|
|
04-29-2021, 06:40 PM
|
#4
|
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
|
Quote:
Originally Posted by Grobe
[snip]
Therefore I have the ability to spread the swap over more than one hdd, however I have some questions in that regard: - Can one get (slightly) better swap performance (i.e. from user perspective) by having multiple swap partitions over two or more hdd's ?
- 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...
|
|
|
04-29-2021, 06:47 PM
|
#5
|
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
|
Quote:
Originally Posted by Grobe
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...
|
|
|
04-29-2021, 06:57 PM
|
#6
|
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,272
|
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.
|
|
|
04-29-2021, 09:14 PM
|
#7
|
Moderator
Registered: Mar 2008
Posts: 22,150
|
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.
|
|
|
04-29-2021, 10:42 PM
|
#8
|
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
|
|
|
1 members found this post helpful.
|
04-30-2021, 04:15 AM
|
#9
|
LQ Guru
Registered: Aug 2016
Location: SE USA
Distribution: openSUSE 24/7; Debian, Knoppix, Mageia, Fedora, others
Posts: 6,188
|
Quote:
Originally Posted by Grobe
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.
|
|
|
04-30-2021, 11:32 AM
|
#10
|
Member
Registered: Aug 2019
Location: Close to north
Distribution: Fedora
Posts: 124
Original Poster
Rep:
|
Thank you for responding
Appreciate for answers.
Quote:
Originally Posted by frankbell
|
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
. . . . 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
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
Swap uses disk blocks without any filesystem. It can use a whole unformatted disk or an unformatted partition.
|
Quote:
Originally Posted by jpollard
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).
|
|
|
|
04-30-2021, 06:12 PM
|
#11
|
LQ Sage
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,675
Rep:
|
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.)
|
|
|
05-03-2021, 03:50 PM
|
#12
|
Moderator
Registered: Mar 2008
Posts: 22,150
|
"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.
|
|
|
05-04-2021, 01:48 PM
|
#13
|
Member
Registered: Dec 2020
Posts: 170
Rep:
|
I propose running a light distro (Puppy, antiX...) and no swapping.
It's good for our sanity.
|
|
|
05-04-2021, 03:15 PM
|
#14
|
Member
Registered: Aug 2019
Location: Close to north
Distribution: Fedora
Posts: 124
Original Poster
Rep:
|
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
|
|
|
All times are GMT -5. The time now is 05:53 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|