<?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>Linux Archives | Paul Bupe Jr, PhD</title>
	<atom:link href="https://paulbupejr.com/category/tutorials/linux/feed/" rel="self" type="application/rss+xml" />
	<link>https://paulbupejr.com/category/tutorials/linux/</link>
	<description>Hardware, software, and everything in between</description>
	<lastBuildDate>Tue, 02 Feb 2021 16:52:15 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://paulbupejr.com/wp-content/uploads/2019/07/cropped-paul_logo@2x-32x32.png</url>
	<title>Linux Archives | Paul Bupe Jr, PhD</title>
	<link>https://paulbupejr.com/category/tutorials/linux/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Adding Swap Memory to the Beaglebone Black</title>
		<link>https://paulbupejr.com/adding-swap-memory-to-the-beaglebone-black/</link>
					<comments>https://paulbupejr.com/adding-swap-memory-to-the-beaglebone-black/#comments</comments>
		
		<dc:creator><![CDATA[paulbupe]]></dc:creator>
		<pubDate>Mon, 31 Dec 2018 22:48:37 +0000</pubDate>
				<category><![CDATA[BeagleBone Black]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[beaglebone]]></category>
		<category><![CDATA[beaglebone black]]></category>
		<category><![CDATA[linux]]></category>
		<guid isPermaLink="false">http://paulbupejr.com/?p=336</guid>

					<description><![CDATA[<p><span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 2</span> <span class="rt-label rt-postfix">minutes</span></span>I recently needed to build Python 3.6 from source on the BeagleBone Black for a robotics project and discovered that the build would always fail after running out of memory. Who could have figured that 512MB of RAM wasn&#8217;t enough to build Python from source?! While I could have set up cross-compilation and performed the &#8230; <a href="https://paulbupejr.com/adding-swap-memory-to-the-beaglebone-black/" class="more-link">Continue reading <span class="screen-reader-text">Adding Swap Memory to the Beaglebone Black</span></a></p>
<p>The post <a href="https://paulbupejr.com/adding-swap-memory-to-the-beaglebone-black/">Adding Swap Memory to the Beaglebone Black</a> appeared first on <a href="https://paulbupejr.com">Paul Bupe Jr, PhD</a>.</p>
]]></description>
										<content:encoded><![CDATA[<span class="span-reading-time rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">Reading Time: </span> <span class="rt-time"> 2</span> <span class="rt-label rt-postfix">minutes</span></span>
<p>I recently needed to build Python 3.6 from source on the BeagleBone Black for a robotics project and discovered that the build would always fail after running out of memory. Who could have figured that 512MB of RAM wasn&#8217;t enough to build Python from source?! While I could have set up cross-compilation and performed the heavy lifting on my computer with more resources, I figured this was a perfect problem to solve by adding swap memory to the BeagleBone Black.</p>



<span id="more-336"></span>



<h2 class="wp-block-heading">What is a swap space?</h2>



<p>At a very high level, a swap space (usually in the form of a partition) allows the system to move some of the &#8220;lower priority&#8221; memory pages (blocks of memory) to the partition or file so that higher priority tasks can use the memory. The combined size of the physical memory and swap space is called <em>virtual memory</em>. Gary Sims has a great primer on swap spaces over at <a href="https://www.linux.com/news/all-about-linux-swap-space">linux.com</a></p>



<p>In this case, the BeagleBone Black only has 512MB of RAM so I&#8217;ll be adding ~1GB of swap space to my SD card in the form of a swap file. This will allow it to perform more memory-intensive tasks without running out of memory (at a cost of slower access times).</p>



<h2 class="wp-block-heading">Creating a swap file</h2>



<p>Creating a swap space is a fairly simple process that involves creating a file (and filling it with zeros) then telling the system to use that file as a swap space. Finally, the system has to be configured to load that file on startup.</p>



<h5 class="wp-block-heading">Check if you already have a swap file</h5>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;cobalt&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudo swapon -s</pre></div>



<div class="wp-block-image"><figure class="aligncenter"><img fetchpriority="high" decoding="async" width="670" height="77" src="http://paulbupejr.com/wp-content/uploads/2018/12/swapon.png" alt="" class="wp-image-343" srcset="https://paulbupejr.com/wp-content/uploads/2018/12/swapon.png 670w, https://paulbupejr.com/wp-content/uploads/2018/12/swapon-300x34.png 300w" sizes="(max-width: 670px) 100vw, 670px" /></figure></div>



<p>In my case I already created the file so it&#8217;s shown. The assumptions is that you&#8217;re performing these steps because you don&#8217;t have a swap space.</p>



<h5 class="wp-block-heading">Create the swap file</h5>



<p>Use the <code>dd </code>utility to create a file with a fixed size and fill it with &#8220;zeroes&#8221;. In this case I&#8217;m moving 1000 &#8220;zeroes&#8221; from <code>/dev/zero</code> in block sizes of 1024k (1MB) into my file at&nbsp;<code>/var/cache/swap/swapfile</code>. This will result in a swap file of around 1 gigabyte. <em>Keep in mind that the swap file is actually named &#8220;swapfile&#8221; with no extension</em>.</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;cobalt&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudo dd if=/dev/zero of=/var/cache/swap/swapfile bs=1024k count=1000</pre></div>



<p>use <code>chmod </code>to change the file permissions of the new swap file.</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;cobalt&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudo chmod 0600 /var/cache/swap/swapfile</pre></div>



<p>Use the <code>mkswap&nbsp; </code>command to create the swap area using our newly created swap file.</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;cobalt&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudo mkswap /var/cache/swap/swapfile</pre></div>



<p>Finally, enable the swap area with the <code>swapon </code>command</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;cobalt&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudo swapon /var/cache/swap/swapfile</pre></div>



<h5 class="wp-block-heading">Configure the swap file to automatically mount on boot</h5>



<p>Open up the <code>/etc/fstab</code> file with the <code>nano </code>editor.</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;cobalt&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">sudo nano /etc/fstab</pre></div>



<p>Append the following line to the file:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text/x-sh&quot;,&quot;theme&quot;:&quot;cobalt&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}">/var/cache/swap/swapfile    none   swap   sw   0   0</pre></div>



<p>That is all there is to it for this specific case &#8211; adding swap memory to the BeagleBone Black is pretty straightforward! </p>



<div class="wp-block-image wp-image-344 size-full"><figure class="aligncenter"><img decoding="async" width="689" height="227" src="http://paulbupejr.com/wp-content/uploads/2018/12/top2.png" alt="" class="wp-image-344" srcset="https://paulbupejr.com/wp-content/uploads/2018/12/top2.png 689w, https://paulbupejr.com/wp-content/uploads/2018/12/top2-300x99.png 300w" sizes="(max-width: 689px) 100vw, 689px" /><figcaption>The newly created swap space being heavily during building</figcaption></figure></div>
<p>The post <a href="https://paulbupejr.com/adding-swap-memory-to-the-beaglebone-black/">Adding Swap Memory to the Beaglebone Black</a> appeared first on <a href="https://paulbupejr.com">Paul Bupe Jr, PhD</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://paulbupejr.com/adding-swap-memory-to-the-beaglebone-black/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Lazy Loading (feed)

Served from: paulbupejr.com @ 2026-04-15 13:15:49 by W3 Total Cache
-->