# htop output after first connecting to the server <figure> <Image src={cover} alt="An abstract visual representing complex networks and swap usage in a server" />
</figure> top - 14:30:00 up 1 day, 1:15, 1 user, load average: 0.50, 0.60, 0.70
Tasks: 200 total, 1 running, 199 sleeping, 0 stopped, 0 zombie
%Cpu(s): 5.0 us, 2.0 sy, 0.0 ni, 93.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 7800 total, 150 free, 6500 used, 1150 buff/cache
MiB Swap: 2048 total, 500 free, 1548 used. 1000 avail Mem # As memory usage reaches 83%, swap usage also starts to increase
top - 14:35:00 up 1 day, 1:20, 1 user, load average: 1.20, 1.00, 0.90
Tasks: 210 total, 2 running, 208 sleeping, 0 stopped, 0 zombie
%Cpu(s): 10.0 us, 5.0 sy, 0.0 ni, 85.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 7800 total, 50 free, 7200 used, 550 buff/cache
MiB Swap: 2048 total, 50 free, 1998 used. 0 avail Mem <-- Swap is almost full!
# htop output after first connecting to the server <figure> <Image src={cover} alt="An abstract visual representing complex networks and swap usage in a server" />
</figure> top - 14:30:00 up 1 day, 1:15, 1 user, load average: 0.50, 0.60, 0.70
Tasks: 200 total, 1 running, 199 sleeping, 0 stopped, 0 zombie
%Cpu(s): 5.0 us, 2.0 sy, 0.0 ni, 93.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 7800 total, 150 free, 6500 used, 1150 buff/cache
MiB Swap: 2048 total, 500 free, 1548 used. 1000 avail Mem # As memory usage reaches 83%, swap usage also starts to increase
top - 14:35:00 up 1 day, 1:20, 1 user, load average: 1.20, 1.00, 0.90
Tasks: 210 total, 2 running, 208 sleeping, 0 stopped, 0 zombie
%Cpu(s): 10.0 us, 5.0 sy, 0.0 ni, 85.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 7800 total, 50 free, 7200 used, 550 buff/cache
MiB Swap: 2048 total, 50 free, 1998 used. 0 avail Mem <-- Swap is almost full!
# htop output after first connecting to the server <figure> <Image src={cover} alt="An abstract visual representing complex networks and swap usage in a server" />
</figure> top - 14:30:00 up 1 day, 1:15, 1 user, load average: 0.50, 0.60, 0.70
Tasks: 200 total, 1 running, 199 sleeping, 0 stopped, 0 zombie
%Cpu(s): 5.0 us, 2.0 sy, 0.0 ni, 93.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 7800 total, 150 free, 6500 used, 1150 buff/cache
MiB Swap: 2048 total, 500 free, 1548 used. 1000 avail Mem # As memory usage reaches 83%, swap usage also starts to increase
top - 14:35:00 up 1 day, 1:20, 1 user, load average: 1.20, 1.00, 0.90
Tasks: 210 total, 2 running, 208 sleeping, 0 stopped, 0 zombie
%Cpu(s): 10.0 us, 5.0 sy, 0.0 ni, 85.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 7800 total, 50 free, 7200 used, 550 buff/cache
MiB Swap: 2048 total, 50 free, 1998 used. 0 avail Mem <-- Swap is almost full!
# Let's create a new 4 GB swap file
-weight: 600;">sudo fallocate -l 4G /swapfile2
# Or with dd:
# -weight: 600;">sudo dd if=/dev/zero of=/swapfile2 bs=1M count=4096
# Let's create a new 4 GB swap file
-weight: 600;">sudo fallocate -l 4G /swapfile2
# Or with dd:
# -weight: 600;">sudo dd if=/dev/zero of=/swapfile2 bs=1M count=4096
-weight: 600;">sudo chmod 600 /swapfile2
-weight: 600;">sudo chmod 600 /swapfile2
-weight: 600;">sudo mkswap /swapfile2
-weight: 600;">sudo mkswap /swapfile2
-weight: 600;">sudo swapon /swapfile2
-weight: 600;">sudo swapon /swapfile2
echo '/swapfile2 none swap sw 0 0' | -weight: 600;">sudo tee -a /etc/fstab
echo '/swapfile2 none swap sw 0 0' | -weight: 600;">sudo tee -a /etc/fstab
# Status after increasing swap space
free -h total used free shared buff/cache available
Mem: 7.6G 7.2G 50Mi 100Mi 550Mi 100Mi
Swap: 6.0G 1.5G 4.5G # Lowering swappiness to 10
-weight: 600;">sudo sysctl vm.swappiness=10
# Making the change permanent
echo 'vm.swappiness = 10' | -weight: 600;">sudo tee -a /etc/sysctl.conf
# Status after increasing swap space
free -h total used free shared buff/cache available
Mem: 7.6G 7.2G 50Mi 100Mi 550Mi 100Mi
Swap: 6.0G 1.5G 4.5G # Lowering swappiness to 10
-weight: 600;">sudo sysctl vm.swappiness=10
# Making the change permanent
echo 'vm.swappiness = 10' | -weight: 600;">sudo tee -a /etc/sysctl.conf
# Status after increasing swap space
free -h total used free shared buff/cache available
Mem: 7.6G 7.2G 50Mi 100Mi 550Mi 100Mi
Swap: 6.0G 1.5G 4.5G # Lowering swappiness to 10
-weight: 600;">sudo sysctl vm.swappiness=10
# Making the change permanent
echo 'vm.swappiness = 10' | -weight: 600;">sudo tee -a /etc/sysctl.conf - Create Swap File: Allocate space for the swap file using fallocate or dd. # Let's create a new 4 GB swap file
-weight: 600;">sudo fallocate -l 4G /swapfile2
# Or with dd:
# -weight: 600;">sudo dd if=/dev/zero of=/swapfile2 bs=1M count=4096
- Set File Permissions: Ensure only the root user can access the swap file. -weight: 600;">sudo chmod 600 /swapfile2
- Format as Swap Area: Mark the created file as a swap area. -weight: 600;">sudo mkswap /swapfile2
- Activate Swap: Add the new swap file to the system. -weight: 600;">sudo swapon /swapfile2
- Make Permanent: Add it to the /etc/fstab file so the swap file is automatically activated on system reboot. echo '/swapfile2 none swap sw 0 0' | -weight: 600;">sudo tee -a /etc/fstab