Linux - HardwareThis forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with 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.
Is your swap partition primary or extended. How should it be?
I always set up my swap and my root partition as primary, but I was wondering, should I set up swap as extended from my primary root partition, or it doesn't matter whether it's going to be primary or extended?
Hello!
Well, it does not matter if you use a windows, and a linux, and you don't want to use other OS in the future. For storage partitions you use extended parts I suppose. If you plan to use more than 2 OS's in the future, than an extra primary partition can be handy. If you want to live with 2 OS's, than you can keep your current partitioning. That's all.
It should not really matter where you put your swap although I have noticed that some people have problems booting if they put swap as the first primary partition.
I've had swap in both primary and extended, it makes no difference. FWIW, I usually put swap at the end of the drive (ie, it's the last partition I define, and thus typically is in extended)
I have my swap partition as the 2nd primary partition, /boot being the first. As I have plenty of RAM it is hardly used. Everything else is on a logical partition in the extended partition - /, /usr, /var, /opt, /home, /tmp). As for performance, I would suspect it would be better if the swap partition is at the centre of the disk (less head movement) or on another disk altogether which would mean either a big swap partition or put other partitions on with it. If you really want extra performance then how about SATA disks?
Under Linux there is no requirement for any primary partitions. Full stop.
Nor performance penalty.
As for file (directory) placement - forget it; for almost everybody it's a waste of time. What's the point of worrying about /var when /home is at the other end of the drive for example ???.
And the I/O schedulers aggregate the I/O for you anyway unless you are in the (very) unusual situation of using NOOP. Then there's (O/S and drive) caching, maybe even RAID, or LVM, or ...
That was a strictly theoretical question, actually. I have 2 GB DDR2 and Sata 2 disks so I guess I could dispense with swap space altogether.
I 've heard your remark about the center of the disk being the best spot before but I've always wondered whether that's a "universal" truth. It just seems to me that the best option is to place swap on the fastest part(s) of the disk, right next to your system files. Which explains my remark about the start of the disk or (at least the platter). On the other hand, I do agree that it's a good idea to spread swap across multiple disks whenever that's an option, especially with pri=1 option.
syg00:
Those are really interesting remarks but again I wonder whether those are valid at all times. E.g. I use Gentoo so I occasionally do lots of compiling - do you really think that I wouldn't benefit at all from having var on the fastest part of the disk?
On the other hand, I do agree that it's a good idea to spread swap across multiple disks whenever that's an option, especially with pri=1 option.
Except for that pesky issue of memory just being so cheap. If you never use the swap space, it doesn't matter where it is. Unless you're running an enterprise server, put your swap on the clunkiest slowest drive you have. That way, if you ever actually use it, the slowness will punish you so much you'll go out and buy another stick of RAM.
Those are really interesting remarks but again I wonder whether those are valid at all times. E.g. I use Gentoo so I occasionally do lots of compiling - do you really think that I wouldn't benefit at all from having var on the fastest part of the disk?
There is no (effectively) fastest part of the disk on modern hardware.
There are plenty of ways to speed up compiling - worrying about directory placement ain't one of them IMHO. With the obvious exception of /tmp - make sure it's in memory.
In most modern desktop Linux systems, swap seldom actually gets used. Keep in mind that swap will only get used if/when the system demands for memory exceed physical capacity, and thus the system is forced to write memory pages to disk. The more RAM you have, the less likely that becomes, and my guess is that if you've got, say, 256Mg RAM, your swap space might get used lightly, with 512 it might get used once in a while, and with 1G or more it probably almost never gets used.
For high traffic, professional grade servers, having a lot of swap is good insurance, but for the typical desktop user, setting up a swap space or more than say 512Mg is probably not really necessary. Back in the days when having 16Mg of RAM was considered impressive and having 32Mg of RAM was considered bleeding edge, setting up a swap of twice the size of RAM was important, but these days, it's pretty rare that a typical desktop user will actually put such a heavy load on the CPU that all RAM is in use (meaning that the results of running "free" show that the 'total' value in Mem is the same as the 'used' value in "-/+ buffers/cache") and the "twice RAM rule" is a legacy of long-past years
To return to the original question, my personal view would be that swap probably isn't going to get used much, and thus, its location on the disk is not significant in terms of performance
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.