<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Dhananjay Tanpure</title>
    <description>The latest articles on DEV Community by Dhananjay Tanpure (@dtan13).</description>
    <link>https://dev.to/dtan13</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F454471%2F7b12f6b7-3686-443b-89e6-64680d382631.jpeg</url>
      <title>DEV Community: Dhananjay Tanpure</title>
      <link>https://dev.to/dtan13</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dtan13"/>
    <language>en</language>
    <item>
      <title>SSH and GPG Keys With Gitpod</title>
      <dc:creator>Dhananjay Tanpure</dc:creator>
      <pubDate>Mon, 27 Dec 2021 17:29:17 +0000</pubDate>
      <link>https://dev.to/dtan13/ssh-and-gpg-with-gitpod-3nbj</link>
      <guid>https://dev.to/dtan13/ssh-and-gpg-with-gitpod-3nbj</guid>
      <description>&lt;h2&gt;
  
  
  Get Your &lt;strong&gt;.gitconfig&lt;/strong&gt;
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Your Git Config is located at &lt;strong&gt;~/.gitconfig&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Encode the File with base64:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; .gitconfig | &lt;span class="nb"&gt;base64&lt;/span&gt; &lt;span class="nt"&gt;-w&lt;/span&gt; 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;a href="https://gitpod.io/variables"&gt;Create a variable&lt;/a&gt; on gitpod.&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Enter Name &lt;strong&gt;GITCONFIG&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Enter output of previous command as Value.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Add following task to your &lt;strong&gt;.gitpod.yml&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;tasks&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;before&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="s"&gt;[[ ! -z $GITCONFIG  ]] &amp;amp;&amp;amp;&lt;/span&gt;
          &lt;span class="s"&gt;echo $GITCONFIG | base64 -d &amp;gt; ~/.gitconfig &amp;amp;&amp;amp;&lt;/span&gt;
          &lt;span class="s"&gt;chmod 644 ~/.gitconfig&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Make commits GPG-signed
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;To sign commit using GPG you must first add GPG keys to Github and/or Gitlab.&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.github.com/en/authentication/managing-commit-signature-verification"&gt;For Github&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.gitlab.com/ee/user/project/repository/gpg_signed_commits/"&gt;For Gitlab&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Your GPG Keys are stored in &lt;strong&gt;~/.gnupg&lt;/strong&gt; folder. Encode this folder with base64.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;tar&lt;/span&gt; &lt;span class="nt"&gt;-czf&lt;/span&gt; - ~/.gnupg | &lt;span class="nb"&gt;base64&lt;/span&gt; &lt;span class="nt"&gt;-w&lt;/span&gt; 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;a href="https://gitpod.io/variables"&gt;Create a variable&lt;/a&gt; on gitpod.

&lt;ul&gt;
&lt;li&gt;Enter Name &lt;strong&gt;GNUPG&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Enter output of previous command in Value.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Add following task to your &lt;strong&gt;.gitpod.yml&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;tasks&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;before&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="s"&gt;[[ ! -z $GNUPG  ]] &amp;amp;&amp;amp;&lt;/span&gt;
          &lt;span class="s"&gt;cd ~ &amp;amp;&amp;amp;&lt;/span&gt;
          &lt;span class="s"&gt;rm -rf .gnupg &amp;amp;&amp;amp;&lt;/span&gt;
          &lt;span class="s"&gt;echo $GNUPG | base64 -d | tar --no-same-owner -xzf -&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  SSH Github and Gitlab from gitpod
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Add SSH Keys to Github and/or Gitlab

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.github.com/en/authentication/connecting-to-github-with-ssh"&gt;For Github&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.gitlab.com/ee/ssh/"&gt;For Gitlab&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Get your SSH Public Key from &lt;strong&gt;id_rsa.pub&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://gitpod.io/variables"&gt;Create a variable&lt;/a&gt; on gitpod.&lt;/li&gt;
&lt;li&gt;Enter Name &lt;strong&gt;SSH_PUBLIC_KEY&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Paste the contents of file in Value.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Get your SSH Public Key from &lt;strong&gt;id_rsa&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://gitpod.io/variables"&gt;Create a variable&lt;/a&gt; on gitpod.&lt;/li&gt;
&lt;li&gt;Enter Name &lt;strong&gt;SSH_PRIVATE_KEY&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Encode the File &lt;strong&gt;id_rsa&lt;/strong&gt; with base64.
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cat &lt;/span&gt;id_rsa | &lt;span class="nb"&gt;base64&lt;/span&gt; &lt;span class="nt"&gt;-w&lt;/span&gt; 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Paste the output of previous command in Value.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Add Following tasks to your &lt;strong&gt;.gitpod.yml&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;tasks&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;before&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="s"&gt;mkdir -p ~/.ssh &amp;amp;&amp;amp;&lt;/span&gt;
          &lt;span class="s"&gt;[[ ! -z $SSH_PUBLIC_KEY  ]] &amp;amp;&amp;amp;&lt;/span&gt;
          &lt;span class="s"&gt;echo $SSH_PUBLIC_KEY &amp;gt; ~/.ssh/id_rsa.pub &amp;amp;&amp;amp;&lt;/span&gt;
          &lt;span class="s"&gt;chmod 644 ~/.ssh/id_rsa.pub &amp;amp;&amp;amp;&lt;/span&gt;
          &lt;span class="s"&gt;[[ ! -z $SSH_PRIVATE_KEY  ]] &amp;amp;&amp;amp;&lt;/span&gt;
          &lt;span class="s"&gt;echo $SSH_PRIVATE_KEY | base64 -d &amp;gt; ~/.ssh/id_rsa &amp;amp;&amp;amp;&lt;/span&gt;
          &lt;span class="s"&gt;chmod 600 ~/.ssh/id_rsa&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Thank You!
&lt;/h2&gt;

</description>
    </item>
    <item>
      <title>Recovering a Broken Linux Installation With Chroot</title>
      <dc:creator>Dhananjay Tanpure</dc:creator>
      <pubDate>Sun, 24 Oct 2021 04:15:52 +0000</pubDate>
      <link>https://dev.to/dtan13/recovering-a-broken-linux-installation-with-chroot-4lb3</link>
      <guid>https://dev.to/dtan13/recovering-a-broken-linux-installation-with-chroot-4lb3</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Chroot&lt;/strong&gt; is a method of focusing on a part of your filesystem. This changes apparent root directory. Which gives asscess to root filesystem and root access in order to perform various operations on the system.&lt;br&gt;
Some of which include&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Recovering a broken install (Reinstalling the bootloader)&lt;/li&gt;
&lt;li&gt;Upgrading and Downgrading packages&lt;/li&gt;
&lt;li&gt;Resetting a forgotten passsword&lt;/li&gt;
&lt;li&gt;Fix your /etc/fstab&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  Problem
&lt;/h3&gt;

&lt;p&gt;Sometimes in case dual boot, due to a &lt;strong&gt;Windows Update&lt;/strong&gt; or a &lt;strong&gt;BIOS Update&lt;/strong&gt;, It may happen that you are left with the default bios options which has &lt;strong&gt;Legacy Boot&lt;/strong&gt; mode and you only have windows as a option to boot. Or maybe you just deleted your EFI partition somehow!&lt;/p&gt;

&lt;p&gt;In this case the data in our linux partitions is safe but you cant access it directly. In order to gain access to the system you need to resintall GRUB (or more specifically MBR).&lt;/p&gt;
&lt;h2&gt;
  
  
  Procedure
&lt;/h2&gt;

&lt;p&gt;You need to access your broken installation in order to fix it.&lt;/p&gt;
&lt;h3&gt;
  
  
  Boot
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;You need to grab the &lt;strong&gt;Arch Linux ISO&lt;/strong&gt; from &lt;a href="https://archlinux.org/download/"&gt;Website&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Make a bootable USB Drive.&lt;/li&gt;
&lt;li&gt;Make sure to boot into UEFI mode.&lt;/li&gt;
&lt;li&gt;Boot into archlinux.&lt;/li&gt;
&lt;li&gt;Match the architecture of the system you are booted in with the system you wish to enter.&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;uname -r&lt;/code&gt; Most probably this will be&lt;code&gt;x86_64&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ol&gt;
&lt;li&gt;Enable Swap if needed.&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;swapon /path/to/swapfile&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;
  
  
  Mount
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;chroot&lt;/strong&gt; is all about the root file filesystem &lt;code&gt;/&lt;/code&gt;. You need to mount the partition before performing &lt;code&gt;chroot&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Check the location and filetype of the your disk.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;fdisk &lt;span class="nt"&gt;-l&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output in my case is :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Disk /dev/sda: 1.82 TiB, 2000398934016 bytes, 3907029168 sectors
Disk model: ST2000LM007-1R81
Units: sectors of 1 &lt;span class="k"&gt;*&lt;/span&gt; 512 &lt;span class="o"&gt;=&lt;/span&gt; 512 bytes
Sector size &lt;span class="o"&gt;(&lt;/span&gt;logical/physical&lt;span class="o"&gt;)&lt;/span&gt;: 512 bytes / 4096 bytes
I/O size &lt;span class="o"&gt;(&lt;/span&gt;minimum/optimal&lt;span class="o"&gt;)&lt;/span&gt;: 4096 bytes / 4096 bytes
Disklabel &lt;span class="nb"&gt;type&lt;/span&gt;: gpt

Device          Start        End    Sectors   Size Type
/dev/sda1        2048     526335     524288   256M Linux filesystem
/dev/sda2      526336  419956735  419430400   200G Linux filesystem
/dev/sda3   419956736 3277883391 2857926656   1.3T Linux filesystem
/dev/sda4  3277883392 3278088191     204800   100M EFI System
/dev/sda5  3278088192 3278120959      32768    16M Microsoft reserved
/dev/sda6  3278120960 3905969269  627848310 299.4G Microsoft basic data
/dev/sda7  3905970176 3907026943    1056768   516M Windows recovery environment
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In above output :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;/dev/sda2 &lt;span class="c"&gt;#root filesystem(/)&lt;/span&gt;
/dev/sda3 &lt;span class="c"&gt;#home (/home)&lt;/span&gt;
/dev/sda1 &lt;span class="c"&gt;#EFI partition&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To properly mounting these partitions you need to know the type of partition, You can get this using &lt;code&gt;blkid&lt;/code&gt; :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;blkid
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;/dev/sda4: &lt;span class="nv"&gt;UUID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"BEBE-377F"&lt;/span&gt; &lt;span class="nv"&gt;BLOCK_SIZE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"512"&lt;/span&gt; &lt;span class="nv"&gt;TYPE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"vfat"&lt;/span&gt; &lt;span class="nv"&gt;PARTLABEL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"EFI system partition"&lt;/span&gt; &lt;span class="nv"&gt;PARTUUID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"b0ce5bc5-5767-4138-ba63-209fd95abbc7"&lt;/span&gt;
/dev/sda2: &lt;span class="nv"&gt;UUID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"cb2baa0a-3a81-42a1-9670-6060fabaa27f"&lt;/span&gt; &lt;span class="nv"&gt;BLOCK_SIZE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"4096"&lt;/span&gt; &lt;span class="nv"&gt;TYPE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"ext4"&lt;/span&gt; &lt;span class="nv"&gt;PARTUUID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"8b7aaeab-1bcb-cf43-8b5d-785fbc5c63a1"&lt;/span&gt;
/dev/sda7: &lt;span class="nv"&gt;BLOCK_SIZE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"512"&lt;/span&gt; &lt;span class="nv"&gt;UUID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"CAAEBF45AEBF2939"&lt;/span&gt; &lt;span class="nv"&gt;TYPE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"ntfs"&lt;/span&gt; &lt;span class="nv"&gt;PARTUUID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"ecd471f6-cbd4-4a8a-b70c-54070669939c"&lt;/span&gt;
/dev/sda5: &lt;span class="nv"&gt;PARTLABEL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Microsoft reserved partition"&lt;/span&gt; &lt;span class="nv"&gt;PARTUUID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"75d5ffda-1051-47cc-8cba-ae187d2d35d7"&lt;/span&gt;
/dev/sda3: &lt;span class="nv"&gt;UUID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"1fe29b19-feb2-4924-b8ac-91a7e4785e98"&lt;/span&gt; &lt;span class="nv"&gt;BLOCK_SIZE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"4096"&lt;/span&gt; &lt;span class="nv"&gt;TYPE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"ext4"&lt;/span&gt; &lt;span class="nv"&gt;PARTUUID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"f15d44bb-96f9-0d42-a0f8-4109dd5959b0"&lt;/span&gt;
/dev/sda1: &lt;span class="nv"&gt;UUID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"D939-5AD9"&lt;/span&gt; &lt;span class="nv"&gt;BLOCK_SIZE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"512"&lt;/span&gt; &lt;span class="nv"&gt;TYPE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"vfat"&lt;/span&gt; &lt;span class="nv"&gt;PARTUUID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"242f0c5c-5a6c-554c-a2c3-70d6268b835a"&lt;/span&gt;
/dev/sda6: &lt;span class="nv"&gt;BLOCK_SIZE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"512"&lt;/span&gt; &lt;span class="nv"&gt;UUID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"3AAAC0ADAAC066CB"&lt;/span&gt; &lt;span class="nv"&gt;TYPE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"ntfs"&lt;/span&gt; &lt;span class="nv"&gt;PARTLABEL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Basic data partition"&lt;/span&gt; &lt;span class="nv"&gt;PARTUUID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"6cfc75a8-c9ee-4239-8cec-2394c0ec5037"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can get type of partition in &lt;code&gt;TYPE&lt;/code&gt; field.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Now mount your partition accordingly on &lt;code&gt;/mnt&lt;/code&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Most important partition is root &lt;code&gt;/&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Here &lt;code&gt;-t&lt;/code&gt; is the type of filesystem.&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mount &lt;span class="nt"&gt;-t&lt;/span&gt; ext4 /dev/sda2 /mnt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;  Mount &lt;code&gt;/home&lt;/code&gt; if necessary
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mount &lt;span class="nt"&gt;-t&lt;/span&gt; ext4 /dev/sda3 /mnt/home
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;  Mount other required partitions.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;These include virtual filesystems required for chroot to run&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="k"&gt;for &lt;/span&gt;i &lt;span class="k"&gt;in&lt;/span&gt; /dev /dev/pts /proc /sys /run&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do &lt;/span&gt;mount &lt;span class="nt"&gt;-B&lt;/span&gt; &lt;span class="nv"&gt;$i&lt;/span&gt; /mnt&lt;span class="nv"&gt;$i&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;  If you want to update the GRUB, mount &lt;code&gt;/sys/firmware/efi/efivars&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mount -B /sys/firmware/efi/efivars /mnt/sys/firmware/efi/efivars
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;  If you've setup your network and want to use it in the chrooted system, copy over &lt;code&gt;/etc/resolv.conf&lt;/code&gt; so that you'll be able to resolve domain names :&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;cp -L /etc/resolv.conf /mnt/etc/resolv.conf&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;After all required partitions are mounted you are free to chroot into your &lt;code&gt;/mnt&lt;/code&gt; directory.&lt;/p&gt;

&lt;h3&gt;
  
  
  Chroot
&lt;/h3&gt;

&lt;p&gt;Use &lt;code&gt;chroot&lt;/code&gt; command to move into mounted filesystem.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;chroot&lt;/span&gt; /mnt /bin/bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;  If you'll be doing anything with GRUB, you'll need to be sure your &lt;code&gt;/etc/mtab&lt;/code&gt; file is up-to-date :&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;grep -v rootfs /proc/mounts &amp;gt; /etc/mtab&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Work
&lt;/h3&gt;

&lt;p&gt;After a successful &lt;code&gt;chroot&lt;/code&gt;, You get root access on mounted root(&lt;code&gt;/&lt;/code&gt;) filesystem. You are free to do anything you want. Like :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Upgrade and Downgrade packages.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Use your package manager to upgrade or downgrade broken packages.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;  Change a forgotten password.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;You can use &lt;code&gt;passwd &amp;lt;username&amp;gt;&lt;/code&gt; to change the password.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;  Fix your &lt;code&gt;/etc/fstab&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;  Upgrade or Downgrade kernel.&lt;/li&gt;
&lt;li&gt;  Anything you want to do.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Recovering broken installation
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Mount
&lt;/h3&gt;

&lt;p&gt;In order to Reinstall the GRUB you need to mount your EFI partition.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mount &lt;span class="nt"&gt;-t&lt;/span&gt; vfat /dev/sda1 /boot/efi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Run &lt;strong&gt;grub-install&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;grub-install &lt;span class="nt"&gt;--target&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;x86_64-efi &lt;span class="nt"&gt;--efi-directory&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/boot/efi &lt;span class="nt"&gt;--bootloader-id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;arch_grub &lt;span class="nt"&gt;--recheck&lt;/span&gt; &lt;span class="nt"&gt;--force&lt;/span&gt; &lt;span class="nt"&gt;--debug&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After this make sure to unmount your EFI partition.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;umount /boot/efi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Finally
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Unmount
&lt;/h3&gt;

&lt;p&gt;When you are done with your work you can exit &lt;code&gt;chroot&lt;/code&gt; by typing &lt;code&gt;exit&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Now unmount all the partitions you mounted.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;umount &lt;span class="nt"&gt;-R&lt;/span&gt; /mnt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If any error occurs, you can use &lt;code&gt;umount -l&lt;/code&gt; to list all the mounted partitions and unmount remaining partitions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Reboot
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;reboot
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>archlinux</category>
      <category>linux</category>
    </item>
    <item>
      <title>Add Power Off and Reboot to grub menu</title>
      <dc:creator>Dhananjay Tanpure</dc:creator>
      <pubDate>Sun, 17 Oct 2021 04:57:04 +0000</pubDate>
      <link>https://dev.to/dtan13/add-power-off-and-reboot-to-grub-menu-a45</link>
      <guid>https://dev.to/dtan13/add-power-off-and-reboot-to-grub-menu-a45</guid>
      <description>&lt;p&gt;To add &lt;strong&gt;Power Off&lt;/strong&gt; and &lt;strong&gt;Reboot&lt;/strong&gt; options to grub menu, you need to update a file in your grub configuration directory.&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; /etc/grub.d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;h3&gt;
  
  
  Open &lt;code&gt;40_custom&lt;/code&gt; in your favorite editor
&lt;/h3&gt;

&lt;p&gt;For me its &lt;code&gt;micro&lt;/code&gt; :&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;micro 40_custom
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;h3&gt;
  
  
  Add following line at the end of the file
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;
 menuentry &lt;span class="s2"&gt;"Reboot"&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
      reboot
&lt;span class="o"&gt;}&lt;/span&gt;

menuentry &lt;span class="s2"&gt;"Power Off"&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
      halt
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Do not change the &lt;code&gt;exec tail&lt;/code&gt; line in the file&lt;/p&gt;
&lt;/blockquote&gt;



&lt;h3&gt;
  
  
  Update your &lt;code&gt;grub.cfg&lt;/code&gt; file
&lt;/h3&gt;



&lt;ul&gt;
&lt;li&gt;  For Debian based distros
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;update-grub
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;  For Arch based and Other distros
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;grub-mkconfig &lt;span class="nt"&gt;-o&lt;/span&gt; /boot/grub/grub.cfg
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>grublinux</category>
    </item>
  </channel>
</rss>
