Swap files have been around forever. You really don't need to worry about file fragmentation on an SSD because of the way files are written and being handled by the controller. Partitions are contiguous, so they don't get fragmented, but all the writes would be confined to a smaller space on an SSD so it would wear it out faster.  Ext4 file systems spread files out to prevent file fragmentation, but when your hard disk gets full it is possible to get some fragmentation. On an SSD you should not let it get full, a full SSD will start writing to the same areas more often shortening the life of the SSD.


On Thu, Oct 29, 2020, 7:15 PM Seabass via PLUG-discuss <plug-discuss@lists.phxlinux.org> wrote:
Defragmentation should be an issue for you on an SSD, even if there is some, right?


------------------------------

Message: 4
Date: Wed, 28 Oct 2020 17:08:03 -0700
From: Matt Graham <mhgraham@crow202.org>
To: <plug-discuss@lists.phxlinux.org>
Subject: Re: swap file vs swap partition
Message-ID: <064f92165a42d6f88a3430b42a5211f6@crow202.org>
Content-Type: text/plain; charset=UTF-8; format=flowed

On 2020-10-28 16:24, Steve Litt via PLUG-discuss wrote:
> On Wed, 28 Oct 2020 13:43:22 -0700
> Bob Elzer via PLUG-discuss <plug-discuss@lists.phxlinux.org> wrote:
>> The biggest difference is, files can become fragmented while
>> partitions don't.
> I had no idea there was such a thing as a Linux swap file. I guess
> that's a recent thing.

You could use a file as swap space in the early 2000s. I remember
doing that on a few machines then.

> If my partition file becomes fragmented, is there a way for me
> to defragment it?

Probably not. However, file fragmentation is not generally a problem
on modern machines because disks and CPUs are much faster than they were
in 1998. If you use ext4 and have a disk that's less than 10 years old
and less than 95% full, you will not notice anything. /swapfile on my
laptop has 11 extents and it doesn't seem to have any problems.

--
Crow202 Blog: http://crow202.org/wordpress
There is no Darkness in Eternity
But only Light too dim for us to see.

---------------------------------------------------------------------------------
PLUG-discuss mailing list - PLUG-discuss@lists.phxlinux.org
To subscribe, unsubscribe, or to change your mail settings:
https://lists.phxlinux.org/mailman/listinfo/plug-discuss