Swapon: Unterschied zwischen den Versionen
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
| Zeile 5: | Zeile 5: | ||
== Installation == | == Installation == | ||
<syntaxhighlight lang="bash" highlight="1" line copy> | <syntaxhighlight lang="bash" highlight="1" line copy> | ||
< /syntaxhighlight> | </syntaxhighlight> | ||
== Aufruf == | == Aufruf == | ||
<syntaxhighlight lang="bash" highlight="1" line copy> | <syntaxhighlight lang="bash" highlight="1" line copy> | ||
< /syntaxhighlight> | </syntaxhighlight> | ||
=== Optionen === | === Optionen === | ||
| Zeile 34: | Zeile 34: | ||
== Anwendung == | == Anwendung == | ||
<syntaxhighlight lang="bash" highlight="1" line copy> | <syntaxhighlight lang="bash" highlight="1" line copy> | ||
< /syntaxhighlight> | </syntaxhighlight> | ||
<!-- output --> | <!-- output --> | ||
| Zeile 41: | Zeile 41: | ||
=== Problembehebung === | === Problembehebung === | ||
; swap file appears to have holes | |||
; | |||
'''error message''' – | |||
<code>root@host:~# '''swapon /swap-file-00''' | |||
swapon: /swap-file-00: skipping - it appears to have holes.</code> | |||
'''solution''' – you need to zero-fill the file you are using as swap | |||
'''steps to remediate this –''' | |||
first of all, remove the existing file with the holes. | |||
<code>root@host:~# '''rm /swap-file-00'''</code> | |||
create the new swap file using the following command: | |||
<code>root@host:~# '''dd if=/dev/zero of=/swap-file-00 bs=1M count=5120 status=progress''' | |||
5322571776 bytes (5.3 GB, 5.0 GiB) copied, 6 s, 887 MB/s | |||
5120+0 records in | |||
5120+0 records out | |||
5368709120 bytes (5.4 GB, 5.0 GiB) copied, 6.08009 s, 883 MB/s</code> | |||
check the file type being displayed now. it’s just a data file. | |||
<code>root@host:~# '''file /swap-file-00''' | |||
/swap-file-00: data</code> | |||
if your system says something like the following, it just means that the ''file'' command is not installed on your system. you may either ignore the ''file'' commands in the further steps since they are not required in getting a swap file operational on your system. they are being used to verify the file contents based on their magic numbers. or you may chose to install the ''file'' command using the package manager on your gnu/linux, say ''apt -y install file'' on a debian/ubuntu: | |||
<code>file: command not found</code> | |||
change the permissions on it: | |||
<code>root@host:~# chmod 600 /swap-file-00</code> | |||
make the new file as swap file: | |||
<code>root@host:~# '''mkswap /swap-file-00''' | |||
Setting up swapspace version 1, size = 5 GiB (5368705024 bytes) | |||
no label, UUID=738f253b-aed0-46ac-bc50-b4d1fe2d1702</code> | |||
check the file type being displayed now. it’s a swap file. | |||
<code>root@host:~# '''file /swap-file-00''' | |||
/swap-file-00: Linux/i386 swap file (new style), version 1 (4K pages), size 1310719 pages, no label, UUID=738f253b-aed0-46ac-bc50-b4d1fe2d1702</code> | |||
turn on the swap, as usual | |||
<code>root@host:~# '''swapon /swap-file-00'''</code> | |||
check if it is being used as a swap file | |||
<code>root@host:~# '''swapon --show''' | |||
NAME TYPE SIZE USED PRIO | |||
/swap-file-00 file 5G 0B -2</code> | |||
== Konfiguration == | == Konfiguration == | ||
=== Dateien === | === Dateien === | ||
| Zeile 83: | Zeile 119: | ||
</noinclude> | </noinclude> | ||
Version vom 28. April 2026, 14:09 Uhr
Swapon - Beschreibung
Beschreibung
Installation
Aufruf
Optionen
| Unix | GNU | Parameter | Beschreibung |
|---|---|---|---|
Parameter
Umgebungsvariablen
Exit-Status
| Wert | Beschreibung |
|---|---|
| 0 | Erfolg |
| >0 | Fehler |
Anwendung
<syntaxhighlight lang="bash" highlight="" line> < /syntaxhighlight>
Problembehebung
- swap file appears to have holes
error message –
root@host:~# swapon /swap-file-00
swapon: /swap-file-00: skipping - it appears to have holes.
solution – you need to zero-fill the file you are using as swap
steps to remediate this –
first of all, remove the existing file with the holes.
root@host:~# rm /swap-file-00
create the new swap file using the following command:
root@host:~# dd if=/dev/zero of=/swap-file-00 bs=1M count=5120 status=progress
5322571776 bytes (5.3 GB, 5.0 GiB) copied, 6 s, 887 MB/s
5120+0 records in
5120+0 records out
5368709120 bytes (5.4 GB, 5.0 GiB) copied, 6.08009 s, 883 MB/s
check the file type being displayed now. it’s just a data file.
root@host:~# file /swap-file-00
/swap-file-00: data
if your system says something like the following, it just means that the file command is not installed on your system. you may either ignore the file commands in the further steps since they are not required in getting a swap file operational on your system. they are being used to verify the file contents based on their magic numbers. or you may chose to install the file command using the package manager on your gnu/linux, say apt -y install file on a debian/ubuntu:
file: command not found
change the permissions on it:
root@host:~# chmod 600 /swap-file-00
make the new file as swap file:
root@host:~# mkswap /swap-file-00
Setting up swapspace version 1, size = 5 GiB (5368705024 bytes)
no label, UUID=738f253b-aed0-46ac-bc50-b4d1fe2d1702
check the file type being displayed now. it’s a swap file.
root@host:~# file /swap-file-00
/swap-file-00: Linux/i386 swap file (new style), version 1 (4K pages), size 1310719 pages, no label, UUID=738f253b-aed0-46ac-bc50-b4d1fe2d1702
turn on the swap, as usual
root@host:~# swapon /swap-file-00
check if it is being used as a swap file
root@host:~# swapon --show
NAME TYPE SIZE USED PRIO
/swap-file-00 file 5G 0B -2
Konfiguration
Dateien
| Datei | Beschreibung |
|---|---|
Anhang
Siehe auch
Dokumentation
Links
Projekt
Weblinks