<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.5">Jekyll</generator><link href="https://glacion.com/feed.xml" rel="self" type="application/atom+xml" /><link href="https://glacion.com/" rel="alternate" type="text/html" /><updated>2024-04-23T12:13:13+00:00</updated><id>https://glacion.com/feed.xml</id><title type="html">Ahmetcan Güvendiren</title><subtitle>Source for glacion.com</subtitle><entry><title type="html">From Zero to Fedora Workstation</title><link href="https://glacion.com/2021/02/01/Fedora.html" rel="alternate" type="text/html" title="From Zero to Fedora Workstation" /><published>2021-02-01T00:00:00+00:00</published><updated>2021-02-01T00:00:00+00:00</updated><id>https://glacion.com/2021/02/01/Fedora</id><content type="html" xml:base="https://glacion.com/2021/02/01/Fedora.html"><![CDATA[<p>Here’s a set of instructions to install fedora on a
system the arch way™ with or without dualbooting with windows.</p>

<ul>
  <li>Boot fedora live from a USB</li>
  <li>Get root with <code class="language-plaintext highlighter-rouge">sudo -s</code></li>
</ul>

<p><strong>WARNING:</strong> If your system is UEFI, you already have a windows installation, and you don’t have an ESP, <strong>STOP RIGHT NOW</strong>, you’ve installed windows in CSM mode, and you will break your windows installation.
Either work out how to deal with MBR on your own, or backup your important data, disable CSM from your firmware settings, delete everything, reset the partition table, follow the rest of the instructions, then install windows.</p>

<h2 id="partitioning">Partitioning</h2>

<p>This installation will dual boot with Windows,
so i have this partition table on my SSD on /dev/sda</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 447.1G  0 disk
├─sda1   8:1    0     1G  0 part /boot
├─sda2   8:2    0    96G  0 part /
├─sda3   8:3    0    16M  0 part
└─sda4   8:4    0 350.1G  0 part
sdb      8:16   0 931.5G  0 disk
├─sdb1   8:17   0    16M  0 part
└─sdb2   8:18   0 931.5G  0 part
sdc      8:32   1   7.5G  0 disk
└─sdc1   8:33   1   7.5G  0 part /run/media/glacion/FEDORA-WS-L
</code></pre></div></div>

<p>Some notes:</p>

<ul>
  <li>I am not using a swap partition.</li>
  <li>I don’t have a seperate home partition.</li>
  <li><code class="language-plaintext highlighter-rouge">/dev/sda1</code> will be used by both windows and fedora,
be careful not to format the ESP if you’ve already installed windows, it’s a pain to get windows’ bootloader installed again. When asked for partition type, enter <code class="language-plaintext highlighter-rouge">EF00</code> for ESP partition.</li>
</ul>

<h2 id="filesystems">Filesystems</h2>

<p>ESP is vfat, no exceptions. Don’t do this unless you don’t have a working windows(or any other OS) installation. I had installed windows before so i’ll leave ESP as is.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>mkfs.vfat <span class="nt">-n</span> ESP /dev/sda1
</code></pre></div></div>

<p>I like to use XFS for my installation filesystem. Use whatever you want, but there’s something you need to do which will be noted in a later section.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>mkfs.xfs <span class="nt">-L</span> fedora /dev/sda2
</code></pre></div></div>

<h2 id="setup">Setup</h2>

<p>Mount your partitions</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>mount /dev/sda2 /mnt
<span class="nb">mkdir</span> /mnt/boot
mount /dev/sda1 /mnt/boot
</code></pre></div></div>

<p>…No <code class="language-plaintext highlighter-rouge">/boot/efi</code>?
Yes, i had prepared my ESP when i was first installing on this computer to be 1G,
windows by default create an 100M ESP partition,
which is enough for both windows,
and kernel, initrd, and bootloader.
But 100M won’t be enough if you keep more than 2 kernels if you want to keep multiple kernels installed.</p>

<h2 id="bootstrapping-fedora">Bootstrapping Fedora</h2>

<p>With everything out of the way,
let’s install a bare minimum required for a functioning system. Replace or add to <code class="language-plaintext highlighter-rouge">glibc-langpack-en</code> if you want localization on your system. Omitting this will cause dnf to install all available langpacks.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>dnf <span class="nb">install</span> <span class="se">\</span>
<span class="nt">--installroot</span><span class="o">=</span>/mnt <span class="se">\</span>
<span class="nt">--releasever</span><span class="o">=</span>33 <span class="se">\</span>
<span class="nt">--setopt</span><span class="o">=</span><span class="nv">install_weak_deps</span><span class="o">=</span>False <span class="se">\</span>
<span class="nt">--assumeyes</span> <span class="se">\</span>
systemd dnf glibc-langpack-en vim-minimal <span class="nb">sudo </span>passwd
</code></pre></div></div>

<h2 id="generating-etcfstab">Generating /etc/fstab</h2>

<p>Arch Linux has a convenient little tool called <code class="language-plaintext highlighter-rouge">genfstab</code> that we can use for this.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>wget https://github.com/glacion/genfstab/releases/download/1.0/genfstab
<span class="nb">chmod</span> +x genfstab
./genfstab /mnt <span class="o">&gt;&gt;</span> /mnt/etc/fstab
</code></pre></div></div>

<p>Control <code class="language-plaintext highlighter-rouge">/mnt/etc/fstab</code> and manually modify if necessary.
I’ll remove <code class="language-plaintext highlighter-rouge">/dev/zram0</code> entry since i don’t want swap.</p>

<h2 id="installation">Installation</h2>

<p>Chroot into the container</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>systemd-nspawn <span class="nt">-D</span> /mnt
</code></pre></div></div>

<p>Create user</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>useradd <span class="nt">-c</span> <span class="s2">"Ahmetcan Güvendiren"</span> <span class="nt">-m</span> <span class="nt">-G</span> wheel <span class="nt">-s</span> /bin/bash glacion
</code></pre></div></div>

<p>Set password for the user</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>passwd glacion
</code></pre></div></div>

<p>Exit the chroot with <code class="language-plaintext highlighter-rouge">C-d</code></p>

<p>“boot” the newly bootstrapped system.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>systemd-nspawn <span class="nt">-bD</span> /mnt
</code></pre></div></div>

<p>Login with your credentials, become root with <code class="language-plaintext highlighter-rouge">sudo</code></p>

<p>I’ll delete some repositories that i don’t use.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">rm</span> <span class="nt">-f</span> /etc/yum.repos.d/<span class="k">*</span><span class="o">{</span><span class="k">*</span>cisco<span class="k">*</span>,<span class="k">*</span>testing<span class="k">*</span>,<span class="k">*</span>modular<span class="k">*</span><span class="o">}</span><span class="k">*</span>
</code></pre></div></div>

<p>I’ll disable installation of weak dependencies</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>vi /etc/dnf/dnf.conf
</code></pre></div></div>

<p>Append <code class="language-plaintext highlighter-rouge">install_weak_deps=False</code> to the end of that file, save and exit.</p>

<h2 id="bootloader">Bootloader</h2>

<p>Install <code class="language-plaintext highlighter-rouge">systemd-udev</code> package with dnf.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>dnf <span class="nb">install </span>systemd-udev
</code></pre></div></div>

<p>You may need to edit <code class="language-plaintext highlighter-rouge">/etc/resolv.conf</code> if you get an error saying “couldn’t resolve host name”. Add <code class="language-plaintext highlighter-rouge">nameserver 1.1.1.1</code> or something to that file and try again.</p>

<h3 id="install-the-bootloader">Install The Bootloader</h3>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>bootctl <span class="nb">install</span>
</code></pre></div></div>

<p>…Wait, where’s grub? I don’t use grub, and i recommend you to not use grub as well unless you have a specific setup. If you want grub, you’re on your own.</p>

<h3 id="configure-initrd">Configure Initrd</h3>

<p>You need to make dracut know whatever your filesystem is.
Replace xfsprogs with whatever the programs for your root filesystem is. I use LZ4 for compressing my initrd. Omit that if you’re fine with it.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>dnf <span class="nb">install </span>dracut xfsprogs lz4
vi /etc/dracut.conf.d/bardiche.conf
<span class="c"># Add these to that file</span>
filesystems+<span class="o">=</span><span class="s2">" xfs "</span>
drivers+<span class="o">=</span><span class="s2">" i915 "</span>
<span class="nv">compress</span><span class="o">=</span><span class="s2">"lz4"</span>
<span class="nv">hostonly</span><span class="o">=</span><span class="s2">"yes"</span>
</code></pre></div></div>

<h3 id="install-the-kernel">Install The Kernel</h3>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>dnf <span class="nb">install </span>kernel
dracut <span class="nt">-Nfv</span> <span class="nt">--regenerate-all</span>
</code></pre></div></div>

<h3 id="bootloader-configuration">Bootloader Configuration</h3>

<p>There’s now a bootloader entry at <code class="language-plaintext highlighter-rouge">/boot/loader/entries/${MACHINE_ID}-${KERNEL_VERSION}.conf</code></p>

<p>Edit the options section of this file like below</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>root=UUID=${UUID} ro
</code></pre></div></div>

<p>The root drive’s UUID can be acquired with <code class="language-plaintext highlighter-rouge">blkid</code> tool.</p>

<h3 id="network-configuration">Network Configuration</h3>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>dnf <span class="nb">install </span>NetworkManager NetworkManager-wifi NetworkManager-config-connectivity-fedora
</code></pre></div></div>

<h3 id="services">Services</h3>

<p>I disable some services due to conflicts or them being not necessary</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>systemctl disable systemd-homed systemd-resolved NetworkManager-wait-online
</code></pre></div></div>

<h3 id="shut-down">Shut Down</h3>

<p>Close the chroot with <code class="language-plaintext highlighter-rouge">poweroff</code></p>

<h3 id="add-efi-entry">Add EFI Entry</h3>

<p>Add an EFI entry that points to systemd-boot</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>efibootmgr <span class="nt">-d</span> /dev/sda <span class="nt">-p</span> 1 <span class="nt">-c</span> <span class="nt">-L</span> <span class="s2">"Fedora"</span> <span class="nt">-l</span> /EFI/systemd/systemd-bootx64.efi
</code></pre></div></div>

<h2 id="first-boot">First Boot</h2>

<p>Power off the system, unmount everything, and restart your computer.</p>

<h3 id="connecting-to-network">Connecting to Network</h3>

<p>Connect to a network with Ethernet or WiFi.</p>

<p>To connect to WiFi using <code class="language-plaintext highlighter-rouge">nmcli</code> use the following:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">sudo </span>nmcli device wifi connect <span class="k">${</span><span class="nv">SSID_NAME</span><span class="k">}</span> password <span class="k">${</span><span class="nv">PASSWORD</span><span class="k">}</span>
</code></pre></div></div>

<h3 id="install-some-quality-of-life-packages">Install Some Quality of Life Packages</h3>

<p>These packages are not required but recommended.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>dnf <span class="nb">install </span>rtkit deltarpm zchunk sqlite iputils less bash-completion file rootfiles iproute
</code></pre></div></div>

<h3 id="configuration">Configuration</h3>

<p>Configure keymap, hostname, NTP, and system timezone</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>localectl set-keymap us
hostnamectl set-hostname bardiche
timedatectl set-ntp <span class="nb">true
</span>timedatectl set-timezone Europe/Istanbul
</code></pre></div></div>

<h3 id="selinux-optional">SELinux (Optional)</h3>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>dnf <span class="nb">install </span>policycoreutils selinux-policy-targeted audit
<span class="nb">touch</span> /.autorelabel
reboot
</code></pre></div></div>

<p>This may not work, keep your live usb nearby for failures.</p>

<h3 id="gnome">GNOME</h3>

<p>Fedora Workstation installs the group “Fedora Workstation”, you can list all available groups with <code class="language-plaintext highlighter-rouge">dnf group list</code></p>

<p>Checking what’s in Fedora Workstation</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>dnf groupinfo <span class="s2">"Fedora Workstation"</span>
</code></pre></div></div>

<p>From these subgroups i’ll check what’s in GNOME group</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>dnf groupinfo GNOME
</code></pre></div></div>

<p>From the listed packages i will install some of them:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>dnf <span class="nb">install </span>mesa-dri-drivers mesa-libEGL gdm gnome-shell nautilus kitty gnome-screenshot eog file-roller-nautilus avahi gnome-session-wayland-session gnome-settings-daemon gnome-control-center gnome-tweaks
</code></pre></div></div>

<p>After a reboot, GDM will welcome you.</p>

<h3 id="fractional-scaling">Fractional Scaling</h3>

<p>GNOME supports fractional scaling, my screen is better on 125% so i’ll enable that.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>gsettings <span class="nb">set </span>org.gnome.mutter experimental-features <span class="s2">"['scale-monitor-framebuffer']"</span>
</code></pre></div></div>

<p>Then in settings-&gt;displays i selected 125% Scale factor</p>

<h3 id="rpmfusion">RPMFusion</h3>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">sudo </span>dnf <span class="nb">install </span>https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-<span class="si">$(</span>rpm <span class="nt">-E</span> %fedora<span class="si">)</span>.noarch.rpm https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-<span class="si">$(</span>rpm <span class="nt">-E</span> %fedora<span class="si">)</span>.noarch.rpm
</code></pre></div></div>

<p>You may want to opt out of nonfree repo of rpmfusion.</p>

<h3 id="browser">Browser</h3>

<p>I use <code class="language-plaintext highlighter-rouge">chromium-freeworld</code> package from rpmfusion which includes VAAPI support</p>

<p>Setup VAAPI first</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>dnf <span class="nb">install </span>libva intel-media-driver
vainfo
</code></pre></div></div>

<p>You should see <code class="language-plaintext highlighter-rouge">libva info: va_openDriver() returns 0</code> in the output.</p>

<p>Now install chromium</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>dnf <span class="nb">install </span>chromium-freeworld
</code></pre></div></div>]]></content><author><name>Ahmetcan Güvendiren</name></author><category term="fedora" /><category term="uefi" /><category term="systemd-boot" /><category term="efistub" /><category term="chroot" /><category term="gnome" /><category term="container" /><summary type="html"><![CDATA[Here’s a set of instructions to install fedora on a system the arch way™ with or without dualbooting with windows.]]></summary></entry><entry><title type="html">Deploying a Docker Registry and Cache on Local Network</title><link href="https://glacion.com/2020/02/11/Docker.html" rel="alternate" type="text/html" title="Deploying a Docker Registry and Cache on Local Network" /><published>2020-02-11T19:35:00+00:00</published><updated>2020-02-11T19:35:00+00:00</updated><id>https://glacion.com/2020/02/11/Docker</id><content type="html" xml:base="https://glacion.com/2020/02/11/Docker.html"><![CDATA[<h2 id="prerequisites">Prerequisites</h2>

<ul>
  <li>Local network</li>
  <li>A machine that can run <code class="language-plaintext highlighter-rouge">docker</code> and <code class="language-plaintext highlighter-rouge">docker-compose</code></li>
</ul>

<p>In this guide i will be using a ubuntu 18.04 virtual machine on Virtualbox
connected to the local network via bridged adapter.</p>

<h2 id="preperation">Preperation</h2>

<h3 id="server-installation">Server installation</h3>

<ul>
  <li>Retrieve ubuntu server 18.04 image from <a href="https://ubuntu.com/download/server">here</a>.</li>
  <li>Create a new virtual machine in Virtualbox, set network adapter attached to bridged adapter.</li>
  <li>Install ubuntu server on this virtual machine.</li>
</ul>

<h3 id="networking">Networking</h3>

<p>Install <code class="language-plaintext highlighter-rouge">avahi-daemon</code> via <code class="language-plaintext highlighter-rouge">apt</code>,
this ensures that your virtual machine will show up under the name of <code class="language-plaintext highlighter-rouge">hostname.local</code>,
for this machine, i set the hostname to <code class="language-plaintext highlighter-rouge">ubuntu</code>.
Any instructions below will use this hostname.</p>

<h3 id="docker">Docker</h3>

<p>Follow the
<a href="https://docs.docker.com/install/linux/docker-ce/ubuntu/">official instructions</a>
to install <code class="language-plaintext highlighter-rouge">docker</code> on the server.</p>

<p><strong>Optional:</strong> Add user to <code class="language-plaintext highlighter-rouge">docker</code> group to use docker without root</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">sudo </span>usermod <span class="nt">-aG</span> docker your-user
</code></pre></div></div>

<h3 id="miscellaneous-dependencies">Miscellaneous Dependencies</h3>

<p>Install <code class="language-plaintext highlighter-rouge">docker-compose</code> and <code class="language-plaintext highlighter-rouge">git</code> if not installed.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">sudo </span>apt <span class="nb">install </span>docker-compose git
</code></pre></div></div>

<h2 id="deploying-docker-registry">Deploying Docker Registry</h2>

<ul>
  <li>
    <p>Clone <a href="https://github.com/glacion/lan-docker-registry">this repository</a> from GitHub which includes the required configuration files.</p>

    <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git clone https://github.com/glacion/lan-docker-registry
</code></pre></div>    </div>
  </li>
  <li>
    <p>Go to the fetched directory</p>

    <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">cd </span>lan-docker-registry
</code></pre></div>    </div>
  </li>
  <li>
    <p>Run the server</p>

    <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>docker-compose up <span class="nt">-d</span>
</code></pre></div>    </div>
  </li>
</ul>

<h2 id="testing-the-deployment">Testing The Deployment</h2>

<ul>
  <li>
    <p>Pull the busybox image from the local registry, this will trigger the registry to cache the busybox image.</p>

    <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>docker pull localhost/library/busybox
</code></pre></div>    </div>
  </li>
  <li>
    <p>Acquire the container id of the registry.</p>

    <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>docker ps <span class="nt">--format</span> <span class="s2">"{{ .ID }} {{ .Image }}"</span>
9e898cde9182 registry:2
804903ce9f7e redis:alpine
</code></pre></div>    </div>

    <p>This shows that <code class="language-plaintext highlighter-rouge">9e898cde9182</code> is the container id of my registry container.</p>
  </li>
  <li>
    <p>Check for errors and warnings of the registry.</p>

    <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>docker logs 9e898cde9182 2&gt;&amp;1 | <span class="nb">grep</span> <span class="nt">-E</span> <span class="s2">"level=(warning|error)"</span>
</code></pre></div>    </div>

    <p>Currently, the only output to this should be a warning level log with message</p>

    <pre><code class="language-Text">Registry does not implement RempositoryRemover. Will not be able to delete repos and tags
</code></pre>
  </li>
  <li>
    <p>Remove the busybox image</p>

    <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>docker image <span class="nb">rm </span>localhost/library/busybox
</code></pre></div>    </div>
  </li>
  <li>
    <p>Re-pull the busybox image</p>

    <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>docker pull localhost/library/busybox
</code></pre></div>    </div>
  </li>
  <li>
    <p>Recheck the logs, if there are no new entries, the registry is working correctly.</p>
  </li>
</ul>

<h2 id="client-configuration">Client Configuration</h2>

<p>Clients to this registry must be configured to use the newly created server as proxy.</p>

<ul>
  <li>
    <p>In a <strong>client machine</strong>, edit docker daemon settings.<br />
For a linux client, edit <code class="language-plaintext highlighter-rouge">/etc/docker/daemon.json</code>,<br />
For a mac client, use Preferences -&gt; Docker Engine</p>
  </li>
  <li>
    <p>The file should look like this:</p>

    <div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">{</span><span class="w">
  </span><span class="nl">"registry-mirrors"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
      </span><span class="s2">"http://ubuntu.local"</span><span class="w">
  </span><span class="p">],</span><span class="w">
  </span><span class="nl">"insecure-registries"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
      </span><span class="s2">"ubuntu.local"</span><span class="w">
  </span><span class="p">]</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre></div>    </div>
  </li>
</ul>

<p>Keep any other items as-is.</p>]]></content><author><name>Ahmetcan Güvendiren</name></author><category term="docker" /><category term="cache" /><category term="registry" /><category term="linux" /><summary type="html"><![CDATA[Prerequisites]]></summary></entry><entry><title type="html">Minimal Fedora Installation via Chroot</title><link href="https://glacion.com/2019/06/16/Fedora.html" rel="alternate" type="text/html" title="Minimal Fedora Installation via Chroot" /><published>2019-06-16T19:30:52+00:00</published><updated>2019-06-16T19:30:52+00:00</updated><id>https://glacion.com/2019/06/16/Fedora</id><content type="html" xml:base="https://glacion.com/2019/06/16/Fedora.html"><![CDATA[<h2 id="preperation">Preperation</h2>

<ul>
  <li>Acquire a <a href="https://getfedora.org/en/workstation/download/">Fedora Workstation</a> image.</li>
  <li>Create a bootable USB with that image.</li>
  <li>Open a terminal and acquire root.</li>
  <li>Disable enforcing selinux with <code class="language-plaintext highlighter-rouge">setenforce 0</code>, this is only required for setting the password for the new user that you’ll create.</li>
  <li>Acquire the <code class="language-plaintext highlighter-rouge">genfstab</code> script which makes it easier to create the <code class="language-plaintext highlighter-rouge">/etc/fstab</code>. The script is originally from <a href="https://git.archlinux.org/arch-install-scripts.git">Arch Install Scripts</a>, but for convenience you can acquire it and add executable permission with this command:<br />
<code class="language-plaintext highlighter-rouge">wget https://github.com/glacion/genfstab/releases/download/1.0/genfstab; chmod +x genfstab</code></li>
</ul>

<h2 id="partitioning">Partitioning</h2>

<p>If you are not familiar with partitioning, <a href="https://wiki.archlinux.org/index.php/Partitioning">get comfortable with it</a>.<br />
For reference, these are the partitions i use for testing in a VM with a drive of 12GiB:</p>

<ul>
  <li><code class="language-plaintext highlighter-rouge">/dev/sda1</code> ESP partition of size 100MiB, mounted on <code class="language-plaintext highlighter-rouge">/boot</code>.</li>
  <li><code class="language-plaintext highlighter-rouge">/dev/sda2</code> swap partition of size 1.9GiB.</li>
  <li><code class="language-plaintext highlighter-rouge">/dev/sda3</code> XFS partition of size 10GiB, mounted on <code class="language-plaintext highlighter-rouge">/</code>.</li>
</ul>

<p>I chose <code class="language-plaintext highlighter-rouge">/mnt</code> to be my install root, you may change to your preference but be sure to update the commands accordingly.</p>

<h2 id="installing-the-base-system">Installing The Base System</h2>

<p>Assuming that your partitions are mounted on <code class="language-plaintext highlighter-rouge">/mnt</code>, install the base system like below:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>dnf <span class="nb">install</span> <span class="se">\</span>
<span class="nt">--installroot</span><span class="o">=</span>/mnt <span class="se">\</span>
<span class="nt">--releasever</span><span class="o">=</span>30 <span class="se">\</span>
<span class="nt">--setopt</span><span class="o">=</span><span class="nv">install_weak_deps</span><span class="o">=</span>False <span class="se">\</span>
<span class="nt">--setopt</span><span class="o">=</span><span class="nv">keepcache</span><span class="o">=</span>True <span class="se">\</span>
<span class="nt">--assumeyes</span> <span class="se">\</span>
<span class="nt">--nodocs</span> <span class="se">\</span>
systemd dnf glibc-langpack-en passwd rtkit policycoreutils <span class="se">\</span>
NetworkManager audit firewalld selinux-policy-targeted kbd zchunk <span class="nb">sudo</span> <span class="se">\</span>
vim-minimal systemd-udev rootfiles less iputils deltarpm sqlite lz4 xfsprogs
</code></pre></div></div>

<ul>
  <li><code class="language-plaintext highlighter-rouge">releasever=30</code> Install fedora 30, change if desired.</li>
  <li><code class="language-plaintext highlighter-rouge">setopt=install_weak_deps=False</code> Do not install weak dependencies.</li>
  <li><code class="language-plaintext highlighter-rouge">glibc-langpack-en</code> English langpack for glibc, in order to have a localized system install <code class="language-plaintext highlighter-rouge">glibc-langpack-&lt;LANGCODE&gt;</code> if no langpack is specified to install, dnf will install <code class="language-plaintext highlighter-rouge">glibc-all-langpacks</code> package which costs 100MB alone compared to installing them seperately which costs around 1MB per langpack. Use a different langcode if you want to use a different locale.</li>
  <li><code class="language-plaintext highlighter-rouge">xfsprogs</code> because i used an XFS root, change or add more filesystem tools depending on your setup.</li>
</ul>

<h2 id="configuration">Configuration</h2>

<ul>
  <li>
    <p>Setup machine id and configure the system locale, keymap, hostname on your new system;</p>

    <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>systemd-firstboot <span class="se">\</span>
<span class="nt">--root</span><span class="o">=</span>/mnt <span class="se">\</span>
<span class="nt">--locale</span><span class="o">=</span>C.UTF-8 <span class="se">\</span>
<span class="nt">--keymap</span><span class="o">=</span>us <span class="se">\</span>
<span class="nt">--hostname</span><span class="o">=</span>fedora <span class="se">\</span>
<span class="nt">--setup-machine-id</span>
</code></pre></div>    </div>
  </li>
  <li>
    <p>Generate fstab and save it in your new system, replace <code class="language-plaintext highlighter-rouge">-U</code> with <code class="language-plaintext highlighter-rouge">-L</code> if you want to use labels instead of UUIDs in your <code class="language-plaintext highlighter-rouge">/etc/fstab</code></p>

    <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>./genfstab <span class="nt">-U</span> /mnt <span class="o">&gt;&gt;</span> /mnt/etc/fstab
</code></pre></div>    </div>
  </li>
  <li>
    <p>Chroot without booting and add an user</p>

    <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>systemd-nspawn <span class="nt">-D</span> /mnt
useradd <span class="nt">-c</span> <span class="s2">"&lt;YOUR_FULL_NAME&gt;"</span> <span class="nt">-m</span> <span class="nt">-g</span> <span class="nb">users</span> <span class="nt">-G</span> wheel <span class="nt">-s</span> /bin/bash &lt;YOUR_USERNAME&gt;
passwd &lt;YOUR_USERNAME&gt;
<span class="nb">exit</span>
</code></pre></div>    </div>
  </li>
  <li>
    <p>Boot the system as a container</p>

    <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>systemd-nspawn <span class="nt">-bD</span> /mnt
</code></pre></div>    </div>

    <p>Login with the newly created user and get root with <code class="language-plaintext highlighter-rouge">sudo -s</code>, commands until the <code class="language-plaintext highlighter-rouge">exit</code> will be executed in the container.</p>
  </li>
  <li>
    <p>DNF configuration</p>

    <ul>
      <li>
        <p>Delete unnecessary repositories with <code class="language-plaintext highlighter-rouge">rm -f /mnt/etc/yum.repos.d/*{*cisco*,*testing*,*modular*}*</code></p>
      </li>
      <li>
        <p>Add following options to <code class="language-plaintext highlighter-rouge">/etc/dnf/dnf.conf</code></p>

        <div class="language-ini highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="py">install_weak_deps</span><span class="p">=</span><span class="s">False</span>
<span class="py">keepcache</span><span class="p">=</span><span class="s">True</span>
<span class="py">tsflags</span><span class="p">=</span><span class="s">nodocs</span>
</code></pre></div>        </div>
      </li>
    </ul>
  </li>
  <li>
    <p>Install the bootloader</p>

    <p><code class="language-plaintext highlighter-rouge">systemd-boot</code> is a fairly minimal and gets the job done without much configuration. If you opt to use <code class="language-plaintext highlighter-rouge">GRUB</code> or something similar, you are on your own.</p>

    <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>bootctl <span class="nb">install</span>
</code></pre></div>    </div>
  </li>
  <li>
    <p>Add any required filesystem to <code class="language-plaintext highlighter-rouge">dracut</code> configuration</p>

    <p>Dracut needs to know the root filesystem so that it can mount it when booting, it doesn’t need to know about other filesystems that are in the system. Open <code class="language-plaintext highlighter-rouge">/etc/dracut.conf.d/fs.conf</code> and add the root filesystem like below:</p>

    <div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">filesystems</span><span class="o">+=</span><span class="s">"xfs"</span>
</code></pre></div>    </div>
  </li>
  <li>
    <p>Install the kernel</p>

    <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>dnf <span class="nb">install </span>kernel
</code></pre></div>    </div>
  </li>
  <li>
    <p>Configure the bootloader</p>

    <p>When you installed the kernel, the bootloader created an entry at <code class="language-plaintext highlighter-rouge">/boot/loader/entries/&lt;MACHINE_ID&gt;-&lt;KVER&gt;.conf</code>, however it just copied the boot parameters of the live system.</p>

    <p>The <code class="language-plaintext highlighter-rouge">options</code> part of the file shows something like this:</p>

    <div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>options    BOOT_IMAGE=/images/pxeboot/vmlinuz
root=live:CDLABEL=Fedora-WS-Live-30-1-2 rd.live.image quiet
</code></pre></div>    </div>

    <p>Change it to something like this:</p>

    <div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>options    root=UUID=&lt;UUID_OF_ROOT_PARTITION&gt; ro quiet
</code></pre></div>    </div>

    <p>Add the kernel parameters that you want to include here.</p>
  </li>
  <li>
    <p>Exit the container with <code class="language-plaintext highlighter-rouge">poweroff</code></p>
  </li>
  <li>
    <p>EFI Entry</p>

    <p>Create an EFI entry using <code class="language-plaintext highlighter-rouge">efibootmgr</code> like below.<br />
<strong>Note:</strong> Make sure that the -d and -p arguments point to the ESP of your system.</p>

    <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>efibootmgr <span class="nt">-d</span> /dev/sda <span class="se">\</span>
<span class="nt">-p</span> 1 <span class="se">\</span>
<span class="nt">-c</span> <span class="se">\</span>
<span class="nt">-L</span> <span class="s2">"Fedora"</span> <span class="se">\</span>
<span class="nt">-l</span> /EFI/systemd/systemd-bootx64.efi
</code></pre></div>    </div>
  </li>
  <li>
    <p>Clean up and reboot</p>

    <div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>umount <span class="nt">-R</span> /mnt
reboot
</code></pre></div>    </div>
  </li>
</ul>

<h2 id="tweaks">Tweaks</h2>

<ul>
  <li>
    <p>Dracut</p>

    <ul>
      <li>
        <p>Install binutils with <code class="language-plaintext highlighter-rouge">dnf install binutils</code> so that initramfs can be stripped.</p>
      </li>
      <li>
        <p>Open <code class="language-plaintext highlighter-rouge">/etc/dracut.conf.d/custom.conf</code> and add the lines below:</p>

        <div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code> <span class="n">drivers</span><span class="o">+=</span><span class="s">"i915"</span>
 <span class="n">compress</span><span class="o">=</span><span class="s">"lz4"</span>
 <span class="n">hostonly</span><span class="o">=</span><span class="s">"yes"</span>
</code></pre></div>        </div>

        <ul>
          <li><code class="language-plaintext highlighter-rouge">drivers+="i915"</code> add i915 driver to initramfs for early Kernel Mode Setting.</li>
          <li><code class="language-plaintext highlighter-rouge">compress="lz4"</code> use lz4 for the initramfs compression.</li>
          <li><code class="language-plaintext highlighter-rouge">hostonly="yes"</code> generate images that works with this host only.</li>
        </ul>
      </li>
      <li>
        <p>Rebuild the initramfs with <code class="language-plaintext highlighter-rouge">dracut -fv</code></p>
      </li>
    </ul>
  </li>
  <li>
    <p>Time</p>

    <ul>
      <li>Set the timezone with <code class="language-plaintext highlighter-rouge">timedatectl set-timezone Europe/Istanbul</code></li>
      <li>Enable NTP with <code class="language-plaintext highlighter-rouge">timedatectl set-ntp true</code></li>
    </ul>
  </li>
</ul>]]></content><author><name>Ahmetcan Güvendiren</name></author><category term="fedora" /><category term="uefi" /><category term="systemd-boot" /><category term="efistub" /><category term="chroot" /><summary type="html"><![CDATA[Preperation]]></summary></entry><entry><title type="html">Installing Android SDK Without Android Studio</title><link href="https://glacion.com/2019/04/06/AVD.html" rel="alternate" type="text/html" title="Installing Android SDK Without Android Studio" /><published>2019-04-06T13:12:52+00:00</published><updated>2019-04-06T13:12:52+00:00</updated><id>https://glacion.com/2019/04/06/AVD</id><content type="html" xml:base="https://glacion.com/2019/04/06/AVD.html"><![CDATA[<h2 id="prerequisites">Prerequisites</h2>

<p>You will need a Java 8 executable in your PATH as the <code class="language-plaintext highlighter-rouge">sdkmanager</code> tool is still not compatible with higher Java versions.<br />
More info can be found <a href="https://stackoverflow.com/q/47150410">here.</a></p>

<h2 id="download-android-sdk-command-line-tools">Download Android SDK Command line tools</h2>

<p>Near to the end of the <a href="https://developer.android.com/studio/">Studio</a> page, a section exists under the name of “Command line tools only”, download the Linux tools.</p>

<h2 id="setting-up-the-environment">Setting up the environment</h2>

<p>Add the following environment variables to your <code class="language-plaintext highlighter-rouge">~/.profile</code><br />
More info about these variables can be found <a href="https://developer.android.com/studio/command-line/variables">here.</a></p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">export </span><span class="nv">ANDROID_SDK_ROOT</span><span class="o">=</span><span class="nv">$HOME</span>/.local/opt/android_sdk
<span class="nb">export </span><span class="nv">ANDROID_HOME</span><span class="o">=</span><span class="nv">$ANDROID_SDK_ROOT</span>
<span class="nb">export </span><span class="nv">ANDROID_AVD_HOME</span><span class="o">=</span><span class="nv">$HOME</span>/.local/opt/android_avd
</code></pre></div></div>

<p>Activate changes by running <code class="language-plaintext highlighter-rouge">source ~/.profile</code></p>

<h2 id="extracting-the-command-line-utilities">Extracting the command line utilities</h2>

<p>Extract the downloaded zip file to your <code class="language-plaintext highlighter-rouge">ANDROID_SDK_ROOT</code></p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>unzip ~/Downloads/sdk-tools-linux-4333796.zip <span class="se">\</span>
<span class="nt">-d</span> <span class="nv">$ANDROID_SDK_ROOT</span>
</code></pre></div></div>

<h2 id="installing-the-sdk">Installing the SDK</h2>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ANDROID_SDK_ROOT</span>/tools/bin/sdkmanager <span class="se">\</span>
<span class="s1">'platforms;android-28'</span> <span class="se">\</span>
<span class="s1">'build-tools;28.0.3'</span> <span class="se">\</span>
<span class="s1">'system-images;android-28;google_apis;x86_64'</span> <span class="se">\</span>
<span class="s1">'platform-tools'</span> <span class="se">\</span>
<span class="s1">'ndk-bundle'</span>
</code></pre></div></div>

<ul>
  <li><code class="language-plaintext highlighter-rouge">platforms;android-28</code>: The Android SDK for API 28 (Android 9).</li>
  <li><code class="language-plaintext highlighter-rouge">build-tools;28.0.3</code>: Android SDK Build Tools.</li>
  <li><code class="language-plaintext highlighter-rouge">system-images;android-28;google_apis;x86_64</code>: An Android 9 system image for Android Virtual Device.</li>
  <li><code class="language-plaintext highlighter-rouge">platform-tools</code>: Tools such as <code class="language-plaintext highlighter-rouge">adb</code> and <code class="language-plaintext highlighter-rouge">fastboot</code> (Optional)</li>
  <li><code class="language-plaintext highlighter-rouge">ndk-bundle</code>: Android Native Development Kit (Optional). If this is installed, an additional environment variable <code class="language-plaintext highlighter-rouge">ANDROID_NDK_ROOT</code>, which is typically on <code class="language-plaintext highlighter-rouge">$ANDROID_SDK_ROOT/ndk-bundle</code></li>
</ul>

<h3 id="searching-additional-utilities">Searching Additional Utilities</h3>

<p>To search a newer version of a package or installing a different package, you may search with the following command:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ANDROID_SDK_ROOT</span>/tools/bin/sdkmanager <span class="nt">--list</span> | <span class="nb">grep </span>YOUR_QUERY
</code></pre></div></div>

<h2 id="creating-an-android-virtual-device">Creating an Android Virtual Device</h2>

<p>An AVD can be created with the following command;</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ANDROID_SDK_ROOT</span>/tools/bin/avdmanager create avd <span class="se">\</span>
<span class="nt">-n</span> MyAvd <span class="se">\</span>
<span class="nt">-d</span> <span class="s1">'Nexus 5X'</span> <span class="se">\</span>
<span class="nt">-k</span> <span class="s1">'system-images;android-28;google_apis;x86_64'</span>
</code></pre></div></div>

<ul>
  <li><code class="language-plaintext highlighter-rouge">-n</code>: Specifies the name of the AVD</li>
  <li><code class="language-plaintext highlighter-rouge">-d</code>: Specifies the device definition. Find more definitions by running <code class="language-plaintext highlighter-rouge">$ANDROID_SDK_ROOT/tools/bin/avdmanager list device</code></li>
  <li><code class="language-plaintext highlighter-rouge">-k</code>: Specifies the system image of the AVD. The system image must be installed to be used.</li>
</ul>

<h2 id="starting-the-avd">Starting the AVD</h2>

<p>An AVD can be started with the <code class="language-plaintext highlighter-rouge">emulator</code> utility.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ANDROID_SDK_ROOT</span>/tools/emulator @MyAvd
</code></pre></div></div>

<p>or</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ANDROID_SDK_ROOT</span>/tools/emulator <span class="nt">-avd</span> MyAvd
</code></pre></div></div>

<h2 id="troubleshooting">Troubleshooting</h2>

<h3 id="this-user-doesnt-have-permissions-to-use-kvm-on-debian-based-systems-when-trying-to-run-the-avd-there-are-two-solutions">“This User Doesn’t Have Permissions to Use KVM” on Debian based systems when trying to run the AVD, there are two solutions</h3>

<ul>
  <li>Installing <code class="language-plaintext highlighter-rouge">qemu-kvm</code></li>
</ul>

<figure class="highlight"><pre><code class="language-console" data-lang="console"><span class="go">  sudo apt install qemu-kvm
  sudo usermod -aG kvm USER*NAME</span></code></pre></figure>

<p>Though, since the Android Emulator already packs its own qemu, we can avoid installing <code class="language-plaintext highlighter-rouge">qemu</code> _just* for the permission to use <code class="language-plaintext highlighter-rouge">/dev/kvm</code></p>

<ul>
  <li>Manually taking ownership of <code class="language-plaintext highlighter-rouge">/dev/kvm</code></li>
</ul>

<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="go">sudo groupadd kvm
sudo usermod -aG kvm USER_NAME

</span><span class="gp">#</span><span class="w"> </span>The following must be run each boot,
<span class="go">
</span><span class="gp">#</span><span class="w"> </span>create a service or something similar.
<span class="go">
sudo chgrp kvm /dev/kvm
</span></code></pre></div></div>]]></content><author><name>Ahmetcan Güvendiren</name></author><summary type="html"><![CDATA[Prerequisites]]></summary></entry></feed>