<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>technology Archives - Linux Windows and android Tutorials</title>
	<atom:link href="https://www.osradar.com/tag/technology/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.osradar.com</link>
	<description>tutorials and news and Seurity</description>
	<lastBuildDate>Wed, 28 Apr 2021 07:52:32 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.8.13</generator>
	<item>
		<title>How to Create SWAP in Centos</title>
		<link>https://www.osradar.com/how-to-create-swap-in-centos/</link>
					<comments>https://www.osradar.com/how-to-create-swap-in-centos/#respond</comments>
		
		<dc:creator><![CDATA[Muhammad Nabeel]]></dc:creator>
		<pubDate>Thu, 17 Jan 2019 08:30:30 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[technology]]></category>
		<guid isPermaLink="false">https://www.osradar.com/?p=9367</guid>

					<description><![CDATA[<p>Most Linux installations recommend that you include a SWAP partition. Swap partition is the second type of memory in Linux systems. The primary function of swap is to use disk space for RAM memory when real RAM fills up and more space is needed. In this article, you will learn that how to create swap. [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.osradar.com/how-to-create-swap-in-centos/">How to Create SWAP in Centos</a> appeared first on <a rel="nofollow" href="https://www.osradar.com">Linux  Windows and android  Tutorials</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Most Linux installations recommend that you include a SWAP partition. Swap partition is the second type of memory in Linux systems. The primary function of swap is to use disk space for RAM memory when real RAM fills up and more space is needed.</p>
<p>In this article, you will learn that how to create swap. There are three types of swap that will be covered in this article respectively.</p>
<ul>
<li><strong>Standard SWAP</strong></li>
<li><strong>LVM SWAP</strong></li>
<li><strong>SWAP File</strong></li>
</ul>
<h1 style="text-align: center;"><strong>Create Standard SWAP</strong></h1>
<p>Command to see available RAM and SWAP stats</p>
<pre class="lang:sh decode:true "># free -h

# swapon -s

</pre>
<p><img loading="lazy" class="alignnone wp-image-9375" src="https://www.osradar.com/wp-content/uploads/2019/01/1-3-300x84.jpg" alt="" width="686" height="192" srcset="https://www.osradar.com/wp-content/uploads/2019/01/1-3-300x84.jpg 300w, https://www.osradar.com/wp-content/uploads/2019/01/1-3-768x216.jpg 768w, https://www.osradar.com/wp-content/uploads/2019/01/1-3.jpg 810w" sizes="(max-width: 686px) 100vw, 686px" /></p>
<h3><strong>Step 1: Follow below instructions</strong></h3>
<ul>
<li>List partition table using below command<strong><br />
</strong></p>
<pre class="lang:sh decode:true"># fdisk -l</pre>
</li>
<li>Choose desired hard disk for swap partition List partition table using below command
<pre class="lang:sh decode:true "># fdisk /dev/sdb</pre>
</li>
<li>Press <strong>m</strong> for help</li>
<li>Press <strong>p</strong> to print partition table</li>
<li>Press <strong>n</strong> to create new partition</li>
<li>Press <strong>p</strong> to make primary partition.</li>
<li>Press <strong>1</strong> to create first partition on selected disk.<br />
There are 1-4 partition number. We can type any one number from them.</li>
<li>Press <strong>ente</strong>r to leave first cylinder as default</li>
<li>Now assign space to partition. Use + to assign space e.g.<br />
<strong>+1G</strong> and press enter.</li>
<li>Press <strong>p</strong> to print partition table.</li>
<li>Now set SWAP file system ID on partition.</li>
<li>Press <strong>l</strong> to list all available file system volumes. We will set <strong>SWAP (82)</strong></li>
<li>Press <strong>t</strong> to set file system on partition</li>
<li>Press <strong>1</strong> to select partition. It is the partition on which we set SWAP file system.</li>
<li>type <strong>82</strong> and press enter to set LVM ID on selected partition.</li>
<li>Press <strong>w</strong> to write/save partition.</li>
</ul>
<p>Now run command to make changes in partition table using below command</p>
<pre class="lang:sh decode:true "># partprobe</pre>
<h3><strong>Step 2: Format Partition (File System)</strong></h3>
<pre class="lang:sh decode:true "># mkswap   /dev/sdb1</pre>
<p><img loading="lazy" class="alignnone wp-image-9378" src="https://www.osradar.com/wp-content/uploads/2019/01/2-2-300x61.jpg" alt="" width="689" height="140" srcset="https://www.osradar.com/wp-content/uploads/2019/01/2-2-300x61.jpg 300w, https://www.osradar.com/wp-content/uploads/2019/01/2-2-768x157.jpg 768w, https://www.osradar.com/wp-content/uploads/2019/01/2-2.jpg 839w" sizes="(max-width: 689px) 100vw, 689px" /></p>
<h3><strong>Step 3: Set Partition Label</strong></h3>
<p>Command to set Label on SWAP Partition<br />
<strong>Syntax:</strong>  mkswap   -L   Label-name    /dev/partition</p>
<pre class="lang:sh decode:true "># mkswap   -L   myswap    /dev/sdb1</pre>
<p><img loading="lazy" class="alignnone wp-image-9379" src="https://www.osradar.com/wp-content/uploads/2019/01/3-1-300x72.jpg" alt="" width="692" height="166" srcset="https://www.osradar.com/wp-content/uploads/2019/01/3-1-300x72.jpg 300w, https://www.osradar.com/wp-content/uploads/2019/01/3-1-768x183.jpg 768w, https://www.osradar.com/wp-content/uploads/2019/01/3-1.jpg 838w" sizes="(max-width: 692px) 100vw, 692px" /></p>
<h3><strong>Step 4: Now Mount partition in /etc/fstab File</strong></h3>
<pre class="lang:sh decode:true"># vim /etc/fstab</pre>
<p>and add following entry:</p>
<p><span style="color: #008000;">LABEL=myswap           swap    swap    deafults    0     0</span></p>
<p>write changes to /etc/fstab and quite</p>
<p><img loading="lazy" class="alignnone wp-image-9380" src="https://www.osradar.com/wp-content/uploads/2019/01/4-300x104.jpg" alt="" width="689" height="239" srcset="https://www.osradar.com/wp-content/uploads/2019/01/4-300x104.jpg 300w, https://www.osradar.com/wp-content/uploads/2019/01/4-768x266.jpg 768w, https://www.osradar.com/wp-content/uploads/2019/01/4.jpg 908w" sizes="(max-width: 689px) 100vw, 689px" /></p>
<h3><strong>Step 5: Now Activate Created SWAP<br />
</strong></h3>
<pre class="lang:sh decode:true"># swapoff  -a              (Disable all swap)

# swapon  -a               (enable all swap)

# swapon  -s               (list enabled all swap)

# free   -m</pre>
<p><img loading="lazy" class="alignnone wp-image-9381" src="https://www.osradar.com/wp-content/uploads/2019/01/5-1-300x88.jpg" alt="" width="689" height="202" srcset="https://www.osradar.com/wp-content/uploads/2019/01/5-1-300x88.jpg 300w, https://www.osradar.com/wp-content/uploads/2019/01/5-1-768x224.jpg 768w, https://www.osradar.com/wp-content/uploads/2019/01/5-1.jpg 867w" sizes="(max-width: 689px) 100vw, 689px" /></p>
<p>You have created a standard swap successfully!</p>
<hr />
<h1 style="text-align: center;"><strong>LVM SWAP</strong></h1>
<h3><strong>Step 1: </strong>Follow the Previous procedure</h3>
<h3><strong>Step 2: </strong>Follow the Previous procedure</h3>
<h3><strong>Step 3: Create PV (Physical Volume) of the partition</strong></h3>
<p>Use below command</p>
<pre class="lang:sh decode:true ">#pvcreate   /dev/sdb1

#pvs
</pre>
<p><img loading="lazy" class="alignnone wp-image-9408" src="https://www.osradar.com/wp-content/uploads/2019/01/1-4-300x69.jpg" alt="" width="687" height="158" srcset="https://www.osradar.com/wp-content/uploads/2019/01/1-4-300x69.jpg 300w, https://www.osradar.com/wp-content/uploads/2019/01/1-4-768x176.jpg 768w, https://www.osradar.com/wp-content/uploads/2019/01/1-4.jpg 913w" sizes="(max-width: 687px) 100vw, 687px" /></p>
<h3><strong>Step 4: Create VG (Volume Group)</strong></h3>
<pre class="lang:sh decode:true">#vgcreate   swap_vg    /dev/sdb1

#vgs</pre>
<p><strong>Note:</strong> <span style="color: #ff0000;">swap_vg</span> is vg name you can use any</p>
<p><img loading="lazy" class="alignnone wp-image-9409" src="https://www.osradar.com/wp-content/uploads/2019/01/2-3-300x69.jpg" alt="" width="687" height="158" srcset="https://www.osradar.com/wp-content/uploads/2019/01/2-3-300x69.jpg 300w, https://www.osradar.com/wp-content/uploads/2019/01/2-3-768x177.jpg 768w, https://www.osradar.com/wp-content/uploads/2019/01/2-3.jpg 868w" sizes="(max-width: 687px) 100vw, 687px" /></p>
<h3><strong>Step 5: Create LVM (Logical Volum Manager)</strong></h3>
<p>Use below command</p>
<pre class="lang:sh decode:true"># lvcreate   -l   100%free   -n    swap_lvm   swap_vg
# lvs</pre>
<p><span style="color: #ff0000;">swap_lvm</span>   is the LVM Name. you can use any.</p>
<p><span style="color: #ff0000;">swap_vg</span>     is the name of created VG</p>
<p><img loading="lazy" class="alignnone wp-image-9410" src="https://www.osradar.com/wp-content/uploads/2019/01/3-3-300x72.jpg" alt="" width="692" height="166" srcset="https://www.osradar.com/wp-content/uploads/2019/01/3-3-300x72.jpg 300w, https://www.osradar.com/wp-content/uploads/2019/01/3-3-768x185.jpg 768w, https://www.osradar.com/wp-content/uploads/2019/01/3-3.jpg 914w" sizes="(max-width: 692px) 100vw, 692px" /></p>
<h3><strong>Step 6: Format Partition (File system)</strong></h3>
<pre class="lang:sh decode:true"># mkswap   /dev/swap_vg/swap_lvm
</pre>
<p><img loading="lazy" class="alignnone wp-image-9411" style="color: #222222; font-family: Verdana, Geneva, sans-serif; font-size: 15px;" src="https://www.osradar.com/wp-content/uploads/2019/01/4-1-300x56.jpg" alt="" width="687" height="129" srcset="https://www.osradar.com/wp-content/uploads/2019/01/4-1-300x56.jpg 300w, https://www.osradar.com/wp-content/uploads/2019/01/4-1-768x145.jpg 768w, https://www.osradar.com/wp-content/uploads/2019/01/4-1.jpg 882w" sizes="(max-width: 687px) 100vw, 687px" /></p>
<h3><strong>Step</strong><strong> 7: Mount Partition in /etc/fstab File</strong></h3>
<pre class="lang:sh decode:true"># vi /etc/fstab</pre>
<p>and add the following entry:</p>
<p class=""><span style="color: #008000;">/dev/swap_vg/swap_lvm  swap  swap  defaults 0 0</span></p>
<p>write changes to /etc/fstab and quite</p>
<p><img loading="lazy" class="alignnone wp-image-9412" src="https://www.osradar.com/wp-content/uploads/2019/01/5-3-300x101.jpg" alt="" width="698" height="235" srcset="https://www.osradar.com/wp-content/uploads/2019/01/5-3-300x101.jpg 300w, https://www.osradar.com/wp-content/uploads/2019/01/5-3-768x257.jpg 768w, https://www.osradar.com/wp-content/uploads/2019/01/5-3.jpg 925w" sizes="(max-width: 698px) 100vw, 698px" /></p>
<h3><strong>Step 8: Now Activate Created SWAP<br />
</strong></h3>
<pre class="lang:sh decode:true"># swapoff  -a              (Disable all swap)

# swapon  -a               (enable all swap)

# swapon  -s               (list enabled all swap)

# free   -m</pre>
<hr />
<h1 style="text-align: center;"><strong>Make SWAP FILE</strong></h1>
<h3><strong>Step 1: Make File</strong></h3>
<p>We will create swap file of 3GB</p>
<p>Use the following command</p>
<pre class="lang:sh decode:true"># dd if=/dev/zero of=/myswap bs=1G count=3
</pre>
<p>Note: Above command will take some time to generate the file.</p>
<p><img loading="lazy" class="alignnone wp-image-9416" src="https://www.osradar.com/wp-content/uploads/2019/01/1-5-300x60.jpg" alt="" width="690" height="138" srcset="https://www.osradar.com/wp-content/uploads/2019/01/1-5-300x60.jpg 300w, https://www.osradar.com/wp-content/uploads/2019/01/1-5-768x155.jpg 768w, https://www.osradar.com/wp-content/uploads/2019/01/1-5.jpg 819w" sizes="(max-width: 690px) 100vw, 690px" /></p>
<h3><strong>Step 2: Set Permission on SWAP File</strong></h3>
<p>set the appropriate permissions on the file to make it readable only by root user.</p>
<pre class="lang:sh decode:true "># cd /

# chmod   600   /myswap

# ls –lh myswap

</pre>
<p><img loading="lazy" class="alignnone wp-image-9417" src="https://www.osradar.com/wp-content/uploads/2019/01/2-4-300x70.jpg" alt="" width="690" height="161" srcset="https://www.osradar.com/wp-content/uploads/2019/01/2-4-300x70.jpg 300w, https://www.osradar.com/wp-content/uploads/2019/01/2-4-768x179.jpg 768w, https://www.osradar.com/wp-content/uploads/2019/01/2-4.jpg 813w" sizes="(max-width: 690px) 100vw, 690px" /></p>
<h3><strong>Step 3: Set SWAP Filesystem on file</strong></h3>
<pre class="lang:sh decode:true"># mkswap /myswap</pre>
<h3 class=""><strong>Step 4: Enable SWAP File</strong></h3>
<pre class="lang:sh decode:true "># swapon  /myswap</pre>
<h3><strong>Step 5: Mount SWAP File in /etc/fstab file</strong></h3>
<pre class="lang:sh decode:true"># vi /etc/fstab</pre>
<p>and add following entry:</p>
<p class=""><span style="color: #008000;">/myswap  swap  swap  defaults 0 0</span></p>
<p>write changes to /etc/fstab and quite</p>
<p><img loading="lazy" class="alignnone wp-image-9418" src="https://www.osradar.com/wp-content/uploads/2019/01/3-4-300x107.jpg" alt="" width="690" height="246" srcset="https://www.osradar.com/wp-content/uploads/2019/01/3-4-300x107.jpg 300w, https://www.osradar.com/wp-content/uploads/2019/01/3-4-768x273.jpg 768w, https://www.osradar.com/wp-content/uploads/2019/01/3-4.jpg 887w" sizes="(max-width: 690px) 100vw, 690px" /></p>
<h3><strong>Step 6: Now Activate Created SWAP<br />
</strong></h3>
<pre class="lang:sh decode:true"># swapoff  -a              (Disable all swap)

# swapon  -a               (enable all swap)

# swapon  -s               (list enabled all swap)

# free   -m</pre>
<p>You have learned that how to create different types of SWAP in Linux.</p>
<p>The post <a rel="nofollow" href="https://www.osradar.com/how-to-create-swap-in-centos/">How to Create SWAP in Centos</a> appeared first on <a rel="nofollow" href="https://www.osradar.com">Linux  Windows and android  Tutorials</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.osradar.com/how-to-create-swap-in-centos/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
