[SOLVED] What's thepurpose of putting swap at beginning of drive?
SlackwareThis Forum is for the discussion of Slackware 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.
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.
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.
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.
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.
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.
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.
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.
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.
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?
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.
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.
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.
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
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
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.