Jekyll2021-05-25T20:15:24-03:00https://schertel.dev/blog/feed.xml508: Loop DetectedWrite an awesome description for your new site here. You can edit this line in _config.yml. It will appear in your document head meta (for Google search results) and in your feed.xml site description.Compiling the docker-compose binary for Raspberry Pi2021-05-25T19:03:00-03:002021-05-25T19:03:00-03:00https://schertel.dev/blog/container/compiling-the-docker-compose-binary-for-raspberry-pi<p><strong>Update on 2021-05-21:</strong></p>
<blockquote>
<p>Although the method presented in this post still works as described for the version mentioned (1.25.5), for newer versions (e.g.: 1.29.2) changes in the cloned repo code are required.</p>
<p>Because of that it is recommended to install <code class="language-plaintext highlighter-rouge">docker-compose</code> on a Raspberry Pi using the <a href="https://docs.docker.com/compose/install/#install-using-pip">pip</a> alternative method.</p>
</blockquote>
<p><strong>Original post from 2020-06-05:</strong></p>
<p>Everyone knows the hassles of installing <a href="https://www.docker.com/">docker</a> on a <a href="https://www.raspberrypi.org/">Raspberry Pi</a> are mostly gone.</p>
<p>Besides specialized distros like <a href="https://dietpi.com/">dietpi</a> - where the installation is one command-line away - or <a href="https://blog.hypriot.com/">hypriot</a> -, which comes with it preinstallled and optimized, the official documentation already includes instructions for using an official <code class="language-plaintext highlighter-rouge">arm</code> supported repository.</p>
<p>If you consider:</p>
<p><img src="/blog/assets/compiling-the-docker-compose-binary-for-raspberry-pi-arm.png" alt="Install docker using the repository" /></p>
<p>But trying to install <a href="https://docs.docker.com/compose/">docker-compose</a> using the <a href="https://docs.docker.com/compose/install/#install-compose-on-linux-systems">official instructions</a>…</p>
<p><img src="/blog/assets/compiling-the-docker-compose-binary-for-raspberry-pi-compose-install.png" alt="Install docker-compose" /></p>
<p>You’ll see it returns an error. Maybe not, since the command fails without any visible error:</p>
<p><img src="/blog/assets/compiling-the-docker-compose-binary-for-raspberry-pi-compose-install-error.png" alt="No visible error" /></p>
<p>The download was only 9kb, it was not the expected binary, but the <code class="language-plaintext highlighter-rouge">404 Not Found</code> error returned when accessing <a href="https://github.com/docker/compose/releases/download/1.25.5/docker-compose-Linux-armv7l">https://github.com/docker/compose/releases/download/1.25.5/docker-compose-Linux-armv7l</a>. There are no <a href="https://github.com/docker/compose/releases">release</a> builds for <code class="language-plaintext highlighter-rouge">arm</code> architecture.</p>
<p>It’s possible to install <code class="language-plaintext highlighter-rouge">docker-compose</code> using <a href="https://docs.docker.com/compose/install/#install-using-pip">pip</a>, but what if a pre-compiled binary is desired?</p>
<h2 id="compiling">Compiling</h2>
<p>It’s actually pretty simple to compile the <code class="language-plaintext highlighter-rouge">docker-compose</code> binary. The only requirement is a Raspberry Pi with a working <code class="language-plaintext highlighter-rouge">docker</code> installation.</p>
<p>To build and install the 1.25.5 release:</p>
<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># clone the repo</span>
<span class="nv">$ </span>git clone https://github.com/docker/compose.git
<span class="nv">$ </span><span class="nb">cd </span>compose
<span class="c"># checkout the desired version</span>
<span class="nv">$ </span>git checkout 1.25.5
<span class="c"># run the build script</span>
<span class="nv">$ </span>./script/build/linux
<span class="c"># wait a little while... and install it</span>
<span class="nv">$ </span><span class="nb">sudo mv </span>dist/docker-compose-Linux-armv7l /usr/local/bin/docker-compose
</code></pre></div></div>
<p>The build script detects the host architecture and compile the binary using the correct docker images, <code class="language-plaintext highlighter-rouge">armhf</code> on the <a href="https://www.raspberrypi.org/products/raspberry-pi-3-model-b-plus/">Raspberry Pi 3 Model B+</a>.</p>
<p>That’s it! plain and simple! and don’t forget to save it aside so it’s easy to reuse it on other boards… because who only has <strong>one</strong> rPi? I know I don’t…</p>
<p><img src="/blog/assets/compiling-the-docker-compose-binary-for-raspberry-pi-compose-picluster.jpg" alt="Raspberry Pi Home Lab Cluster" /></p>Matias S.Update on 2021-05-21:Arch Linux ARM image for Raspberry Pi2015-08-09T23:51:00-03:002015-08-09T23:51:00-03:00https://schertel.dev/blog/raspberry%20pi/arch-linux-arm-image-for-raspberry-pi<p>Currently neither <a href="https://www.raspberrypi.org/">Raspberry Pi</a> nor the <a href="http://archlinuxarm.org/">Arch Linux ARM</a> website offer an image ready for use of Arch Linux for Raspberry Pi, and because of that I created this small step by steps on how to do it on Linux.</p>
<h2 id="tutorial">Tutorial</h2>
<ol>
<li>Download the last release <a href="http://archlinuxarm.org/developers/downloads">image</a> for your Pi (ARM).</li>
<li>Create a image file of 2gb:
<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">$</span><span class="w"> </span><span class="nb">dd </span><span class="k">if</span><span class="o">=</span>/dev/zero <span class="nv">of</span><span class="o">=</span>arch.img <span class="nv">bs</span><span class="o">=</span>1M <span class="nv">count</span><span class="o">=</span>1850
</code></pre></div> </div>
</li>
<li>Partition the image file<sup id="fnref:1" role="doc-noteref"><a href="#fn:1" class="footnote" rel="footnote">1</a></sup>:
<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">$</span><span class="w"> </span>fdisk arch.img
</code></pre></div> </div>
<ol>
<li>Type <strong>o</strong>. This will clear out any partitions on the drive.</li>
<li>Type <strong>p</strong> to list partitions. There should be no partitions left.</li>
<li>Type <strong>n</strong>, then <strong>p</strong> for primary, <strong>1</strong> for the first partition on the drive, press ENTER to accept the default first sector, then type <strong>+100M</strong> for the last sector.</li>
<li>Type <strong>t</strong>, then <strong>c</strong> to set the first partition to type W95 FAT32 (LBA).</li>
<li>Type <strong>n</strong>, then <strong>p</strong> for primary, <strong>2</strong> for the second partition on the drive, and then press ENTER twice to accept the default first and last sector.</li>
<li>Write the partition table and exit by typing <strong>w</strong>.</li>
</ol>
</li>
<li>Check the partitions created:
<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">$</span><span class="w"> </span>fdisk <span class="nt">-l</span> arch.img
</code></pre></div> </div>
</li>
<li>Mount the <strong>boot</strong> partition<sup id="fnref:2" role="doc-noteref"><a href="#fn:2" class="footnote" rel="footnote">2</a></sup>:
<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">$</span><span class="w"> </span>losetup <span class="nt">-v</span> <span class="nt">-f</span> <span class="nt">-o</span> <span class="k">$((</span><span class="m">2048</span> <span class="o">*</span> <span class="m">512</span><span class="k">))</span> <span class="nt">--sizelimit</span> 104857600 arch.img
</code></pre></div> </div>
</li>
<li>Mount the <strong>root</strong> partition:
<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">$</span><span class="w"> </span>losetup <span class="nt">-v</span> <span class="nt">-f</span> <span class="nt">-o</span> <span class="k">$((</span><span class="m">206848</span> <span class="o">*</span> <span class="m">512</span><span class="k">))</span> <span class="nt">--sizelimit</span> 1833959424 arch.img
</code></pre></div> </div>
</li>
<li>Format and mount <strong>boot</strong> partition
<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">$</span><span class="w"> </span>mkfs.vfat /dev/loop0
<span class="gp">$</span><span class="w"> </span><span class="nb">mkdir </span>boot
<span class="gp">$</span><span class="w"> </span>mount /dev/loop0 boot
</code></pre></div> </div>
</li>
<li>Format and mount <strong>root</strong> partition
<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">$</span><span class="w"> </span>mkfs.ext4 /dev/loop1
<span class="gp">$</span><span class="w"> </span><span class="nb">mkdir </span>root
<span class="gp">$</span><span class="w"> </span>mount /dev/loop1 root
</code></pre></div> </div>
</li>
<li>Become <strong>root</strong>:
<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">$</span><span class="w"> </span><span class="nb">sudo </span>su -
</code></pre></div> </div>
</li>
<li>Extract <strong>image</strong> files:
<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">$</span><span class="w"> </span>bsdtar <span class="nt">-xpf</span> ArchLinuxARM-rpi-latest.tar.gz <span class="nt">-C</span> root
<span class="gp">$</span><span class="w"> </span><span class="nb">sync</span>
</code></pre></div> </div>
</li>
<li>Copy <strong>boot</strong> files:
<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">$</span><span class="w"> </span><span class="nb">mv </span>root/boot/<span class="k">*</span> boot
<span class="gp">$</span><span class="w"> </span><span class="nb">sync</span>
</code></pre></div> </div>
</li>
<li>Unmount partitions:
<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">$</span><span class="w"> </span>umount boot root
<span class="gp">$</span><span class="w"> </span><span class="nb">rmdir </span>boot root
</code></pre></div> </div>
</li>
<li>Back to your user:
<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">$</span><span class="w"> </span><span class="nb">exit</span>
</code></pre></div> </div>
</li>
<li>Detach partitions:
<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">$</span><span class="w"> </span>losetup <span class="nt">-d</span> /dev/loop0
<span class="gp">$</span><span class="w"> </span>losetup <span class="nt">-d</span> /dev/loop1
</code></pre></div> </div>
</li>
</ol>
<p>Your image is ready to be used!</p>
<hr />
<div class="footnotes" role="doc-endnotes">
<ol>
<li id="fn:1" role="doc-endnote">
<p><a href="http://archlinuxarm.org/platforms/armv6/raspberry-pi">Raspberry Pi, SD Card Creation</a> <a href="#fnref:1" class="reversefootnote" role="doc-backlink">↩</a></p>
</li>
<li id="fn:2" role="doc-endnote">
<p><a href="http://unix.stackexchange.com/a/72449">Calculate offset and sizelimit of a partition</a> <a href="#fnref:2" class="reversefootnote" role="doc-backlink">↩</a></p>
</li>
</ol>
</div>Matias S.Currently neither Raspberry Pi nor the Arch Linux ARM website offer an image ready for use of Arch Linux for Raspberry Pi, and because of that I created this small step by steps on how to do it on Linux.Install Microsoft Windows truetype fonts in Ubuntu2014-06-01T20:29:00-03:002014-06-01T20:29:00-03:00https://schertel.dev/blog/software/install-microsoft-windows-truetype-fonts-in-ubuntu<p>To install Microsoft core fonts easy using <code class="language-plaintext highlighter-rouge">apt-get</code> enter the following in a terminal window:</p>
<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">$</span><span class="w"> </span><span class="nb">sudo </span>apt-get <span class="nb">install </span>ttf-mscorefonts-installer
</code></pre></div></div>
<p>This command will install the following true type fonts commonly present in Windows:</p>
<ul>
<li>Andale Mono</li>
<li>Arial Black</li>
<li>Arial (Bold, Italic, Bold Italic)</li>
<li>Comic Sans MS (Bold)</li>
<li>Courier New (Bold, Italic, Bold Italic)</li>
<li>Georgia (Bold, Italic, Bold Italic)</li>
<li>Impact</li>
<li>Times New Roman (Bold, Italic, Bold Italic)</li>
<li>Trebuchet (Bold, Italic, Bold Italic)</li>
<li>Verdana (Bold, Italic, Bold Italic)</li>
<li>Webdings</li>
</ul>
<dl>
<dt>Tip</dt>
<dd>You can also use the <strong>Ubuntu Software Center</strong>.</dd>
</dl>Matias S.To install Microsoft core fonts easy using apt-get enter the following in a terminal window:Use WebP images in your site with .htaccess2014-04-27T23:27:00-03:002014-04-27T23:27:00-03:00https://schertel.dev/blog/development/use-webp-images-in-your-site-with-htaccess<p><a href="https://developers.google.com/speed/webp/">WebP</a> is a fairly new image format under development by <a href="https://developers.google.com/products/">Google</a> with the intent of creating smaller files without losing quality. A WebP file is about 34% smaller than a visual equivalent JPEG, while also supporting transparency by the use of alpha channels.</p>
<p>Currently only a few browsers<sup id="fnref:1" role="doc-noteref"><a href="#fn:1" class="footnote" rel="footnote">1</a></sup> support the format, making a big risk to simply to simply convert all image in your site. So a more subtle approach is required, one that is invisible to your site’s visitor, thats where <a href="https://en.wikipedia.org/wiki/Htaccess">.htaccess</a> comes in handy.</p>
<h2 id="adapting-your-site">Adapting your site</h2>
<p>There are two steps to this process, first will create a <a href="https://developers.google.com/speed/webp/">WebP</a> equivalente to all image you want to make available, than will create a .htaccess rule that will serve to correct file for each browser.</p>
<h3 id="converting-the-images">Converting the images</h3>
<p>Keep in mind that we wont replace the image, but rather create WebP copys of them with the same name and location, e.g.:</p>
<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">$</span><span class="w"> </span><span class="nb">ls</span> <span class="nt">-al</span>
<span class="go">total 436
drwxrwxr-x 2 4096 Abr 27 02:08 .
drwxrwxr-x 3 4096 Abr 27 02:44 ..
-rw-rw-r-- 1 374050 Abr 25 01:53 instalando-o-steam-localmente-no-gnulinux-screenshot.png
-rw-rw-r-- 1 44832 Abr 27 02:08 instalando-o-steam-localmente-no-gnulinux-screenshot.webp
</span></code></pre></div></div>
<p>For that we will use the libwebp set of tools, more specifically the <code class="language-plaintext highlighter-rouge">cwebp</code> program, available for Windows, OSx and Linux and can be downloaded as <a href="https://developers.google.com/speed/webp/docs/precompiled">precompiled</a> binaries<sup id="fnref:2" role="doc-noteref"><a href="#fn:2" class="footnote" rel="footnote">2</a></sup>, but on Ubuntu its easy as using <code class="language-plaintext highlighter-rouge">apt-get</code>:</p>
<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">$</span><span class="w"> </span><span class="nb">sudo </span>apt-get <span class="nb">install </span>webp
</code></pre></div></div>
<p>Then convert the desired images using:</p>
<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">$</span><span class="w"> </span>cwebp image_file.jpg <span class="nt">-o</span> image_file.webp
</code></pre></div></div>
<dl>
<dt>Attention</dt>
<dd>The output file must have the same name of the input file.</dd>
</dl>
<p>There are many other parameters to fine tune the conversions see the <code class="language-plaintext highlighter-rouge">--longhep</code> of <code class="language-plaintext highlighter-rouge">cwebp</code> for more options, one that is really usefull is the <code class="language-plaintext highlighter-rouge">-preset</code> a serie of preset (duh) values for the most common scenarios, e.g.:</p>
<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">$</span><span class="w"> </span>cwebp <span class="nt">-preset</span> <span class="o">[</span>preset] image_file.png <span class="nt">-o</span> image_file.webp
</code></pre></div></div>
<p>Where <code class="language-plaintext highlighter-rouge">[preset]</code> can be:</p>
<ul>
<li>default</li>
<li>photo</li>
<li>picture</li>
<li>drawing</li>
<li>icon</li>
<li>text</li>
</ul>
<p>Choose the best for each file.</p>
<h3 id="serving-the-images">Serving the images</h3>
<p>Now that our images are converted how can we serve them? If we simply replace the old files with the WebP versions a good number of browser wont be able to render them.</p>
<p>Thats where htaccess file comes in, by creating a rewrite rule that that everytime a image is requested will check if the requesting browser support the new format, and if so will profile the WebP file instead of the original requested.</p>
<p>So, create a <code class="language-plaintext highlighter-rouge">.htaccess</code> in your sites root directory (if there isnt one already) and add the following lines<sup id="fnref:3" role="doc-noteref"><a href="#fn:3" class="footnote" rel="footnote">3</a></sup>:</p>
<pre><code class="language-apacheconf"><IfModule mod_rewrite.c>
RewriteEngine On
# check if browser accepts webp
RewriteCond %{HTTP_ACCEPT} image/webp
# check if file is jpg or png
RewriteCond %{REQUEST_FILENAME} (.*)\.(jpe?g|png)$
# check if corresponding webp file exists image.png -> image.webp
RewriteCond %1\.webp -f
# serve up webp instead
RewriteRule (.+)\.(jpe?g|png)$ $1.webp [T=image/webp,E=accept:1]
</IfModule>
<IfModule mod_headers.c>
Header append Vary Accept env=REDIRECT_accept
</IfModule>
AddType image/webp .webp
</code></pre>
<p>To make sure if its working open Chrome <a href="https://developers.google.com/chrome-developer-tools/">DevTools</a> (<code class="language-plaintext highlighter-rouge">SHIFT + CTRL + I</code>) select the <strong>Network</strong> tab and load an image of your site and compare the <strong>Type</strong> column with and without the htaccess rule, i.e:</p>
<p><img src="/blog/assets/use-webp-images-on-your-site-with-htaccess-without.png" alt="Without support to WebP" /></p>
<p><img src="/blog/assets/use-webp-images-on-your-site-with-htaccess-with.png" alt="With support to WebP" /></p>
<dl>
<dt>Tip</dt>
<dd>Its a go idea to test the site in a browser that lacks support, Internet Explorer for example.</dd>
</dl>
<h2 id="the-future">The Future</h2>
<p>With many new formats like <a href="https://en.wikipedia.org/wiki/Multiple-image_Network_Graphics">MNG</a>, the some what old <a href="https://en.wikipedia.org/wiki/JPEG_2000">JPEG 2000</a> and the new <a href="https://en.wikipedia.org/wiki/JPEG_XR">JPEG XR</a> fighting along <a href="https://developers.google.com/speed/webp/">WebP</a> for the place of image format of choice for the web, the future is uncertain, but having a giant like <a href="https://developers.google.com/products/">Google</a> as supporter cetantly gives <a href="https://developers.google.com/speed/webp/">WebP</a> a good start.</p>
<p>Lets wait to see what the future holds for web development!</p>
<hr />
<div class="footnotes" role="doc-endnotes">
<ol>
<li id="fn:1" role="doc-endnote">
<p>WebP web browser <a href="https://en.wikipedia.org/wiki/WebP#Support">support</a> list <a href="#fnref:1" class="reversefootnote" role="doc-backlink">↩</a></p>
</li>
<li id="fn:2" role="doc-endnote">
<p>libwebp <a href="https://chromium.googlesource.com/webm/libwebp/">source</a> is also available <a href="#fnref:2" class="reversefootnote" role="doc-backlink">↩</a></p>
</li>
<li id="fn:3" role="doc-endnote">
<p><a href="http://mikevoermans.com/apache/serving-right-image-htaccess-webp">Serving Up the Right Image</a> <a href="#fnref:3" class="reversefootnote" role="doc-backlink">↩</a></p>
</li>
</ol>
</div>Matias S.WebP is a fairly new image format under development by Google with the intent of creating smaller files without losing quality. A WebP file is about 34% smaller than a visual equivalent JPEG, while also supporting transparency by the use of alpha channels.Add files to your last GIT commit2014-04-26T23:51:00-03:002014-04-26T23:51:00-03:00https://schertel.dev/blog/development/add-files-to-your-last-git-commit<p>More than once when using <a href="http://git-scm.com/">git</a> I forgot to add a file to a commit, like with this post:</p>
<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">$</span><span class="w"> </span>git status
<span class="go">On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
</span><span class="gp"> (use "git reset HEAD <file></span>...<span class="s2">" to unstage)
</span><span class="go">
new file: posts/git-adding-files-t-your-last-commit.rst
Untracked files:
</span><span class="gp"> (use "git add <file></span>...<span class="s2">" to include in what will be committed)
</span><span class="go">
posts/git-adding-files-t-your-last-commit.rst.pt_br
</span><span class="gp">$</span><span class="w"> </span>git commit <span class="nt">-am</span> <span class="s2">"en/pt_br: GIT: Adding files to your last commit!"</span>
<span class="go">[master cfa764b] en/pt_br: GIT: Adding files to your last commit!
1 file changed, 9 insertions(+)
create mode 100644 posts/git-adding-files-t-your-last-commit.rst
</span><span class="gp">$</span><span class="w"> </span>git status
<span class="go">On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
Untracked files:
</span><span class="gp"> (use "git add <file></span>...<span class="s2">" to include in what will be committed)
</span><span class="go">
posts/git-adding-files-t-your-last-commit.rst.pt_br
nothing added to commit but untracked files present (use "git add" to track)
</span></code></pre></div></div>
<p>One terrible way to fix this is commiting the missing files and specifying the mistake in the commit message, another <strong>awesome</strong> way would be using the <code class="language-plaintext highlighter-rouge">--amend</code> parameter of the <code class="language-plaintext highlighter-rouge">commit</code> command to add the files to the last commit.</p>
<p>First stage the missing files:</p>
<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">$</span><span class="w"> </span>git add posts/git-adding-files-t-your-last-commit.rst.pt_br
</code></pre></div></div>
<p>Then commit them using the <code class="language-plaintext highlighter-rouge">--amend</code> parameter:</p>
<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">$</span><span class="w"> </span>git commit <span class="nt">--amend</span> <span class="nt">-C</span> HEAD
<span class="go">[master f813cd5] en/pt_br: GIT: Adding files to your last commit!
2 files changed, 18 insertions(+)
create mode 100644 posts/git-adding-files-t-your-last-commit.rst
create mode 100644 posts/git-adding-files-t-your-last-commit.rst.pt_br
</span></code></pre></div></div>
<p>The <code class="language-plaintext highlighter-rouge">-C</code> tell the commit to use the commiting message of <strong>HEAD</strong>, if you omit the <code class="language-plaintext highlighter-rouge">-C HEAD</code> the message editor will open.</p>
<p>Note the we only have one commit with the message <em>en/pt_br: GIT: Adding files to your last commit!</em>:</p>
<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">$</span><span class="w"> </span>git log
<span class="go">commit f813cd5eb640aae1a45936af1bf80699f4064bad
</span><span class="gp">Author: Matias Schertel <matias@schertel.co></span><span class="w">
</span><span class="go">Date: Sat Apr 26 23:56:22 2014 -0300
en/pt_br: GIT: Adding files to your last commit!
commit 9f0380e37ff0e3861d27faf79d2a12716571e8ff
Merge: 63b749d 7acc31f
</span><span class="gp">Author: Matias Schertel <matias@schertel.co></span><span class="w">
</span><span class="go">Date: Sat Apr 26 23:48:22 2014 -0300
Merge branch 'master' of git:co-schertel-blog
</span></code></pre></div></div>
<p>Keep in mind that <code class="language-plaintext highlighter-rouge">--amend</code> will change the <strong>SHA1 ID</strong> of the commit.</p>Matias S.More than once when using git I forgot to add a file to a commit, like with this post:Write and read image files for the Raspberry Pi2014-03-08T18:24:00-03:002014-03-08T18:24:00-03:00https://schertel.dev/blog/raspberry%20pi/write-and-read-image-files-for-the-raspberry-pi<p>The <a href="http://www.raspberrypi.org/">Raspberry Pi</a> is this small cool ARM based board that you can use for endless projects and is compatible with many GNU/Linux distributions!</p>
<p>It main storage is a simple SD card that goes into a slot in the board and in this card is where you must install the linux distro you choose to use.</p>
<dl>
<dt>Attention</dt>
<dd>In this article, to exemplify the installation of a distro, we will use the <a href="https://en.wikipedia.org/wiki/ARM_architecture">ARM</a> compatible version of <a href="http://archlinuxarm.org/platforms/armv6/raspberry-pi">Arch Linux</a>, being installed in a Ubuntu environment.</dd>
</dl>
<h2 id="writing-the-image">Writing the image</h2>
<p>To write an image file to a SD card follow these steps:</p>
<ol>
<li>Download the the latest zip containing the image:
<ul>
<li><a href="http://archlinuxarm.org/os/ArchLinuxARM-rpi-latest.zip">Image file</a></li>
<li><a href="http://archlinuxarm.org/os/ArchLinuxARM-rpi-latest.zip.md5">MD5 sum</a></li>
</ul>
</li>
<li>Extract the zip file to your hard drive, giving you the image <strong>archlinux-hf-*.img</strong>.</li>
<li>Open a terminal window and go the the directory where the image was extracted.</li>
<li>Insert the card in your computer (at least 2GB<sup id="fnref:1" role="doc-noteref"><a href="#fn:1" class="footnote" rel="footnote">1</a></sup>).</li>
<li>Find out the path to the card:
<ol>
<li>With the command <code class="language-plaintext highlighter-rouge">df -h</code> list all mounted partitions.</li>
<li>Your card partition will be listed as something like <strong>/dev/mmcblk0p1</strong>.</li>
<li>The sd card itself is the partition path minus the <strong>pX</strong> part, so something like <strong>/dev/mmcblk0</strong>, take note of it.</li>
</ol>
</li>
<li>Unmount the card with the command:
<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">$</span><span class="w"> </span><span class="nb">sudo </span>umount /dev/mmcblk0
</code></pre></div> </div>
</li>
<li>To write the image to the card use:
<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">$</span><span class="w"> </span><span class="nb">sudo dd </span><span class="nv">bs</span><span class="o">=</span>1M <span class="k">if</span><span class="o">=</span>archlinux-hf-<span class="k">*</span>.img <span class="nv">of</span><span class="o">=</span>/dev/mmcblk0
</code></pre></div> </div>
</li>
<li>It could take a while, so <em>relax</em>.</li>
<li>After is done run the command <code class="language-plaintext highlighter-rouge">sync</code> to ensure the cache is flushed
and it safe to remove the card:
<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">$</span><span class="w"> </span><span class="nb">sudo sync</span>
</code></pre></div> </div>
</li>
<li>Remove it, insert it in the Pi.</li>
<li>Have fun!</li>
</ol>
<h2 id="reading-the-image">Reading the image</h2>
<p>After a while using your system you will have a fully personalized linux installation with your favorite programs in it.</p>
<p>But not everything are roses, SD cards are susceptible to corruption and a bad block can ruin your system, because of that is always handy to have a backup copy for easy recover!</p>
<p>And backing it up is pretty similar to how we write it in the first place:</p>
<ol>
<li>Insert the card with your system image in your computer.</li>
<li>Like when writing your image, use the <code class="language-plaintext highlighter-rouge">df -h</code> command to find the path to the card.</li>
<li>Unmount it with <code class="language-plaintext highlighter-rouge">sudo umount /dev/path_to_card</code>.</li>
<li>Now, use the <code class="language-plaintext highlighter-rouge">dd</code> command to write an image of the card to a file:
<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">$</span><span class="w"> </span><span class="nb">sudo dd </span><span class="nv">bs</span><span class="o">=</span>1M <span class="k">if</span><span class="o">=</span>/dev/path_to_card <span class="nv">of</span><span class="o">=</span>mylinux.image
</code></pre></div> </div>
</li>
<li>Execute the <code class="language-plaintext highlighter-rouge">sync</code> to flush the cache:
<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">$</span><span class="w"> </span><span class="nb">sudo sync</span>
</code></pre></div> </div>
</li>
<li>Remove your card.</li>
</ol>
<p>That’s it! Now you have a full backup of your customized system, if you have any problem just write it to a card line we did in the first part of this article and it will be as good as new!</p>
<dl>
<dt>Attention</dt>
<dd>The generated image can only be written to a card with the same (or larger) size, so the backup of a 4GB card can be written to a 8GB card, but not to a 2GB one.</dd>
</dl>
<hr />
<div class="footnotes" role="doc-endnotes">
<ol>
<li id="fn:1" role="doc-endnote">
<p>Each system have it’s own minimum space spec, make sure to check it in the systems site <a href="#fnref:1" class="reversefootnote" role="doc-backlink">↩</a></p>
</li>
</ol>
</div>Matias S.The Raspberry Pi is this small cool ARM based board that you can use for endless projects and is compatible with many GNU/Linux distributions!Install Steam locally in GNU/Linux2013-06-24T03:00:00-03:002013-06-24T03:00:00-03:00https://schertel.dev/blog/fun/install-steam-locally-in-gnu-linux<p><a href="http://store.steampowered.com/">Steam</a> for GNU/Linux has been around for a while now, and thanks to the efforst of <a href="http://www.valvesoftware.com/">Valve</a> more and more games are been released to the open-source OS!</p>
<p>But since I’m a bit paranoid, I choose to install it at my <code class="language-plaintext highlighter-rouge">$HOME</code> folder, avoiding any unnecessary permissions (<em>root-less</em> installation).</p>
<p>I’ve been using it like this for quite a while, with no noticeable downside.</p>
<h2 id="how-to">How-to</h2>
<p><img src="/blog/assets/install-steam-locally-in-gnu-linux-screenshot.png" alt="Steam on Linux" /></p>
<h3 id="dependencies">Dependencies</h3>
<p>First, with the help of you distro package manager make sure the following dependencies are installed:</p>
<ul>
<li>python</li>
<li>curl</li>
<li>jockey-common</li>
<li>libc6 (>= 2.15)</li>
<li>python-apt</li>
<li>xterm ou gnome-terminal ou konsole</li>
<li>xz-utils</li>
<li>zenity</li>
</ul>
<h3 id="installation">Installation</h3>
<p>Then, get the installer from the <a href="http://store.steampowered.com/about/">official site</a> or download the <a href="http://en.wikipedia.org/wiki/Deb_\(file_format\)">.deb</a> from Valve’s <a href="http://media.steampowered.com/client/installer/steam.deb">repository</a> as pointed out in their github page<sup id="fnref:1" role="doc-noteref"><a href="#fn:1" class="footnote" rel="footnote">1</a></sup>.</p>
<p>Copy the installer to a temporary folder (e.g.: <code class="language-plaintext highlighter-rouge">~/temp/</code>), and extract it:</p>
<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">$</span><span class="w"> </span>ar x steam.deb
</code></pre></div></div>
<p>Extract the <code class="language-plaintext highlighter-rouge">data.tar.gz</code> file:</p>
<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">$</span><span class="w"> </span><span class="nb">tar </span>xf data.tar.gz
</code></pre></div></div>
<p>Now extract <a href="http://store.steampowered.com/">Steam</a> to it’s final destination folder (e.g.: <code class="language-plaintext highlighter-rouge">~/steam/</code>):</p>
<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">$</span><span class="w"> </span><span class="nb">tar </span>xf ~/temp/usr/lib/steam/bootstraplinux_ubuntu12_32.tar.xz ~/steam/
</code></pre></div></div>
<p>Go to the directory <code class="language-plaintext highlighter-rouge">~/steam/</code> and execute <a href="http://store.steampowered.com/">Steam</a>:</p>
<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">$</span><span class="w"> </span>./steam.sh
</code></pre></div></div>
<p>In the first run all the necessary files will be downloaded and soon it will be ready for game!</p>
<hr />
<div class="footnotes" role="doc-endnotes">
<ol>
<li id="fn:1" role="doc-endnote">
<p><a href="https://github.com/ValveSoftware/steam-for-linux">https://github.com/ValveSoftware/steam-for-linux</a> <a href="#fnref:1" class="reversefootnote" role="doc-backlink">↩</a></p>
</li>
</ol>
</div>Matias S.Steam for GNU/Linux has been around for a while now, and thanks to the efforst of Valve more and more games are been released to the open-source OS!