Introduction-אינרודאקטיון
Swap הוא מקום בדיסק המשמש כאשר כמות זיכרון ה-RAM הפיזי מלאה. כאשר מערכת לינוקס אוזל זיכרון ה-RAM, דפים לא פעילים מועברים מ-RAM למרחב ההחלפה.
שטח החלפה יכול ללבוש צורה של מחיצת החלפה ייעודית או של קובץ החלפה. ברוב המקרים, כאשר מריצים לינוקס על מחשב וירטואלי, מחיצת החלפה אינה קיימת, כך שהאפשרות היחידה היא ליצור קובץ החלפה.
מדריך זה נבדק באמזון לינוקס 2.
במאמר זה אנו הולכים ליצור swapfile במחשב אמזון לינוקס 2.
Swap is a space on a disk that is used when the amount of physical RAM memory is full. When a Linux system runs out of RAM, inactive pages are moved from the RAM to the swap space.
Swap space can take the form of either a dedicated swap partition or a swap file. In most cases, when running Linux on a virtual machine, a swap partition is not present, so the only option is to create a swap file.
This tutorial was tested in amazon linux 2.
In this article we are going to create swapfile in amazon linux 2 machine.
Bash Script to create swap
#!/bin/bash
sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo /swapfile swap swap defaults 0 0 >> /etc/fstab
cat /etc/fstab
free -m
#!/bin/bash
sudo swapoff -v /swapfile
sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo /swapfile swap swap defaults 0 0 >> /etc/fstab
cat /etc/fstab
free -m
Bash Script to remove swap
#!/bin/bash
sudo swapoff -v /swapfile
sed '/\/swapfile swap swap defaults 0 0/d' ./infile
sudo rm /swapfile
No comments:
Post a Comment