LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 02-24-2011, 07:32 PM   #1
EDDY1
LQ Addict
 
Registered: Mar 2010
Location: Oakland,Ca
Distribution: wins7, Debian wheezy
Posts: 6,841

Rep: Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649
What's thepurpose of putting swap at beginning of drive?


I was reading this tutorial & it shows swap at the beginning of drive.
http://genek.net/LinuxAdventures/ins.../desktop1.html

Although I've already installed slackware & put the swap at the back of os, I would still like to know the benefits and purpose of putting at the beginning.
 
Old 02-24-2011, 07:36 PM   #2
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
I know one thing for sure - It gets written to the inside of the platter, thus making it faster to access it. Data written to the outside of the disk, especially near the edge, takes a bit longer to access and read the data.
 
1 members found this post helpful.
Old 02-24-2011, 07:45 PM   #3
volkerdi
Slackware Maintainer
 
Registered: Dec 2002
Location: Minnesota
Distribution: Slackware! :-)
Posts: 2,504

Rep: Reputation: 8461Reputation: 8461Reputation: 8461Reputation: 8461Reputation: 8461Reputation: 8461Reputation: 8461Reputation: 8461Reputation: 8461Reputation: 8461Reputation: 8461
Quote:
Originally Posted by corp769 View Post
I know one thing for sure - It gets written to the inside of the platter, thus making it faster to access it. Data written to the outside of the disk, especially near the edge, takes a bit longer to access and read the data.
Logically, I'd think the best place for the swap partition to be would be near your Linux partition(s), or other most actively used partitions. If the swap partition is the only one being used on that drive, I wouldn't expect it to matter where it is on the platter.

Of course, the hard drive manufacturers could be using geometry or other tricks that throw my logic out the window. I don't really know.
 
2 members found this post helpful.
Old 02-24-2011, 07:49 PM   #4
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
Quote:
Originally Posted by volkerdi View Post
Logically, I'd think the best place for the swap partition to be would be near your Linux partition(s), or other most actively used partitions. If the swap partition is the only one being used on that drive, I wouldn't expect it to matter where it is on the platter.

Of course, the hard drive manufacturers could be using geometry or other tricks that throw my logic out the window. I don't really know.
That is true, especially if you have a swap partition that is pretty huge. As far as geometry, it would also depend on how big the hard drive is.
 
1 members found this post helpful.
Old 02-24-2011, 07:51 PM   #5
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Quote:
Originally Posted by corp769 View Post
I know one thing for sure - It gets written to the inside of the platter, thus making it faster to access it. Data written to the outside of the disk, especially near the edge, takes a bit longer to access and read the data.
That is exactly backwards. The edge of the disk spins faster than the inner part. That makes it possible for data to transfer faster on the edge compared to transferring on the inner part of the disk.

You can prove this by doing a dd to /dev/null and using iostat to watch the speed of the data transfer.
Code:
dd if=/dev/sda of=/dev/null bs=4096 conv=notrunc,noerror
If you do that you will notice that the data initially transfers quickly but soon slows down. The built in disk buffer will not significantly affect the results since this test reads the disk and does not read the same data twice.

@EDDY1, people used to put the swap partition at the beginning of the disk back when disks were slow and RAM was expensive. Back then the performance of the swap data transfers would greatly affect the overall performance of the computer. These days disks are fast and RAM is cheap. You should have enough RAM that your computer swaps very little if at all. Therefore you can put the swap partition anywhere. Your computer will (might) work faster if you put the software closer to the beginning (edge) of the disk.

Last edited by stress_junkie; 02-24-2011 at 08:03 PM.
 
2 members found this post helpful.
Old 02-24-2011, 08:07 PM   #6
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
Quote:
Originally Posted by stress_junkie View Post
That is exactly backwards. The edge of the disk spins faster than the inner part. That makes it possible for data to transfer faster on the edge compared to transferring on the inner part of the disk.

You can prove this by doing a dd to /dev/null and using iostat to watch the speed of the data transfer.
Code:
dd if=/dev/sda of=/dev/null bs=4096 conv=notrunc,noerror
If you do that you will notice that the data initially transfers quickly but soon slows down. The built in disk buffer will not significantly affect the results since this test reads the disk and does not read the same data twice.

@EDDY1, people used to put the swap partition at the beginning of the disk back when disks were slow and RAM was expensive. Back then the performance of the swap data transfers would greatly affect the overall performance of the computer. These days disks are fast and RAM is cheap. You should have enough RAM that your computer swaps very little if at all. Therefore you can put the swap partition anywhere. Your computer will (might) work faster if you put the software closer to the beginning (edge) of the disk.
Got ya, thanks for that. Am I thinking of a CD then?
 
1 members found this post helpful.
Old 02-24-2011, 08:12 PM   #7
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Quote:
Originally Posted by corp769 View Post
Got ya, thanks for that. Am I thinking of a CD then?
Yes. Thankfully CDs start reading from the center toward the outer edge. That allows any size CD to work in any CD player without having some mechanism to detect the size of the CD. Think back to vinyl music records. The 45 RPM records were smaller than the LP records. Turntables needed to be able to detect the size of the record so that they would place the arm on the outer edge of the record. This problem was avoided in CDs by making them start reading from the center.

Last edited by stress_junkie; 02-24-2011 at 08:15 PM.
 
1 members found this post helpful.
Old 02-24-2011, 08:14 PM   #8
vtel57
Senior Member
 
Registered: Jul 2006
Location: USA
Distribution: Slackware64 - 14.2 w/ Xfce
Posts: 1,631

Rep: Reputation: 489Reputation: 489Reputation: 489Reputation: 489Reputation: 489
I don't know about now, but back in the day when folks were still using EIDE drives, the newer kernels started seeing everything as SATA. I had issues with some distributions seeing my /swap partitions that were on my EIDE drives beyond the 15 partition SATA limit. Since then, I've gotten into the habit of placing my /swap partitions within the first 10 partitions on any drive, regardless of EIDE/SATA.
 
1 members found this post helpful.
Old 02-24-2011, 08:24 PM   #9
EDDY1
LQ Addict
 
Registered: Mar 2010
Location: Oakland,Ca
Distribution: wins7, Debian wheezy
Posts: 6,841

Original Poster
Rep: Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649
Quote:
Posted by stress junkie
@EDDY1, people used to put the swap partition at the beginning of the disk back when disks were slow and RAM was scarce. These days disks are fast and RAM is cheap. You should have enough RAM that your computer swaps very little if at all. Therefore you can put the swap partition anywhere. Your computer will (might) work faster if you put the software closer to the beginning (edge) of the disk.
Thank you and that answers my question. Basically it's kind of a dated practice.
I am not in anyway saying that tutorial is dated though, as it is quite useful and informative.
Today is the day I'll make that installation complete.

Also the information given by corp769 & volkerdi, helps have a better understanding of the process.
 
Old 02-24-2011, 08:25 PM   #10
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
Quote:
Originally Posted by EDDY1 View Post
Thank you and that answers my question. Basically it's kind of a dated practice.
I am not in anyway saying that tutorial is dated though, as it is quite useful and informative.
Today is the day I'll make that installation complete.

Also the information given by corp769 & volkerdi, helps have a better understanding of the process.
Just don't give me negative rep for getting my answer ass-backwards at first LOL
 
Old 02-24-2011, 08:30 PM   #11
EDDY1
LQ Addict
 
Registered: Mar 2010
Location: Oakland,Ca
Distribution: wins7, Debian wheezy
Posts: 6,841

Original Poster
Rep: Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649
Linux creates debates to get answers.
 
Old 02-24-2011, 08:39 PM   #12
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
Exactly.... We all learn from it too.
 
Old 02-26-2011, 08:00 AM   #13
davidsrsb
Member
 
Registered: Oct 2003
Location: Kuala Lumpur, Malaysia
Distribution: Slackware 13.37 current
Posts: 770

Rep: Reputation: 33
Quote:
Originally Posted by stress_junkie View Post
Yes. Thankfully CDs start reading from the center toward the outer edge. That allows any size CD to work in any CD player without having some mechanism to detect the size of the CD. Think back to vinyl music records. The 45 RPM records were smaller than the LP records. Turntables needed to be able to detect the size of the record so that they would place the arm on the outer edge of the record. This problem was avoided in CDs by making them start reading from the center.
This choice also made the CD far less vulnerable to damage at the edge of the disc
 
Old 02-26-2011, 09:47 AM   #14
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
Just wanna add this word, the practice used to be aimed at placing the swap aarea closest to where the disk head parked. This used to be toward one side, where the practice now usually parks the head in the middle of the physical disk so that access times to any part of the surface are about the same.

The thing that nobody addressed is that a disk is not just one surface or even two. Most hard disks hac ve several physical disks and write to both sides of them. When you partition the disk it is highly unlikely that you would get the beginning of the swap partition placed close to where the read head parks -even if you tried.
 
Old 02-26-2011, 11:02 AM   #15
Mark Pettit
Member
 
Registered: Dec 2008
Location: Cape Town, South Africa
Distribution: Slackware 15.0
Posts: 619

Rep: Reputation: 299Reputation: 299Reputation: 299
To throw another angle into this debate, one might even be consider that the practice of even using swap is defunct. Let me explain my logic :-

Way back when computers had very little memory, and that memory was expensive and relatively slow, virtual memory (ie swap) was a good idea. In the 1980's (when I first started on computers), average access time to low-end PC drives was about 25-40 milliseconds and "mainframe" drives were about 15 milliseconds.

Now, 30 years on, memory is probably 10's of thousands of times faster and cheaper, yet hard-disk access time is maybe only 3 times faster. We're talking the average time to move the head to another spot on the disk to fetch your precious page.

My point is that the ratio of memory speed to disk speed (access time, not transfer rate) used to be low(ish) and thus virtual memory was worthwhile. Nowadays that ratio is probably in the millions (that's a guess).

I believe that if your system has to start paging rapidly, you're pretty screwed. I think the only real useful reason for adding a swap partition would be to do a hibernate. If that can be done another way (and I suspect it can), then it should be OK to not even bother with swap. For my low-end Acer Aspire-One running off SSD, that's the recommended setting anyway.
 
  


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
putting drive icons on kde desktop johns123 Linux - Newbie 5 12-17-2017 09:06 AM
Should I put the swap partition at the beginning or the end of the drive? mpyusko Slackware - Installation 32 04-11-2011 06:07 AM
swap: beginning of fast disk or beggining of second disk sl4ckw4re Slackware 4 07-19-2006 06:41 PM
How to resize a swap partition in suse linux at the beginning of the drive? wandering Linux - General 1 06-28-2006 09:20 AM
Id there anything wrong with putting the swapfile on the end of the drive ? lostboy Linux - General 3 05-19-2003 01:35 PM

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

All times are GMT -5. The time now is 08:06 PM.

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