5

I'm installing Ubuntu on a Samsung evo 850 SSD drive. System has 4GB memory but no other harddrive. Should I use thedefault partition table or install without swap and make a swap file after installation? Or does it even make a difference whether it’s a partition or a file?

Zanna
  • 70,465
Ville
  • 129
  • 1
    It doesn't make much difference. I am voting to close as opinion based. – Pilot6 Jul 24 '18 at 18:15
  • 1
    Swap on an ssd will cause life-decreasing wear no matter how you implement it. – Nonny Moose Jul 24 '18 at 18:20
  • I agree with pilot6 and Nonny Moose. I would advice against swap on an ssd. Just turn the machine off and don't bother about hibernation or suspend. – Rinzwind Jul 24 '18 at 18:25
  • Since 17.04 a swap file will be created by default instead of a swap partition on new Ubuntu installs. It's not opinion-based according to Canonical, it's a logical upgrade because of the emergence of SSDs. – karel Jul 24 '18 at 18:27
  • @Rinzwind I am using swap on SSD for many years. It is a matter of opinions. – Pilot6 Jul 24 '18 at 18:30
  • 1
    Personally, I use swap files. With sufficient enough amount of RAM swap files are just fine, and swap doesn't get used that much because of RAM. Then again, putting swapfiles/partition on hard drive or USB is an option too. – Sergiy Kolodyazhnyy Jul 24 '18 at 18:33
  • With 4GB or RAM or more, it is moot. You will not use swap anyway with normal use. But do not hibernate nor open 100's of tabs or edit large videos. If you really want to do those thing get more RAM. – oldfred Jul 24 '18 at 19:18
  • 1
    @oldfred your normal use clearly differs from mine. 9GB used and it's not even 10am yet. – jymbob Oct 09 '18 at 08:30
  • Linux will use all your RAM over time. Linux ate my RAM! - memory use cache http://www.linuxatemyram.com/ & Difference between Details screen on RAM and free command http://askubuntu.com/questions/743649/new-16gb-of-ram-installed-yet-i-see-15-3-on-my-system-why?noredirect=1#comment1106622_743649 &
    https://askubuntu.com/questions/184217/why-most-people-recommend-to-reduce-swappiness-to-10-20/184221#184221
    – oldfred Oct 09 '18 at 13:15
  • I think some of these comments are unhelpful. There exist cases like mine where: 1. I cannot add a spinning disk (without sacrificing portability using an external disk via usb). 2. I cannot upgrade RAM, since this stupid model has it soldered on motherboard. 3. RAM usage is high. 4. USB thumbdrive swap is an option, but sacrifices portability and uses up 1 of 2 available very needed ports. I can buy a new computer, but that is a bigger hassle than using swap and hypothetically someone might not be in a position to buy one. – Carolus Feb 12 '20 at 11:13

1 Answers1

10

For new installations of Ubuntu 17.04 and later a swap file is created by default instead of a swap partition. The first LTS release to use a swap file by default is Ubuntu 18.04. It's a logical new feature because of the emergence of SSDs. Creating a swap partition on an SSD will cause life-decreasing wear.*

karel
  • 114,770
  • For users concerned about SSD wear, another thing worth considering is to reduce swappiness to 0 or perhaps to 5. Although the jury is still out on that... – joeytwiddle Dec 19 '18 at 03:12
  • 4
    No-one has said it entirely clearly yet - Does a swap file wear out an SSD less than a swap partition? E.g. due to the SSD being able to shuffle around the specific blocks being worn out by writing more - i.e. SSD wear manager has the whole free space on the system partition to use in case of a swap file versus a very limited amount of space in case of a swap partition. – Carolus Feb 12 '20 at 11:07
  • 1
    So in 2020, on Ubuntu 17+, there's no reason for me to bother touching the Swap file, because the OS will handle everything for me? – Eliezer Berlin Dec 01 '20 at 10:51
  • 2
    @EliezerBerlin For new installations of Ubuntu 17.04+ and all release upgrades that are upgraded from the same, the swap file is created automatically (including by default by the Ubuntu installer) without any additional user intervention being necessary. – karel Dec 01 '20 at 10:55
  • Carolus' question is still pending. Would a swap file cause less wear than a swap partition? I'm not sure about how the difference in partitioning in SSD vs. HDD works, I only know they are somehow different and that SSD works at a more logical level. So I'm expecting this to make no difference (but if so why would they implement the feature in Ubuntu TBW?) but I'm no SSD expert. And since we're at it, if you have the option to put either one in a HDD in order to reduce wear, then would that be advisable? – Piovezan Jan 10 '21 at 14:37
  • SSD has a much longer lifespan than HDD because it is a Solid State Drive with no moving parts whereas HDD has a spinning disk that is subject to mechanical wear. swap space in Ubuntu is configurable with respect to type, size, location, etc. My own swap file in Ubuntu 20.04 is still the default settings that the Ubuntu installer gave it which is a 1.5GB swap file and it's located on the SSD where I have Ubuntu installed. – karel Jan 10 '21 at 14:40
  • @karel That is irrelevant to the question. SSD has a limitation on the number of writes which HDD doesn't have not frequent memory swapping on SSD much probably impacts on that. – Piovezan Jan 10 '21 at 14:44
  • Depending on the model of SSD the expected maximum writes for an SSD can be a large number of writes. – karel Jan 10 '21 at 14:45
  • @karen That is my question. How much swapping would be too much for an SSD? A 16 GB RAM system put on daily hibernation would write at least 16 GB to it every day, not to mention the frequent swapping while working which depends on how many applications you keep open and how you put your system's memory to use. As a rule of thumb the more memory you have the less often you swap but that still depends on how your applications and OS use the memory. – Piovezan Jan 10 '21 at 14:58
  • 1
    You've got it exactly right. It all depends on what you intend to use swap space to do. My computer has lots of RAM and I don't ever hibernate it, so it doesn't need much swap space. btw a swap file in Ubuntu can be configured to be dynamically resized in order to save disk space. – karel Jan 10 '21 at 15:01