How to create swap partition in Linux at shell command

You can  use hard disk partition for additional swap space. If u have an additional hard disk, In case if you do not have extra free disk then you can use swap file to increase swap space.
First Check in which partition you want to create swap  using fdisk -l

To create new partition type

#fdisk /dev/sdb

press n  for new -> select the partition type p for Primary -> enter partition number 1 for first partition

-> enter the size like +1GB -> next change the partition id to 82 for swap press t and type 82  . -> next type w to write the partition table . See the below screenshot with red mark for each steps, for more on creating partition click here 



Once you create the partition, Run below command to update partition table or reboot

#partprob

After reboot or running above command  we need to format swap partition. swap volumes are formatted with the mkswap command. and update swap space using swapon  



Next Mount the sawp partition in /ete/fstab files

#vi /etc/fstab

Now verify using free and swapon command



If you want to remove swap you can use swapoff /dev/sdb1

How to create swap partition in Linux at shell command How to create swap partition in Linux at shell command Reviewed by TecGeeks News on November 04, 2017 Rating: 5

No comments:

Get Your Business Online Now


Powered by Blogger.