{{tag>Brouillon}} = Notes swap mémoire Voir : * https://chrisdown.name/2018/01/02/in-defence-of-swap.html * https://kubernetes.io/blog/2025/03/25/swap-linux-improvements/ Voir aussi : * [[Swap sur ramdisk]] systemctl --type swap cat /proc/swaps cat /proc/vmstat echo 0 > /proc/sys/vm/swappiness # cat /proc/sys/vm/vfs_cache_pressure # sysctl -w vm.vfs_cache_pressure=50 # Allocate storage and restrict access fallocate --length 4GiB /swapfile chmod 600 /swapfile # Format the swap space mkswap /swapfile # Activate the swap space for paging swapon /swapfile == Analyse consommation Consommation de la SWAP par utilisateur smem -u -s swap Consommation de la SWAP par process smem -s swap ou echo -e "SWAP_KB\tPPID\tPID\tEXE" for S_FILE in /proc/[0-9]*/ ; do S_PPID="$(awk '/^PPid:/ { print $2}' ${S_FILE}/status)" ; S_PID="$(echo ${S_FILE}/status | cut -d'/' -f3)" ; S_EXE="$(readlink $S_FILE/exe)" ; S_SWAPKB="$(awk '/VmSwap/ { print $2}' ${S_FILE}/status)" ; [ ! -z $S_SWAPKB ] && echo -e "$S_SWAPKB\t${S_PPID}\t${S_PID}\t${S_EXE}" ; done | sort -n == dphys-swapfile dphys-swapfile swapoff == Recommandations SWAP === Prereq Oracle | **RAM** | **Swap Space** | | Between 1 GB and 2 GB | 1.5 times the size of the RAM | | Between 2 GB and 16 GB | Equal to the size of the RAM | | More than 16 GB | 16GB | | **RAM** | **Swap Space** | | Between 8 GB and 16 GB | Equal to the size of the RAM | | More than 16 GB | 16GB | === Recommandations RedHat Source : https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/managing_storage_devices/getting-started-with-swap_managing-storage-devices | **Amount of RAM in the system** | **Recommended swap space** |**Recommended swap space if allowing for hibernation** | | ⩽ 2 GB | 2 times the amount of RAM | 3 times the amount of RAM | | > 2 GB – 8 GB | Equal to the amount of RAM | 2 times the amount of RAM | | > 8 GB – 64 GB | At least 4 GB | 1.5 times the amount of RAM | | > 64 GB | At least 4 GB | Hibernation not recommended |