experchange > ubuntu

Rbwd (03-04-20, 03:03 AM)
Does Ubuntu/Mint can create SWAP file when setup?

Or it is better to have SWAP partition instead of file?
Bobbie Sellers (03-04-20, 03:37 AM)
On 3/3/20 5:03 PM, Rbwd wrote:
> Does Ubuntu/Mint can create SWAP file when setup?
> Or it is better to have SWAP partition instead of file?


It is much better in my opinion to have a swap partition.
bliss
Melzzzzz (03-04-20, 05:32 AM)
On 2020-03-04, Rbwd <something> wrote:
> Does Ubuntu/Mint can create SWAP file when setup?


I was surprised as it does now. Like Windows. Sheesh where
this world is comming?
Anssi Saari (03-04-20, 08:59 AM)
Melzzzzz <Melzzzzz> writes:

> On 2020-03-04, Rbwd <something> wrote:
>> Does Ubuntu/Mint can create SWAP file when setup?

> I was surprised as it does now. Like Windows. Sheesh where
> this world is comming?


Does *now*? I think it's been around for a long time. What's unlike
Windows is that Linux can use zero to many of each, partition or file.

As to a preference, I'd say accessing a partition might be a tiny bit
faster than accessing a file within a file system. OTOH, files tend to
be a bit more flexible that partitions.
Dirk T. Verbeek (03-04-20, 10:49 AM)
Op 04-03-2020 om 02:03 schreef Rbwd:
> Does Ubuntu/Mint can create SWAP file when setup?
> Or it is better to have SWAP partition instead of file?


A swap partition has always been part of the standard setup.
(I'm talking about *ubuntu)

In my experience everything slows down once the swab is getting used but
that's very, very rare. (I have 8GB RAM).

A good reason to have a swap equal to RAM is when you want to hibernate
to disk which uses the swap.
Paul (03-04-20, 11:37 AM)
Anssi Saari wrote:
> Melzzzzz <Melzzzzz> writes:
> Does *now*? I think it's been around for a long time. What's unlike
> Windows is that Linux can use zero to many of each, partition or file.
> As to a preference, I'd say accessing a partition might be a tiny bit
> faster than accessing a file within a file system. OTOH, files tend to
> be a bit more flexible that partitions.


Windows can use multiple pagefiles (pagefile.sys).

In the old days, the objective was to use different spindles
for them, for performance reasons. As if the idea of random
4K I/O to hard drives would somehow be "attractive". In the
WinXP era, the behavior of paging was God-awful. Even with
two spindles.

When I do OS installs, I control these things manually,
selecting the sizes and locations I want for it. I don't
allow the computer to do it for me. Windows receives a single
1GB pagefile. Linux receives a 1GB swap partition.
The purpose of these, is "transient behavior insurance".
I don't expect them to be used to any real purpose.

Paul
bilou (03-04-20, 01:17 PM)
On 04/03/2020 02:03, Rbwd wrote:
> Does Ubuntu/Mint can create SWAP file when setup?
> Or it is better to have SWAP partition instead of file?

A swap partition is better as it can be shared between many
Linux installations.
I believe that if one is available on a fixed drive Ubuntu use it.
Soviet_Mario (03-04-20, 01:40 PM)
On 04/03/20 12:17, bilou wrote:
> On 04/03/2020 02:03, Rbwd wrote:
> A swap partition is better as it can be shared between many
> Linux installations.
> I believe that if one is available on a fixed drive Ubuntu
> use it.


I use a single swap partition shared, but I also happen to
per-use HIBERNATION feature.
In that case one have to pay attention, at boot, to boot the
last hibernated distro (and one at a time is allowed anyway
as far as I know).
Some distros (Deb, MX, maybe others) have some pre-boot
safety mechanism that recognize the hibernated image does
not match with the currently requested OS on boot, and
refuse to load (also, the process is aborted before the
saved image is damaged and later can be resumed, choosing
the correct distro<=>image couple).
But maybe this behaviour is not to be taken for granted.
A part from this, which might be a problem only for those
using hibernation a lot, swap partition is both safer in
case of power off and more performant for it is assured it
is a contiguous space on a disk and the off caches I/O with
its maximum effectiveness on a file-system that is not even
a file system. So the buffer lifetime, size and all I/O
scheduling is done without the minimum interference from
other file systems (*)

(*) well, to lessen a bit what said, actually the maximum
I/O is assured if the swap partition stays on a physically
different disk. In a single physical disk, some hardware
limitations in case of heavy regular I/O on system partition
can interfere with swap partition I/O a bit.

As I had been some 3+ years ago a windows user, I must say
that on Linux the increase of performance is lower than the
one gotten on windows (or better : to use a swap file
instead of a dedicated partition, with its file, on windows
is hit worst than on linux, as disk I/O is more performant
on linux whatever it is and so it comes closer to "iron"
limitations, and there is less to squeeze out of it).
Aragorn (03-04-20, 02:54 PM)
On 04.03.2020 at 02:03, Rbwd scribbled:

> Does Ubuntu/Mint can create SWAP file when setup?
> Or it is better to have SWAP partition instead of file?


The Linux kernel can use both swap partitions and swap files, but
historically, UNIX systems have always used swap partitions.

The thing is that the kernel accesses the swap partition as raw drive
blocks, and if you're going to use a swap file, then the kernel must
first pass through the filesystem layer in order to find the swap file,
and then open the file, and only then can it access the raw blocks —
which also means that the swap file must be set up in such a way that
the filesystem layer does not pull any tricks on it, e.g. the
copy-on-write and compression of btrfs must be disabled.

By default, Ubuntu and Mint prefer swap partitions, but you can set
them up with a swap file if you're so inclined.
Aragorn (03-04-20, 02:55 PM)
On 04.03.2020 at 03:32, Melzzzzz scribbled:

> On 2020-03-04, Rbwd <something> wrote:
> > Does Ubuntu/Mint can create SWAP file when setup?

> I was surprised as it does now. Like Windows. Sheesh where
> this world is comming?


Not just Windows. macOS also uses a swap file.
Anssi Saari (03-04-20, 10:23 PM)
Paul <nospam> writes:

> In the old days, the objective was to use different spindles
> for them, for performance reasons. As if the idea of random
> 4K I/O to hard drives would somehow be "attractive". In the
> WinXP era, the behavior of paging was God-awful. Even with
> two spindles.


I remember XP. I turned paging off once for some reason and forgot to
turn it back on. Didn't notice any issues for months so it stayed off
for good. I also managed to squeeze the system partition to 4 GB, later
had to increase to 8 GB. Made for pretty fast image backups and
restores. Hard to do with the later incarnations.

> When I do OS installs, I control these things manually,
> selecting the sizes and locations I want for it. I don't
> allow the computer to do it for me. Windows receives a single
> 1GB pagefile. Linux receives a 1GB swap partition.
> The purpose of these, is "transient behavior insurance".
> I don't expect them to be used to any real purpose.


Yep, in Linux the page file or partition can be used for hibernation as
well so that's a real use for it. So for example right now (after a
recent hibernation) free reports this on my desktop:

$ free -m
total used free shared buff/cache available
Mem: 15994 3137 10066 337 2790 12189
Swap: 20479 4240 16239

Lots of memory free yet over 4 GB of swap used. As I understand it, it's
how hibernation works in Linux, stuff from RAM is pushed to swap and
then system stops. Or possibly only data pages are pushed to swap since
code pages can be loaded from binaries.

Windows is another story. I have a sudden need of disk space on my work
laptop and noticed there's a 22 GB pagefile.sys. On a 256 GB SSD that's
about 10% so quite a big percentage. I'll take an axe to that,
figuratively speaking...
Paul (03-04-20, 11:33 PM)
Anssi Saari wrote:
[..]
> laptop and noticed there's a 22 GB pagefile.sys. On a 256 GB SSD that's
> about 10% so quite a big percentage. I'll take an axe to that,
> figuratively speaking...


I've generally turned off hibernation here, because worst
case, it could take five minutes for the hibernation to complete.

With hibernation off, that's why the swap or pagefile can be small.

My laptop still has hibernation. But the memory on the laptop
is only 3GB so there's not much potential for mayhem. The
laptop is just a "portable power source" for experiments
and not a mobile computer center.

Paul
bilou (03-05-20, 12:37 PM)
On 04/03/2020 12:40, Soviet_Mario wrote:
[..]
> file, on windows is hit worst than on linux, as disk I/O is more
> performant on linux whatever it is and so it comes closer to "iron"
> limitations, and there is less to squeeze out of it).


Thanks for these useful details.
I must confess that I never use HIBERNATION.
I agree that ,when possible, using a different but fast drive for swap
is better.
It seems also that swapfiles must use contiguous drive space and so can
be difficult to move or resize with usual tools.
Soviet_Mario (03-05-20, 05:18 PM)
On 04/03/20 21:23, Anssi Saari wrote:
[..]
> how hibernation works in Linux, stuff from RAM is pushed to swap and
> then system stops. Or possibly only data pages are pushed to swap since
> code pages can be loaded from binaries.


mmm, I must admit I'd never thought about this, but it seems
very complicated to keep consistent the status beyond a
simple 1:1 copy. The order processes were started (and file
handles, pipes and all assigned to them) seem to me
order-dependent, and likely not to have been saved properly
in useful form.
Processes internal status may depend on each other,
moreover, so the order and timing of start/stop etc of
processes and services and user programs seem to be too much
fragile for that kind of optimizazion.
But I'm far from sure of this : just an opinion !

> Windows is another story. I have a sudden need of disk space on my work
> laptop and noticed there's a 22 GB pagefile.sys.


Minchia ! (= My God) 22 GB swapfile size ? For 4 GB or ram
???? amazing
Also strange usage style maybe
Jack Strangio (03-06-20, 04:02 AM)
Rbwd <something> writes:
> Does Ubuntu/Mint can create SWAP file when setup?
> Or it is better to have SWAP partition instead of file?


Historically, it was advised to put the swap partition on your fastest
hard drive, and roughly in the middle of it, so that seeks would
(generally) be shorter and faster.

The use of a partition rather than a file was to save double-handling of
the data; you could write directly to a point in the partition but
you would need to go through a filesystem to handle writing to a file.

The problem with partitions are that they need to be set up carefully in
regard to size when allocating partitions on the hard drive as it becomes
a pain to adjust sizes later if you have misjudged at the start. A swap
file on the other hand can be enlarged at will at any time. And even
added to if you want two, three, four or more swap files.

With modern SSD drives, even the seek-time problems disappear, so you
can put a swap-file or a swap-partition anywhere you feel like.

When setting up partitions during a distro installation, I always set
up all of the partitions manually first, and then allocate them as
necessary. That's the 'Something Else' option during the Ubuntu/Mint
installation process.

(FWIW, While I'm doing that I always ensure that I have two or even 3
root/system partitions so that I can install a second or third distro
while not destroying my everyday working system.)

Jack

Similar Threads