LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware > Slackware - Installation
User Name
Password
Slackware - Installation This forum is for the discussion of installation issues with Slackware.

Notices


Reply
  Search this Thread
Old 09-22-2005, 12:08 AM   #1
mpyusko
Member
 
Registered: Oct 2003
Location: Rochester, NY, USA
Distribution: Salckware ver 10.1 - 14.1, Debian too.
Posts: 432
Blog Entries: 1

Rep: Reputation: 41
Should I put the swap partition at the beginning or the end of the drive?


I did a search, but I didn't find the answer. Where do I get better performance? Putting my swap at the beginning of the drive or the end of it? I've installed Linux soooo many times and never bothered to ask. I just put an 80GB hard drive into my Sony PCG-F180 and even though the hard drive is 5400 RPM, I need more speed (it's a PII333, 192mb RAM....every little but helps)

P.S. I'm installing slack 10.2
 
Old 09-22-2005, 12:45 AM   #2
dalek
Senior Member
 
Registered: Jul 2003
Location: Mississippi USA
Distribution: Gentoo
Posts: 2,058
Blog Entries: 2

Rep: Reputation: 79
I have always read to put it on the beginning of the drive, the first partition that you can. I always set up my /boot partition first then my swap space right after. If you think about it the inside of the drive can be read faster than the outside part. That is what I have read anyway. I know there is a difference on the old audio records too.

I have never tested this myself though, this is just what I have always read. I don't know if you can test it either.

That help any?

 
Old 09-22-2005, 01:49 AM   #3
gd2shoe
Member
 
Registered: Jun 2004
Location: Northern CA
Distribution: Debian
Posts: 835

Rep: Reputation: 49
I just did some experimenting with dd. It seems that I get better read response from the end of my Western Digital. This isn't what I would expect. There may be other factors involved here. It would probably be much more objective if I didn't have linux running on the drive.

Bear in mind also, that all new hard drives lie about their geometry. Any given sector that you specify can physically be anywhere on the drive. Some will silently replace tracks with bad sectors for spare ones.
 
1 members found this post helpful.
Old 09-22-2005, 02:30 AM   #4
dalek
Senior Member
 
Registered: Jul 2003
Location: Mississippi USA
Distribution: Gentoo
Posts: 2,058
Blog Entries: 2

Rep: Reputation: 79
Quote:
Originally posted by gd2shoe

Bear in mind also, that all new hard drives lie about their geometry. Any given sector that you specify can physically be anywhere on the drive.
That is very true. Maybe a test for the drive you plan to use would be best. That way you can know what that specific drive will do instead of just assuming what it will do. Taking that info in mind, I bet even two drives of the same exact model would differ in speed depending on the where any bad tracks may be at.

I have 1GB of ram so I rarely use swap. I have no clue how fast it would be or how to test it. It is the second partition on mine though. I used the swapiness thing to make it not use to much swap too. I can't remember where I put that. It's in /etc somewhere.

Well, I just came back fom town. They are saying gas may go up again so I went and filled up my tanks, again. It is $2.54 a gallon here. It was $3.55 a few weeks ago. Greedy oil companies.

Later

 
1 members found this post helpful.
Old 09-22-2005, 05:52 AM   #5
runlevel0
Member
 
Registered: Mar 2005
Location: Hilversum/Holland
Distribution: Debian GNU/Linux 5.0 (“Lenny”)
Posts: 290

Rep: Reputation: 31
Re: Should I put the swap partition at the beginning or the end of the drive?

Quote:
Originally posted by mpyusko
I did a search, but I didn't find the answer. Where do I get better performance? Putting my swap at the beginning of the drive or the end of it? I've installed Linux soooo many times and never bothered to ask. I just put an 80GB hard drive into my Sony PCG-F180 and even though the hard drive is 5400 RPM, I need more speed (it's a PII333, 192mb RAM....every little but helps)
Where to place your swap partition depends in the first place on how many disks you have.

The most important thing you have to bear in mind is that the harddisks have to move the heads and this costs time.

The plates (there more than one to conform what we know as a 'hard disk') spin faster on the border as in the middle. But having only one disk the key bottleneck is not this speed difference but the time lost in moving the heads form one part of the disk to the other. What we need to search is a way to minimize head movement placing the swap partition in a proper place.

If we have two or more disks the obvious place are the first sectors of the disk taking also advantage of paralelization, so one head on one disk can always be there writing into the swap while the other on the other disk is reading or writing somewhere else.

But this advantages disappear if we only have one disk. then the approach is radically different:
With a single disk we need to minimize the travel time of the heads as much as we can. And we can achieve this using the middle of the HD as a swap partiion. This way there will always be a header near and the time spent for a head coming from either the border or the center is only half as much as if you place it at the beginning or the end.

Placing a swap aprtition at the end of a disk is always a bad idea as you won't get the advantage of the reduced travel time of the heads and you will also get an extra penalty in speed and block density.

So the thumbrule is:
  • One HD swap in the middle
  • Multiple Hardisks swap in the first sectors

This can improve the speed of disk transaction on systems which makes a heavy use of swapping; old systems with less than 64MB of (slow)RAM... In more or less modern systems swap space is almost a relic from the past which we use more as a tradition. So on one of my machines (Duron 1.3 GHz, 758RAM DDR 333, 2xSeagate ATA100 40GB HD's) I never have used more than a 1%-4% of my 0.5GB of swap space. As you see there not much use in faster disk access when we aren't indeed
using this space at all.

So if you have plenty of RAM (this means more than 128MB) using an alternative solution could be the right solution. This alternative is to use the dynamic swapping daemon instead of a fixed swap partion, the swapd. This daemon takes care of using the part of the disk which fits best to it's needs to place temprorary swap files, so you don't have to bother about where to place them. Drawback is that you have to recompile the kernel.

So, swap partitions make only sense in old low-ram systems and in laptops where the swap partition is used as susend-to-disk storage.

More info:

Last edited by runlevel0; 09-22-2005 at 05:57 AM.
 
1 members found this post helpful.
Old 09-22-2005, 09:47 AM   #6
powadha
Member
 
Registered: Nov 2003
Location: Zwolle
Distribution: Arch
Posts: 651

Rep: Reputation: 31
Re: Re: Should I put the swap partition at the beginning or the end of the drive?

Quote:
So if you have plenty of RAM (this means more than 128MB) using an alternative solution could be the right solution. This alternative is to use the dynamic swapping daemon instead of a fixed swap partion, the swapd. This daemon takes care of using the part of the disk which fits best to it's needs to place temprorary swap files, so you don't have to bother about where to place them. Drawback is that you have to recompile the kernel.
Didn't know about this option. I don't mind recompiling te kernel so I'm sure to test it out. No partition taken up by swap is a good thing!

Thanx
 
1 members found this post helpful.
Old 09-22-2005, 10:18 PM   #7
Bruce Hill
HCL Maintainer
 
Registered: Jun 2003
Location: McCalla, AL, USA
Distribution: Arch, Gentoo
Posts: 6,940

Rep: Reputation: 129Reputation: 129
If you feel the need for speed, don't forget that you can also get more
from your drives if you'll enable DMA using hdparm. Otherwise, short of
buying more ram, with that lappy there's not much difference you're going
to get no matter where the swap is located.
 
1 members found this post helpful.
Old 09-23-2005, 05:39 AM   #8
infinity42
Member
 
Registered: Apr 2005
Location: England
Distribution: Gentoo
Posts: 142

Rep: Reputation: 16
Quote:
I have 1GB of ram so I rarely use swap. I have no clue how fast it would be or how to test it. It is the second partition on mine though. I used the swapiness thing to make it not use to much swap too. I can't remember where I put that. It's in /etc somewhere.
swappiness is in /proc/sys/vm/swappiness, you can set it permanently by editing /etc/sysctl.conf, and adding something like:
Code:
vm.swappiness = 20
or whatever you like.

Quote:
Well, I just came back fom town. They are saying gas may go up again so I went and filled up my tanks, again. It is $2.54 a gallon here. It was $3.55 a few weeks ago. Greedy oil companies.
In the UK we are paying about £1 a litre. Which I think works out about $7 a gallon.

As to swap speed, get it on a second drive if you can. Try to put it on a different bus to, so a harddrive on a different IDE cable if possible.
 
1 members found this post helpful.
Old 09-26-2005, 03:50 PM   #9
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
Swap partition placement

A really good discussion.

I help a lot of people set up dual booting, & if possible I like following in a 1 drive situation:
  • hda1: /boot
  • hda2: Winders (blech!)
  • hda3: swap
  • hda5: FAT32 -- Common data
  • hda6: GNU/Linux

Dual boot w/ 2 drives -- put it on the <choke>Winders</choke> drive.


I was given an ancient (full height) 3G SCSI & I have always wondered if it would be of any use for swap. I suspect it's so old that it isn't very fast by modern standards.
 
Old 03-22-2007, 02:40 AM   #10
Emmanuel_uk
Senior Member
 
Registered: Nov 2004
Distribution: Mandriva mostly, vector 5.1, tried many.Suse gone from HD because bad Novell/Zinblows agreement
Posts: 1,606

Rep: Reputation: 53
Zoned Bit Recording explain partly the why of outer use of HD for swap

excellent thread!
more sectors on the outer tracks of the hard drive platter than on the inner tracks
see picture and details about Zoned Bit Recording
http://www.pcguide.com/ref/hdd/geom/tracksZBR-c.html
 
1 members found this post helpful.
Old 03-22-2007, 08:01 AM   #11
mpyusko
Member
 
Registered: Oct 2003
Location: Rochester, NY, USA
Distribution: Salckware ver 10.1 - 14.1, Debian too.
Posts: 432

Original Poster
Blog Entries: 1

Rep: Reputation: 41
So basically the answer to my question is.... Put the swap at the beginning of the drive. ?
 
Old 03-22-2007, 08:16 AM   #12
Emmanuel_uk
Senior Member
 
Registered: Nov 2004
Distribution: Mandriva mostly, vector 5.1, tried many.Suse gone from HD because bad Novell/Zinblows agreement
Posts: 1,606

Rep: Reputation: 53
no the answer depends on
- how many drives
- what you (the applications) do with the HD
I have no data, just wanted to bring the info to light.

swappiness is still very important AFAIK

this is still relevant
Quote:
The most important thing you have to bear in mind is that the harddisks have to move the heads and this costs time
Well, at the end of the day how do you know where the firmware put you partition on the physical disk?

Anyway I am no specialist of the question
 
Old 03-22-2007, 08:16 AM   #13
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Nope - the real answer is that with modern hardware and kernels it's pointless worrying about it.
If you are swapping that hard, dedicate disks (and paths) solely to swap devices.

If that can't handle it (say you're doing cyclone simulations for NASA), get PCI memory cards and use them.
 
1 members found this post helpful.
Old 03-22-2007, 08:22 AM   #14
mpyusko
Member
 
Registered: Oct 2003
Location: Rochester, NY, USA
Distribution: Salckware ver 10.1 - 14.1, Debian too.
Posts: 432

Original Poster
Blog Entries: 1

Rep: Reputation: 41
As I said in the top post, it is a single drive Laptop with a 5400RPM 80GB Hard drive. So putting it on a second drive is not an option, and with only 192MB ram, I don't think going without a swap is an option either.
 
1 members found this post helpful.
Old 03-22-2007, 08:33 AM   #15
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Stick it wherever you have room - minimum half a gig. Full gig is better.
The kswapd code allocates by segments, and tries to use a segment that "best fits" what you are trying to swap-out. Swap-outs are also delayed (like normal I/O) in an attempt to aggregate the physical I/O.

Swap-ins are more "on demand", but are optimised where possible.
With the other I/O that will also be hitting that disk, just let the VFS layer handle it. It'll be a lot better than any of us will ever be at trying to second guess it.
 
1 members found this post helpful.
  


Reply



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
DISCUSSION: From beginning to end: ProFTPD MasterC LinuxAnswers Discussion 5 09-24-2005 11:21 PM
Resizing a Partition blocked from both beginning and end apachedude Linux - Hardware 2 01-17-2005 03:02 AM
Where to put swap partition mikieboy Linux - Software 3 11-25-2004 12:01 AM
Is this the beginning of the end for Gnome? WSG Linux - General 8 02-03-2002 01:57 PM
Linux put the swap partition on my second HD. Don't want it there. rdaves@earthlink.net Linux - General 3 09-21-2001 08:42 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware > Slackware - Installation

All times are GMT -5. The time now is 09:16 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