Swap partition on an SSD

Questions about Grub, UEFI,the liveCD and the installer
Forum rules
Before you post please read how to get help
Post Reply
in-gold
Level 1
Level 1
Posts: 27
Joined: Sun Apr 12, 2015 10:29 pm
Location: Milwaukee, Wisconsin, USA

Swap partition on an SSD

Post by in-gold »

Good idea or not?
On one hand SSD's are fast fast fast. So memory paging will be seamless.
OTOH, SSD's have limited writes, As I was told to never defrag an SSD, by the same token maybe the writes involved in memory paging might be bad-bad.

When mechanical sectors go bad, like due to surface wear and tear or whatever, that can be marked as bad and we can go on. When too many sectors go bad, that drive, or what's left of it, can be copied to another drive and trashed.

What happens when SSD memory banks go bad? Does garbage collection controller algorithms get in the way of page swapping?

How about it? Is there any special install parted configurations? I read ext4 works good for SSD's.
MrPuff
Level 1
Level 1
Posts: 9
Joined: Wed May 27, 2015 2:48 pm

Re: Swap partition on an SSD

Post by MrPuff »

I wouldn't worry about it too much. Most machines have enough ram these days that there's probably not much going on with the swap file anyway. I've got 6gb ram and I run top ever now and then to see what's going on while I'm doing graphics work and have not even noticed any swap being used.

You're right...EXT4 is good for SSD's or so I've read.

http://techreport.com/review/27436/the- ... -petabytes
Shunjoss
Level 3
Level 3
Posts: 145
Joined: Sat Aug 30, 2014 2:38 pm

Re: Swap partition on an SSD

Post by Shunjoss »

in-gold wrote:What happens when SSD memory banks go bad? Does garbage controller algorithms get in the way of page swapping?
I have heard if a memory stop working after too much write/erase cycle, this will "simply" be dead sector. Causes your SSD to be tinier.
So you will have less and less total disk space.
Linux mint is awesome.
in-gold
Level 1
Level 1
Posts: 27
Joined: Sun Apr 12, 2015 10:29 pm
Location: Milwaukee, Wisconsin, USA

Re: Swap partition on an SSD

Post by in-gold »

Well, okay, that settles it. I have 20G RAM and maybe there will be no memory paging. I'm okay there.. I read about issues with hibernate and insufficient swap space, but I won't be doing any hibernating. Since Mint install complains when I have no swap space, I will just make a 2GB swap partition on my SSD.
User avatar
Derek_S
Level 6
Level 6
Posts: 1278
Joined: Sat Dec 28, 2013 5:36 pm
Location: Long Island, N.Y.

Re: Swap partition on an SSD

Post by Derek_S »

in-gold wrote:Well, okay, that settles it. I have 20G RAM and maybe there will be no memory paging. I'm okay there.. I read about issues with hibernate and insufficient swap space, but I won't be doing any hibernating. Since Mint install complains when I have no swap space, I will just make a 2GB swap partition on my SSD.
Hello in-gold - Making swap minimal in size and not using hibernation is probably the best way to go when using a SSD and is a good idea on your part. I've seen other posts where people install with no swap partition and get error messages as a result, which you are already aware of.

Another thing you can do is limit the amount of "swappiness", or in other words, to alter the balance between the use of physical memory vs. virtual memory on your system. Open the Terminal and enter " sudo cat /proc/sys/vm/swappiness ", and you will see the value "60" is returned, which is the default value used for swappiness. If you want to alter swappiness, enter " sudo gedit /etc/sysctl.conf ", scroll down to the bottom of this file, and insert two new lines at the very end:

### Set swappiness to the minimum value
vm.swappiness=1

After adding these two lines, be sure to click "File" and "Save", then click "File" and "Quit". Setting swappiness to a value of 1 means that all of your physical memory must be used up before the system begins saving memory pages to disk, a.k.a. using swap.

Here is the link where I found this, along with other suggestions on how to optimize your system settings when using a SSD:
https://sites.google.com/site/easylinuxtipsproject/ssd
"Truth is becoming rarer and rarer as time passes. It is only a matter of time before it will cease to exist."
User avatar
Pjotr
Level 22
Level 22
Posts: 15527
Joined: Mon Mar 07, 2011 10:18 am
Location: The Netherlands (Holland)
Contact:

Re: Swap partition on an SSD

Post by Pjotr »

I'd set the swappiness to 1, nevertheless. More about that (and some other SSD tweaks for Linux):
https://sites.google.com/site/easylinuxtipsproject/ssd

Hope this helps. :)

---Edit: Derek_S was quicker than I with responding.... :P
Last edited by Pjotr on Fri Jun 05, 2015 4:03 am, edited 1 time in total.
Tip: 10 things to do after installing Linux Mint 20 Ulyana
Keep your Linux Mint healthy: Avoid these 10 fatal mistakes
Twitter: twitter.com/easylinuxtips
All in all, horse sense simply makes sense.
MrPuff
Level 1
Level 1
Posts: 9
Joined: Wed May 27, 2015 2:48 pm

Re: Swap partition on an SSD

Post by MrPuff »

Or when you install LM 64bit just use the "encrypt home" option and it will create the swap file but it won't mount. :) I didn't even notice swap wasn't working until I ran top a few days after my install.

https://bugs.launchpad.net/ubuntu/+sour ... ug/1310058
in-gold
Level 1
Level 1
Posts: 27
Joined: Sun Apr 12, 2015 10:29 pm
Location: Milwaukee, Wisconsin, USA

Re: Swap partition on an SSD

Post by in-gold »

Great stuff. Derek_S & Pjotr. I read about the swapiness parameter. I think Nixie Pixel has a you tube video about that, among other things after installing. TRIM is what I thought might interfere with the SSD controller's garbage collection, but the Easy Linux tips project link told me just what I need to know. You guys in the mint community ROCK!

There are a lot of things to do after installing Linux which are well documented, but there are some things to do before installing that are not covered quite as well.
MrPuff
Level 1
Level 1
Posts: 9
Joined: Wed May 27, 2015 2:48 pm

Re: Swap partition on an SSD

Post by MrPuff »

Lots of good information in the SSD how to optimize write up however there were a few things that I wasn't too sure about.

The first being fstrim. fstrim runs weekly on Mint and in the optimize how to it says to run it at boot but the fstrim man page says that running fstrim too frequently might negatively affect the lifetime of poor quality ssd drives. Not sure which drives would be considered poor quality but I decided to leave this one alone.

The second thing I didn't like was setting Firefox cache to 0. I can understand the reasoning behind this because if Firefox is your default browser it's probably the application you use the most but not having any cache kind of sucks so what I did was to make a 128mb ramdisk and configured Firefox to store cache on the ramdisk. Yes, I know that everything in the ramdisk will be lost after a reboot but I don't mind.....it's good for privacy.
http://www.jamescoyle.net/how-to/943-cr ... k-in-linux

Not sure how much of this is really necessary. Like any drive it's always a good idea to do regular backups. SSD's are getting cheaper....I just picked up a 240gb Patriot Pryo for $79 so if it does where out in who knows when, I'll just junk it and get a new one....they'll probably be half the price and twice the capacity by then.

Thoughts?
JusTertii
Level 3
Level 3
Posts: 171
Joined: Tue Jul 29, 2014 11:21 pm

Re: Swap partition on an SSD

Post by JusTertii »

in-gold wrote:Good idea or not?
My vote's for not, especially if you've already got 20GB RAM. I doubt you'd ever need swap, unless you're trying to do something really hardcore -- like video editing on one monitor, while playing a AAA game on another, while, I dunno, running a few dedicated servers on a VM. Seriously, I reckon you'll be fine with normal RAM. My box has got a (comparatively) measly 4GB RAM, and I've never used more than 3/4 of that with swap disabled.
MrPuff wrote:Not sure how much of this is really necessary. Like any drive it's always a good idea to do regular backups. SSD's are getting cheaper....I just picked up a 240gb Patriot Pryo for $79 so if it does where out in who knows when, I'll just junk it and get a new one....they'll probably be half the price and twice the capacity by then.
What -- a swap partition? I'd only recommend it if you're pressed for RAM. There's really no point otherwise. My advice? Get one of those conkys that show your CPU & RAM usage, and keep an eye on it for a few days (or however long). If you find your usage creeping up to 100%, then I'd suggest enabling swap. Otherwise? No point, IMHO.

I'd rather load my OS and frequently used apps onto the SSD, as that's where its technical benefits are -- faster boot times from faster reads. And then, yeah, junk it when it breaks. Totally agreed.
User avatar
Pjotr
Level 22
Level 22
Posts: 15527
Joined: Mon Mar 07, 2011 10:18 am
Location: The Netherlands (Holland)
Contact:

Re: Swap partition on an SSD

Post by Pjotr »

MrPuff wrote:the fstrim man page says that running fstrim too frequently might negatively affect the lifetime of poor quality ssd drives.
I think that this could only become an issue when you execute TRIM manually a lot. Or when you add the option "discard" to fstab, because then it forces the system to apply TRIM instantly on *every* file deletion. That's not my favourite method anyway, because it might also slow down the system. :)
Tip: 10 things to do after installing Linux Mint 20 Ulyana
Keep your Linux Mint healthy: Avoid these 10 fatal mistakes
Twitter: twitter.com/easylinuxtips
All in all, horse sense simply makes sense.
Dave B
Level 4
Level 4
Posts: 391
Joined: Thu Jan 08, 2015 10:49 pm
Location: UK

Re: Swap partition on an SSD

Post by Dave B »

in-gold wrote:...When mechanical sectors go bad, like due to surface wear and tear or whatever, that can be marked as bad and we can go on. When too many sectors go bad, that drive, or what's left of it, can be copied to another drive and trashed.

What happens when SSD memory banks go bad? Does garbage collection controller algorithms get in the way of page swapping?...
Hi in-gold,

HDDs and SSDs are not really comparable in their method of data storage, while HDDs keep data mainly in (ignoring fragmentation and defragmentation for a moment) one location and only move parts while replacing bad sectors, an SSDs controller keeps moving data around, a process called wear leveling. So even if you add a swap partition, it will not constantly use the same chips. There's also a certain amount of space reserved (invisible to the user) for over-provisioning (as chips become less reliable they are excluded and replaced by others). After a long period of time, with heavy use, more and more chips will start to fail.

That said, SSDs have improved a great deal in the last few years, this is evident by manufacturers, such as Samsung, being so confident that they now offer a 10 warranty for their top of the range SSD.

One thing you can do to help, while partitioning your SSD, (if you can afford the space) leave 40GB free at the end (or what appears to be the end, based on opening remarks :)) of the drive, this will be added for over-provisioning, and will help keep an SSD more responsive as it fills with data.

David
in-gold
Level 1
Level 1
Posts: 27
Joined: Sun Apr 12, 2015 10:29 pm
Location: Milwaukee, Wisconsin, USA

Re: Swap partition on an SSD

Post by in-gold »

David Black wrote:
One thing you can do to help, while partitioning your SSD, (if you can afford the space) leave 40GB free at the end (or what appears to be the end, based on opening remarks :)) of the drive, this will be added for over-provisioning, and will help keep an SSD more responsive as it fills with data.
Is that an added 40GB unallocated partition or just add +40GB more to the swap partition? I can't see the SSD using unallocated space to do any moving around. 40GB sounds like a lot.

I may be wrong, but I think ext4 does not fragment files very often. I don't think fragmentation would be an issue in any Linux distros. I never hard it being an issue.

Maybe a bit off-topic but here is my strategy:
I already am using a 120GB Windows 8.1 SSD. I just allocated the whole thing NTFS for the OS and whatever Microsoft wants to do with it. That is C:\ and their recovery area. (sda, sda1,sda2) Heck, with all the updates Microsoft wants to do, I think it's not going to last long. But, it's all there for Microsoft. Let them do with it whatever they want--I don't care.

Then I have 2TB mechanical drive I have all my data and VM ware Virtual machines. I partition that thing 6 ways till Sunday (sdb, sdb1 sdb2, sdb3 .... sdbn) . It's got NTFS, FAT32, FAT16, ext4, and even ext2 partitions from time to time . I think I can use this to share data and programs across the different distros. Heck, mint is good at even recognizing stuff on NTFS partitions. That drive can be my all-purpose do-it-all drive. I have a 240 GB OCZ SSD drive on order. I plan on having that drive for Mint and maybe other Linux distros (sdc). I think I will partition it 10GB sdc1 ext4 for / (root), 20G-50GB ext4 for /home, and 4 - 10 GB for swap at least for mint. I am not bothering with LVM. That's about 64 -70 GB, tops, counting overhead for partition tables, etc . Plenty of room for over-provisioning and creating other partitions to mess around with.

I don't really think I will doing much swapping/memory paging with 20GB RAM. Maybe a swap file is a non-issue. The install procedure for Rebecca (don't know about LMDE Betsy) complains if you don't have a swap area. I think it still installs, but asks if you are sure and if you are sure you are sure, or whatever. If I give it something, like 4GB, it won't complain and just install.
MrPuff wrote:

...
The first being fstrim. fstrim runs weekly on Mint and in the optimize how to it says to run it at boot but the fstrim man page says that running fstrim too frequently might negatively affect the lifetime of poor quality ssd drives. Not sure which drives would be considered poor quality but I decided to leave this one alone.

The second thing I didn't like was setting Firefox cache to 0. I can understand the reasoning behind this because if Firefox is your default browser it's probably the application you use the most but not having any cache kind of sucks so what I did was to make a 128mb ramdisk and configured Firefox to store cache on the ramdisk. Yes, I know that everything in the ramdisk will be lost after a reboot but I don't mind.....it's good for privacy.

Not sure how much of this is really necessary. Like any drive it's always a good idea to do regular backups. SSD's are getting cheaper....I just picked up a 240gb Patriot Pryo for $79 so if it does where out in who knows when, I'll just junk it and get a new one....they'll probably be half the price and twice the capacity by then.
I need to read up about how fstrim and configure it properly. Thanks for the heads-up.

I think Firefox cache has more to do displaying offline web pages and not re-loading pages than with actual caching in a RAM management context. All sites force re-loads anyway, like facebook, weather underground almost minute by minute.

As far as the pricing on SSD's: Yeah, heck, I see some people RAID these things. Not sure that's a good idea.
http://www.pcworld.com/article/2365767/ ... raid-0.htm
User avatar
Pjotr
Level 22
Level 22
Posts: 15527
Joined: Mon Mar 07, 2011 10:18 am
Location: The Netherlands (Holland)
Contact:

Re: Swap partition on an SSD

Post by Pjotr »

in-gold wrote:I may be wrong, but I think ext4 does not fragment files very often. I don't think fragmentation would be an issue in any Linux distros. I never hard it being an issue.
That's true, as long as you don't fill your partition too much: 75-80 % is the maximum, if you want to prevent file fragmentation in Linux. More about that here:
https://sites.google.com/site/easylinux ... -in-Linux-
(item 4, left column)
Tip: 10 things to do after installing Linux Mint 20 Ulyana
Keep your Linux Mint healthy: Avoid these 10 fatal mistakes
Twitter: twitter.com/easylinuxtips
All in all, horse sense simply makes sense.
Dave B
Level 4
Level 4
Posts: 391
Joined: Thu Jan 08, 2015 10:49 pm
Location: UK

Re: Swap partition on an SSD

Post by Dave B »

in-gold wrote:...Is that an added 40GB unallocated partition or just add +40GB more to the swap partition? I can't see the SSD using unallocated space to do any moving around. 40GB sounds like a lot. ...
Well not added in the sense of creating a partition then not using it. While creating your partitions, leave 40GB unused at (what appears to be) the end of the drive, and make sure to never create a partition or extend a partition into that space (unless you really need too). Your new OCZ 240GB drive is actually a 256GB, OCZ now reserve extra space for over-provisioning. As Pjotr mentions, you never want to completely fill an SSD with data, doing so will reduce performance.

Your 120GB drive (128GB) will probably last longer than you expect, if you were to analyse Windows updates, with the exception of Windows 7 SP1 and Windows 8.1 upgrade, many are not that large in size, it's more the quantity. Around three years ago, the advice I read went as follows, if you wrote 10GB of data daily to an SSD, it would likely last around 10 years. Since then, SSD technology has advanced.

For your 120GB drive, 40GB would be rather a lot, for optimal performance, possibly reduce your NTFS windows partition size by 20GB.

In relation to swap size, with 20GB of RAM I will be surprised if the swap area will be used (*), even without changing the swappiness setting.

(*) Some programs complain if no swap area is available.

My PC has 16GB of RAM, and I still create an 8GB swap, my reason for doing so, VMware Player performance is degraded and complains if there's no swap area at least equal to the amount of RAM assigned to a virtual machine, even though swap area remains unused, (for others, I've tried recommended preferences and vmx modifications which are supposed to prevent this, but so far been unable to find a solution which works with newer versions of Player, not a problem though, as mentioned, the swap area remains unused.).

David
Post Reply

Return to “Installation & Boot”