Why is it faster to have more primary partitions when using Linux?
Please give some real examples; I know some theoretical reasons but I don't understand them well.
The main reason might be caching, as Linux individually caches filesystems.
Having a single drive with a single partition means, all data on the filesystem competes against each other in the cache. Hence spool-data and binaries, user files and webserver, all use this one big cache.
If bigger data transfer (downloads, streaming movies, etc.) is going on, these will virtually flush the one single cache, so often used binaries etc. vanish from the cache and must be re-read from disk - which may take a while, as large data transfers are going on, so the drive is heavily loaded!
If you have more than one partition each one is cached individually. Hence you have chances that the binaries are still cached even if the webserver cache is heavily loaded.
However this depends on the used caching strategy. As I heared there are several different cache strategies out there today, but sadly I had no time to dive into that deeper.
There also might be a second reason, however today I think this is no more similar relevant:
Maintaining larger structures in the kernel takes more RAM. In old days when there was not much RAM (say 256 MB) filesystems could go so large that you were not able to fsck them without enabling swapping. Today this usually is no more of any issue.
However larger structures need more frequent flushing of pages. Smaller partitions have smaller structures, so the likeliehood that more frequently used parts are still present in the kernel are higher.
You even were able to see this on nearly idle systems in the old days, as these were not able to keep everything in memory even without having larger disk accesses.
But today with virtually enough memory I don't think this is of any importance.
A third reason might have to do with elevators, say how Linux accesses data.
Linux tries to re-arrange disk access, such that the drive's head works more or less like an elevator which tries to use some optimized path going up and down.
Keeping similar data close together can improve access, as then you can read in portions of those requested information in a more predictable way. So access to partitions like /usr/ improve when this information is kept close together.
However this, too, gets more and more unimportant today, as the emerging solid state disks do not have physical drive heads, so seeking time more and more becomes unimportant.
With the upcoming of all those new filesystems like BTRFS and ZFS all the discoveries of the last 30 years or so on clever partitioning become void. These filesystems do not have any notion of "partition" anymore, so I think partitioning your drive is something that will become more and more obsolete.
Already today with
So it is true, that with some certain applications (database raw devices) your disk setup might be somewhat important to improve access speed. However except for such rare cases it is not worthwhile to try to find a super-clever-all-time-best-and-perfect partitioning scheme, as this will only speed up things in a low % area, if you notice any effect at all.
Properly laying out your application (Grid computing etc.) offers far more speed improvement possibilities. Or to speak for the consumer market:
Don't buy your Computer where you buy apples (those you eat). With only a few $ more you often can get a system which is faster and often less power hungry - which will pay out on the long term.
So stick to any partitioning scheme you like and just buy a little more clever - this will improve performance most ;)
There are many things that can benefit performance when you divide your disk in many partitions instead of having all your files stored in one big partition. Some reasons are:
So, more than just "More primary partitions is better" you should consider that a good knowledge of how your system will be used and puting that knowledge to good use in planning the partitioning of your disks may give you better performance.