Create Swap File on Linux
Step 1
Create Storage File
Type the following command to create 512MB swap file (1024 * 512MB = 524288 block size):
# dd if=/dev/zero of=/swapfile1 bs=1024 count=524288
Where,
if=/dev/zero : Read from /dev/zero file. /dev/zero is a special file in that provides as many null characters to build storage file called /swapfile1.
of=/swapfile1 : Read from /dev/zero write stoage file to /swapfile1.
bs=1024 : Read and write 1024 BYTES bytes at a time.
count=524288 : Copy only 523288 BLOCKS input blocks.
Step 2
Set Up a Linux Swap Area
# mkswap /swapfile1
# chown root:root /swapfile1
# chmod 0600 /swapfile1
# swapon /swapfile1
Step 3
Activate Swap in fstab
vi /etc/fstab
/swapfile1 swap swap defaults 0 0
Step 4
Boot the system
$ free -m
Step 1
Create Storage File
Type the following command to create 512MB swap file (1024 * 512MB = 524288 block size):
# dd if=/dev/zero of=/swapfile1 bs=1024 count=524288
Where,
if=/dev/zero : Read from /dev/zero file. /dev/zero is a special file in that provides as many null characters to build storage file called /swapfile1.
of=/swapfile1 : Read from /dev/zero write stoage file to /swapfile1.
bs=1024 : Read and write 1024 BYTES bytes at a time.
count=524288 : Copy only 523288 BLOCKS input blocks.
Step 2
Set Up a Linux Swap Area
# mkswap /swapfile1
# chown root:root /swapfile1
# chmod 0600 /swapfile1
# swapon /swapfile1
Step 3
Activate Swap in fstab
vi /etc/fstab
/swapfile1 swap swap defaults 0 0
Step 4
Boot the system
$ free -m
No comments:
Post a Comment