Should I use a SSD or HDD for "swap" on an old computer

8,299

Solution 1

SSD is definitely a steroid to any system. Even machines already sentenced to scrap are revived by it. On the other hand, factory specifications really state that their statistical lifetime is smaller than that of HDDs. BUT today even the cheapest SSDs are sold with 3 years of guarantee. I doubt anyone can foresee what kind of gadgets we will use 3 years from now, that's pretty fair. Sure, it may still crash within that time frame but, as we all must know, if you have something in one instance only, without a backup, then you have already none, no matter of you have HDD or SSD.

I assume you have already guessed what my thoughts are leading to: unless I had some RAID for which I would have to buy HDDs of the same type, I would buy SSD(s) (well, I did it).

Solution 2

Your question states speed is not a factor, but resources are. In this case, HDDs give you far greater GBs for your money than any SSD on the market currently. If you're after pure resource, HDDs would currently be your best option, depending on exactly how much extra resource you feel you need. However, I'm not sure you really mean that, as in the wrong set up, the speed difference could be very significant.


Now, in terms of reliability, that's difficult to say. Firstly, you haven't actually stated what resource intensive operations you plan to operate that may require a swap partition. The swap partition will only be used beyond 4GB of RAM, so unless you're running operations that are consistently causing >4GB RAM to be rewritten, you may not be causing any PE cycles on SSD blocks at all, and these are our usual indicator of how soon an SSD will fail. An HDD will have mechanical factors to take into account. Even reading across an HDD will cause the heads to seek, possibly quite a lot if you're also using the drive as a normal storage device as well as swap memory. This will cause additional wear to the drive.

Secondly, SSDs are a lot more reliable now than they were at their first implementation (Which unfortunately tarred them as unreliable years later), with most of them easily outlasting the normal life of a machine. Again, it's very hard to say exactly how long a device will live (manufacturers will provide MTTF and MTBF averages, but these are on the whole quite misleading and can only give you a vague statistical idea), but one metric that can give you a somewhat better idea is the warranty periods offered, which typically are longer for SSDs than HDDs now (Figured I should cite a source - Samsung provide 36 months minimum for SSDs and 24 months minimum for HDDs).


Let's consider that speed is a factor. Firstly, your motherboard being of an age where it has DDR2 RAM may only have a SATA2 controller, and as such, you'll probably be bottlenecking the maximum throughput of a lot of SSD's anyway. Of course, the main benefit to an SSD is the incredibly low latency and high IOPS against a HDD, which, if you're using it purely as a swap drive, is going to be very important.

Of course, swap is definitely not a replacement for real RAM, and can't come close to matching the speed RAM, even at DDR2 speeds, can reach. An SSD (heck, even a bank of RAID striped SSDs) looks incredibly slow if you're comparing it to RAM. An HDD looks incredibly slow when compared to an SSD. If you must use a swap in order to make up for a lack of RAM, an SSD will at least give you a fighting chance of making up for the drop in speed.

In order of best case scenario in my opinion:

  1. Upgrading the machine to allow for more, faster RAM.
  2. Using an SSD as a dedicated swap partition.
  3. Using an SSD as a shared swap and boot/data partition.
  4. Using an HDD as a dedicated swap partition.
  5. Using an HDD as a shared swap and boot/data partition.

If your situation is 2 or 4, the reliability really shouldn't be a concern anyway, as you won't be losing any actual data and the device should have a long enough warranty to cover you until you can go for the best option of actually having more RAM.

Solution 3

The big question is "Does this support AHCI" - which you'll need for maximum performance and things like trim to work. Even without it, an SSD is faster than a spinning rust drive - but its less of a obvious choice.

You do want an SSD, and having it for swap should make some difference. AHCI support should tip the balance towards getting an SSD tho.

Amusingly enough, while I don't have performance numbers, I've tried a seriously low end ssd with almost no cache, (a 120gb 'king dian' running a silicon motion controller). Its MLC (so slightly longer life) and performance wise its decent - It'll even let you run windows 10 tolerably on a system with less than optimal ram. That said, if you don't have AHCI, your maximum speed is limited (Tried a better drive on a dell mini10, which only runs compatibility mode, and it was underwhelming). Considering SSDs are roughly 30c a gb these days, meh, if its important, back it up, and restore or get a spare. Also consider than an SSD will always have better random access speeds.

I'm almost sick and tired of pointing out SSDs wearing out is uncommon - more likely your controller fails. My answer here covers all that. SSDs rarely wear out. If you're worried, just spend a little more and get a better SSD. Any component can randomly fail.A SSD wearing out the way people fear is desireable since you get ample warning. A SSD or HDD having controller failure or a HDD having a sudden headcrash or something of that sort does not. Treat any storage as something that can fail at any time.

I'd also consider this is an older machine. A modern 'nuc' class machine may have comparable performance (Or better in some respects), save power and probably be easier to maintain. I'd suggest getting an SSD as the first part of a gradual new build. Consider this machine is likely...greater than a decade old and stuff like capacitors may fail. I suspect even a budget SSD may outlast your motherboard. If nothing else, consider seeing if anyone has a machine with DDR3 they want to get rid of cheap ;p. That said, I've upgraded core 2 era laptops and the speed difference has been significant, even on creaky old machines. They were pretty much the earliest systems to support AHCI too.

I'd also suggest not only using the SSD for swap - it makes a ton of sense to get a reasonably sized drive (Its hard to find anything smaller than 120gb anyway) and store your docker containers on it as well.

I'd not mess with swappyness. You want as much ram used as possible, and your system knows when not to page.

Solution 4

In your HDD vs SSD debate let me give you another alternative: use a USB Flash drive formatted to swap and mount it. Those have a limited lifespan too, but can easily and very cheaply be replaced in case of failure; especially since you will use a relatively low memory flash, such as a 8GB one (2 x RAM-Size should suffice).

This will not be as fast as a SSD disk, since you will be limited to USB bandwidth (assuming your old computer doesn't have USB 3.0), however it still will increase your computers speed noticeably.

Solution 5

The wear levelling algorithms (and individual cells with improved resilience) used by modern SSDs are sufficient that the failure rate even in the face of lots of random writes to a subset of their blocks (i.e. when used as swap in a low RAM situation) will be no worse than a traditional hard drive, so if speed is a factor go for that option.

As you state that "speed is not a factor" though, a non-solid-state drive will give you far more space for the same money, so if you need more space than an SSD in your budget will give then go for that instead.

You could always get both: a small SSD for some parts and a traditional drive for mass storage.

One other difference to note is that in my experience SSDs "just fail" when they go where traditional drives are more likely to fail in a way that will be seen in SMART readings beforehand, so while there is no real difference in overall failure rate a traditional drive may fail in a safer way (i.e. you will get advanced warning) when not used in RAID (assuming of course that you actually monitor SMART readings for changes).

Share:
8,299

Related videos on Youtube

ValeriRangelov
Author by

ValeriRangelov

https://www.linkedin.com/in/valeri-rangelov

Updated on September 18, 2022

Comments

  • ValeriRangelov
    ValeriRangelov over 1 year

    Introduction

    Let's imagine some environment where the speed is not a factor. In my case I am using a really old computer for a "server" with a lot of stupid things ( personal lab ). It is more important the amount of resources, not their speed.

    On what hardware we can use it

    My "server" is with 4 GB RAM DDR2 800Mhz and Intel Pentium CPU x86_64 ( with two cores ). So the motherboard doesn't support more then 4 GB RAM.

    Control of the "swap"

    It is a Linux "server", there is a docker install on it, so every application running into a container with RAM and Swap limit.

    Also there is a magic variable:

    vm.swappiness
    

    The swappiness parameter configures how often your system swaps data out of RAM to the swap space.

    Question?

    HDD and SSD have life spin. And if we using it for a "swap" it is a high read / write operations. Of course It is not a production "server", but it is not also a desktop / personal computer. Anyway It is a bad situation for everyone to broke the hardware, specially when it is an old and the bigger part of their life is over.

    So which one is better? Will be a HDD really slow and useless or SSD has a less life spin then HDD?

    • Xen2050
      Xen2050 about 8 years
      I'd try not to require a swap at all, or disable it, but an SSD will "break" from too many writes, a regular HD shouldn't from just writes, so use the HD?
    • Keltari
      Keltari about 8 years
      always choose the SSD.
    • Canadian Luke
      Canadian Luke about 8 years
      Your processor and motherboard will handle more than 4 gb of RAM
    • user1306322
      user1306322 about 8 years
      could you make the title more reflect the real question?
    • ganesh
      ganesh about 8 years
      Choose the SSD. Truly ancient SSDs had problems with lots of writes. Any modern SSD should handle heavy writes just. Or at least handle them fine for a decade or more. Most people have replaced their SSD by the. (Granted, most people also do not use DD2 hosts anymore, but I thinkthe point is clear).
    • user
      user about 8 years
    • J...
      J... about 8 years
      All these answers and yet nobody has asked the critically important questions - what is the load on this server? What are its roles? How many users? With what sort of duty cycle? How much can you afford an SSD? This is a cost-benefit analysis and we know nothing of your needs or your budget. Who can say if it will be "worth it" or not? Is it a music server for two people, and will you starve for a week if you buy an SSD? Or is it a critical service for twenty people who will lose work time every moment they wait for this system?
  • Danel Lau
    Danel Lau about 8 years
    +1 for the CPU usage. Easy to forget that one, especially on an older system.
  • David Spillett
    David Spillett about 8 years
    The advanced version of "I'd not mess with swappyness": do not mess with swappyness without performing a significant number of realistic benchmarks on each setting you consider, to make sure that it actually helps overall rather than making things slower in most workloads and maybe helping a little in a few others.
  • Kos
    Kos about 8 years
    Careful, it's often something like "3 years or X disk operations of guarantee"
  • MSalters
    MSalters about 8 years
    The worst SSD's are now better than the worst SSD's used to be. The opposite also happened. Some early SSD's were overengineered instead, and they last. Remember, SLC was the initial design, and it's far more robust than MLC and TLC.