Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I recently installed Ubuntu 11.04 onto a RAID0(stripe) device using the alternate installation disc and manually partitioned the HDs ext4 and swap partitions; during this process, I was reading in a forum walkthrough (can't remember where...) that having the swap partition at the beginning of your hard drive could be better for some reason!

Is the idea that the swap is "closer" at the beginning so its accessed quicker with a lower latency/delay? The HD 'needle' moves less to reach the swap...

This confuses me because I like to think of Hard Drives as likened to a samurai sword(not literally)!

I was told that the last inch or two at the tip of the sword is the cutting edge because it travels the fastest.

(Think of a ball on a string and as you swing it around the ball at the end of the string is travelling at a greater speed than it would be if it was closer to the source - your hand)

BUT since the HD is spinning at (x)RPM then the outer edge of that HD should be spinning relatively faster (+x) providing quicker read/write rate.

So does the swap position affect performance in anyway? If so, is it better to have it placed in the beginning for immediate access, or at the end for increased read/write?

I would think the swap is sized and placed according to the individuals needs but how do I decide...

EDIT:

As a note, I do have 8GB of RAM (4x2GB) so I noticed that the swap has not been used in any of my GIS (mapping and analysis) processing. 8GB is the full capacity for my motherboard.

share|improve this question
    
I thought the slowest part of a hard disk was the arm? –  Allan Aug 13 '11 at 0:28
    
The comparison with a sword doesn't work in this case. Sure, the outer edge of the disk is spinning the fastest, but that "advantage" is exactly negated by the increased distance it has to travel, so that the outer part of the disk makes a revolution in exactly the same time as the inner part of the disk. If you did succeed in gaining anything, it would be so slight that you'd never be able to perceive it. –  Kelley Aug 13 '11 at 6:22
    
@kelley thanks! this is a good point because sometimes I do run a process that can take days to complete so the accumulation of these micro/nano seconds may add up... –  SaultDon Aug 13 '11 at 17:14

4 Answers 4

up vote 6 down vote accepted

Forget swords and balls on string. Think of a stack of CD platters and then you will have in mind an image closer to what a hard drive is actually like.

Wikipedia on hard disks

Think also of the amount of Memory in the computer and ask, how often does the swap partition get used? Your question could be irrelevant. Disks do not have a beginning or an end. They have outer edges and inner edges. Data is placed across more than one platter. Seek times and access times, as well as spin speeds, would turn any answer into a debate.

Note this point from the Wikipedia article under HDD Formatting

Modern HDDs ... appear at their interfaces as a contiguous set of logical blocks; typically 512 bytes long

It only appears that has a beginning and an end. If performance is a concern then more RAM will have a greater effect than the placement of the swap partition.

share|improve this answer
    
this clears up my messy logic of how a HD operates, thanks. I have maxed out ram and currently the HD spin at 7200rpm so that is OK for me. –  SaultDon Aug 13 '11 at 17:17
    
I marked this one as correct, though the other answers had their benefits, this one was simple and really cleared it up by discussing that data is spread across "platters". –  SaultDon Aug 13 '11 at 17:22

You should use RAM, not SWAP, because swap is terrible slow, compared to RAM. You can use RAM for hibernation.

The speed to access the first or the last sector on disk, when the head comes from the sleep position is so small (6–20 ms), that it doesn't affect your experience.

If you have many read/write cycles from swap, so that microscopic intervals could sum up to a mentionable fraction of a second, you would have continuous reading from swap - not repeated movements from a sleep position, so this could only be an argument, if there are more bits read from the outer sectors, than from the inner ones.

But do you know whether the first block is on the outer or on the inner side, and where the head is in sleep position?

And are you sure, that more information is put on the outer sectors? Maybe the bits there are at the proportion wider, as the disks rotates faster, so that you have a constant number of bytes in each sector. At least the diagram of wikipedia (DE) suggests so.

But - modern drives have a controller, which presents himself to the outer world as a virtual hard drive, and manages it's internals on his own, so every model could handle its geometry differently.

If you really depend on performance, you should go for more RAM, more RAM, more RAM. If you can't get more RAM for your machine, you should consider buying a faster hard drive, instead of guessing with it's geometry.

share|improve this answer
    
Good points, and I do not know if the first block is on the inner or outer side, just started using Ubuntu so I am still getting familiar with the whole linux thing. –  SaultDon Aug 13 '11 at 17:04
    
to answer your second question, I don't know if more information is on the outer sectors, only that it can be 'put' there from certain defrag utilities (but linux doesn't really need to be defragged from what I understand) –  SaultDon Aug 13 '11 at 17:06

You can measure the speed of different areas of the hard drive with System > Administration > Disk Utility (palimpsest from command line): pick your hard drive from the list and click on Benchmark. For swap use the read-write test results will be more salient, but please note that the test erases data. The resulting graph should give you an idea of the internal performance differences your drive has.

share|improve this answer

It does not matter, the system will spend just about the same amount of time (maybe delays of microseconds or even smaller than that. All in all you would not realise the difference anyways.) read/writing swap if it's at the beginning or the end.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.