Creating a Swap File
Step 1: Determine the size of the new swap file in megabytes and multiply by 1024 to determine the number of blocks. For example, the block size of a 1024MB/1GB swap file is 1048576.
Step 2: At a shell prompt as root, type the following command with count
being equal to the desired block size: dd if=/dev/zero of=/swapfile bs=1024 count=1048576
Step 3: Setup the swap file with the command: mkswap /swapfile
Step 4: To enable the swap file immediately but not automatically at boot time: swapon /swapfile
Step 5: To enable it at boot time, edit /etc/fstab
by nano
or vi
to include the following entry: /swapfile swap swap defaults 0 0
The next time the system boots, it enables the new swap file.
Removing a Swap File
Step 1: At a shell prompt as root, execute the following command to disable the swap file (where /swapfile is the swap file): swapoff -v /swapfile
Step 2: Remove its entry from the /etc/fstab
file by nano
or vi
.
Step 3: Remove the actual file rm /swapfile
'OS > Linux' 카테고리의 다른 글
리눅스 패키지 관리 Package Management Basics: apt, yum, dnf, pkg (0) | 2021.03.28 |
---|---|
Unix 및 Linux 쉘 스크립트에서 날짜 계산 방법 (0) | 2021.03.24 |
Allow users to run any commands anywhere without their password (0) | 2021.03.24 |
부하 테스트를 위한 stress 툴 (0) | 2021.03.24 |
RHEL7에서 THP(Transparent Huge Pages) 기능 설정 여부 확인 및 해제 방법 (0) | 2021.03.23 |