HOW TO CREATE and REMOVE Swap FILE IN LINUX

In this post  we are gonna learn how to make OR remove swap file in linux step by step:

  • Create a file
[root@localhost ~]# touch a.txt
  • Now with with help of disk dumping we will give this file a size .
  • Like i’m giving it 1000MB.
[root@localhost ~]# dd if=/dev/zero of=a.txt bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes (1.0 GB) copied, 7.66024 seconds, 137 MB/s
  • We have to format a.txt before making use of it .
[root@localhost ~]# mkswap a.txt
Setting up swapspace version 1, size = 1048571 kB
  • Activate swap on this file .by swapon filename
[root@localhost ~]# swapon a.txt
  • Check your file is been created or not by cat /proc/swaps command .
[root@localhost ~]# cat /proc/swaps
Filename                                Type            Size    Used    Priority
/dev/sda2                               partition       5116692 0       -1
/root/a.txt                             file            1023992 0       -2

To make it permanent

[root@localhost ~]# vim  /etc/fstab

In this make entry as

/root/file           swaps      swpas      default     0  0

:wq    (save and quiet)

NOW IF YOU WANT TO DELETE 

  • First deactivate the swap file
[root@localhost ~]# swapoff a.txt
  • Now simply delete swap file .
[root@localhost ~]# rm -rf a.txt

TO DELETE SWAP PARTITION IN LINUX

HOW TO CREATE A SWAP PARTITIONS IN LINUX

CHECK OUT MY VIDEO

2 thoughts on “HOW TO CREATE and REMOVE Swap FILE IN LINUX

  1. My partner and I stumbled over here different page and thought I might
    check things out. I like what I see so i am just following you.
    Look forward to going over your web page again.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s