Just created a swap-file on the notebook .. will be persistent hopefully

hi there good evening

just created a swap-file on command line - like so


[martin@x220 ~]$ swapon -s
Dateiname                               Typ             Größe           Benutzt         Priorität
/dev/sda2                               partition       8555336         1425928         -2
[martin@x220 ~]$ ^[[200~sudo fallocate -l 1G /swapfile~
bash: $'\E[200~sudo': Kommando nicht gefunden.
[martin@x220 ~]$ sudo fallocate -l 1G /swapfile
[sudo] Passwort für martin: 
[martin@x220 ~]$ sudo fallocate -l 1G /swapfile
[martin@x220 ~]$ sudo dd if=/dev/zero of=/swapfile bs=1024 count=1048576
1048576+0 Datensätze ein
1048576+0 Datensätze aus
1073741824 Byte (1,1 GB, 1,0 GiB) kopiert, 15,6564 s, 68,6 MB/s
[martin@x220 ~]$ sudo chmod 600 /swapfile
[martin@x220 ~]$ sudo mkswap /swapfile
Auslagerungsbereich Version 1 wird angelegt, Größe = 1024 MiB (1073737728 Bytes)
keine Bezeichnung, UUID=8fe303c8-1291-403c-bf2f-1f561dd24edb
[martin@x220 ~]$ sudo swapon /swapfile
[martin@x220 ~]$ sudo swapon --show
NAME      TYPE       SIZE USED PRIO
/dev/sda2 partition  8,2G 2,5G   -2
/swapfile file      1024M   0B   -3
[martin@x220 ~]$

guess that this is permanent - and will be so if i switch off the notebook and afterwards swith it on agian.

Indeed. swap-files are persistent, they need to be mentioned in fstab, though, as far as I know.

I used [1] as a source of info about swap, and the different sorts there are.
At 3.1 Swap file creation they seem to describe different commands than the commands you seem to have used.

mkswap -U clear --size 4G --file /swapfile
swapon /swapfile

And in /etc/fstab:

/swapfile none swap defaults 0 0

[1] https://wiki.archlinux.org/title/Swap

How much RAM do you have? I tried using a SWAP partition the last time I reinstalled on my other computers and I didn’t notice any difference. In fact, the SWAP partition hardly got used, so I deleted it. I have 16GB of RAM on all of my systems.

good evening dear SemLraug - hello oldthinker :smiley:

first of all : many thanks for the quick reply. great to hear from you . - i need a swapfile - since i am on a Thinkpad X220 with only 4 gigs

thanks for the hint here: dear SemLraug

[quote=“SemLraug, post:2, topic:73000”]

mkswap -U clear --size 4G --file /swapfile
swapon /swapfile

nd in /etc/fstab:

/swapfile none swap defaults 0 0

[1] https://wiki.archlinux.org/title/Swap

thank you so much.

at the evening i am trying to test the behavior of the notebook

greetings :upside_down_face:

OK, yeah you need a SWAP file. Can the RAM be upgraded or is 4GB its max?

The question if swap is at all necessary always pops up as soon as someone mentions ‘swap’. :upside_down_face:

When i read [1] i decided from that moment to always create swap.

The next questions always is, which kind of swap.
Example [2] here in these forums. Many other discussions are easily found here and elsewhere.

[1] https://chrisdown.name/2018/01/02/in-defence-of-swap.html
[2] Zram vs swap partition vs swapfile

hi there - it can be upgreaded - in thinkpad t420 its possible and also in t 520 - i own both of them and love it for its robustness.

@SemLraug & @oldthinker

so if i got you right: swap-files are persistent, they need to be mentioned in fstab,

the process of creation the swap-file does not include and editing of the fstap?

Do:

sudo nano /etc/fstab

To check.

(Perhaps you prefer a different editor to nano, then you can use that one of course.)

good day - well hmm - perhaps ill have to edit like so:

https://askubuntu.com/questions/126018/adding-a-new-swap-file-how-to-edit-fstab-to-enable-swap-after-reboot


Insert the following line in /etc/fstab for swap from the next boot:

/var/cache/swap/myswap    none    swap    sw    0   0

well what do you suggest

btw: should i take 2 gigs in the swap configuration!?

From endeavouros wiki. I recommend that you follow the arch instructions

https://discovery.endeavouros.com/storage-and-partitions/adding-swap-after-installation/2021/03/

Edit the fstab configuration to add an entry for the swap file:

/etc/fstab

/swapfile none swap defaults 0 0

Note: The swap file must be specified by its location on the file system, not by its UUID or LABEL.