ใครที่ติดตั้งลีนุกซ์ไปแล้ว แต่พาร์ติชัน swap ไว้น้อย อยากได้เพิ่มไม่ยากครับ
ผมขออนุญาต copy paste เอาไว้ในนี้เผื่อไว้ใช้นะครับ
Procedure to add a swap file
You need to use dd command to create swapfile. Next you need to use mkswap command to set up a Linux swap area on a device or in a file.
a) Login as the root user
b) Type following command to create 512MB swap file (1024 * 512MB = 524288 block size):
HungryHacker@localhost:~$ dd if=/dev/zero of=/swapfile1 bs=1024 count=524288
c) Set up a Linux swap area:
HungryHacker@localhost:~$ mkswap /swapfile1
d) Activate /swapfile1 swap space immediately:
HungryHacker@localhost:~$ swapon /swapfile1
e) To activate /swapfile1 after Linux system reboot, add entry to /etc/fstab file. Open this file using text editor such as vi:
HungryHacker@localhost:~$ vi /etc/fstab
Append following line to the above file:
/swapfile1 swap swap defaults 0 0
So next time Linux comes up after reboot, it enables the new swap file for you automatically.
g) How do I verify swap is activated or not?
Simply use free command:
HungryHacker@localhost:~$ free -mProcedure to add a swap file
You need to use dd command to create swapfile. Next you need to use mkswap command to set up a Linux swap area on a device or in a file.
a) Login as the root user
b) Type following command to create 512MB swap file (1024 * 512MB = 524288 block size):
HungryHacker@localhost:~$ dd if=/dev/zero of=/swapfile1 bs=1024 count=524288
c) Set up a Linux swap area:
HungryHacker@localhost:~$ mkswap /swapfile1
d) Activate /swapfile1 swap space immediately:
HungryHacker@localhost:~$ swapon /swapfile1
e) To activate /swapfile1 after Linux system reboot, add entry to /etc/fstab file. Open this file using text editor such as vi:
HungryHacker@localhost:~$ vi /etc/fstab
Append following line to the above file:
/swapfile1 swap swap defaults 0 0
So next time Linux comes up after reboot, it enables the new swap file for you automatically.
g) How do I verify swap is activated or not?
Simply use free command:
HungryHacker@localhost:~$ free -m
ที่มา : http://www.linuxadda.com/2009/04/increase-swap-memory-in-llinux.html
- sothorn's blog
- อ่าน 1696 ครั้ง

สงสัยเรื่อง swap ค่ะ
พาร์ติชัน swap สำคัญต่อ linux ยังไงหรอค่ะ
แล้วมีไว้ทำอะไรบ้างค่ะ
แล้วถ้าเราลง linuxแต่ไม่ได้ลง swap จะมีปัญหาอะไรหรือป่าว
ถ้ามี เช่น อะไรบ้างค่ะ
ขอบคุณค่ะ
swap
swap ก็คือการนำพื้นที่ฮาร์ดดิสก์มาจำลอง เพื่อใช้แทนหน่วยความจำหลัก ซึ่งอย่างใน windows ก็จะมี virtual memory เหมือนกัน การทำงานก็เหมือน swap ล่ะครับ
หลักการอาจจะไม่ละเอียดนะครับ ต้องขออภัยด้วยครับ