Swapon: Unterschied zwischen den Versionen
| Zeile 41: | Zeile 41: | ||
=== Problembehebung === | === Problembehebung === | ||
==== swap file appears to have holes ==== | |||
'''steps to remediate this | ; 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. | 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: | 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 | 5322571776 bytes (5.3 GB, 5.0 GiB) copied, 6 s, 887 MB/s | ||
5120+0 records in | 5120+0 records in | ||
5120+0 records out | 5120+0 records out | ||
5368709120 bytes (5.4 GB, 5.0 GiB) copied, 6.08009 s, 883 MB/s | 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. | check the file type being displayed now. it’s just a data file. | ||
root@host:~# '''file /swap-file-00''' | |||
/swap-file-00: data | /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: | 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: | change the permissions on it: | ||
root@host:~# chmod 600 /swap-file-00 | |||
make the new file as swap file: | make the new file as swap file: | ||
root@host:~# '''mkswap /swap-file-00''' | |||
Setting up swapspace version 1, size = 5 GiB (5368705024 bytes) | Setting up swapspace version 1, size = 5 GiB (5368705024 bytes) | ||
no label, UUID=738f253b-aed0-46ac-bc50-b4d1fe2d1702 | no label, UUID=738f253b-aed0-46ac-bc50-b4d1fe2d1702 | ||
check the file type being displayed now. it’s a swap file. | 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 | /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 | turn on the swap, as usual | ||
root@host:~# '''swapon /swap-file-00''' | |||
check if it is being used as a swap file | check if it is being used as a swap file | ||
root@host:~# '''swapon --show''' | |||
NAME TYPE SIZE USED PRIO | NAME TYPE SIZE USED PRIO | ||
/swap-file-00 file 5G 0B -2 | /swap-file-00 file 5G 0B -2 | ||
== Konfiguration == | == Konfiguration == | ||
Version vom 28. April 2026, 14:55 Uhr
swapon - Beschreibung
Beschreibung
Installation
Aufruf
Optionen
| Unix | GNU | Parameter | Beschreibung |
|---|---|---|---|
Parameter
Umgebungsvariablen
Exit-Status
| Wert | Beschreibung |
|---|---|
| 0 | Erfolg |
| >0 | Fehler |
Anwendung
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