<?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>Forem: Matej Bunček 🤔</title>
    <description>The latest articles on Forem by Matej Bunček 🤔 (@themartes_).</description>
    <link>https://forem.com/themartes_</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%2F146756%2F6f473b4a-66cb-48b0-9844-86a04ba4c015.jpg</url>
      <title>Forem: Matej Bunček 🤔</title>
      <link>https://forem.com/themartes_</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/themartes_"/>
    <language>en</language>
    <item>
      <title>How to make WSL2 even faster, with fast git</title>
      <dc:creator>Matej Bunček 🤔</dc:creator>
      <pubDate>Fri, 08 May 2020 13:10:51 +0000</pubDate>
      <link>https://forem.com/themartes_/how-to-make-wsl2-even-faster-with-fast-git-28p8</link>
      <guid>https://forem.com/themartes_/how-to-make-wsl2-even-faster-with-fast-git-28p8</guid>
      <description>&lt;p&gt;So Windows 2004 update is here, and I was really excited about this update. Because it brings WSL2 as a production-ready product to our daily drivers. With all the excitement I downloaded it, and when I did &lt;code&gt;cd&lt;/code&gt; into my project I quickly realized that something is wrong. Git performance was really, really slow.&lt;/p&gt;

&lt;p&gt;So I started searching around web and I discovered &lt;a href="https://github.com/microsoft/WSL/issues/4197"&gt;this issue&lt;/a&gt; and it seems like this issue in only appearing in the &lt;code&gt;/mnt&lt;/code&gt; directory. Sadly the only workaround I found was to move your projects into the WSL filesystem. But I knew I want something more pleasing. So I created a Symlink for it. Now, this took me a great 6 hours, to figure out all the things you need to do, so if you're stuck on the same issue, I hope my guide will help.&lt;/p&gt;

&lt;h1&gt;
  
  
  1. Create a script 📖
&lt;/h1&gt;

&lt;p&gt;You need to create a batch script that will take care of the symlink. Unfortunately, you can't do a symlink from WSL to windows, which is my plan. Create a symlink from &lt;code&gt;$HOME/Code&lt;/code&gt; to your User Directory. So you can start up CMD/PowerShell/Bash/WSL and &lt;code&gt;cd&lt;/code&gt; right into code directory. &lt;/p&gt;

&lt;p&gt;Open up notepad and paste the following lines in here. Make sure you'll change you usernames&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight batchfile"&gt;&lt;code&gt;@echo &lt;span class="na"&gt;off&lt;/span&gt;
&lt;span class="kd"&gt;START&lt;/span&gt; &lt;span class="na"&gt;/B &lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt; &lt;span class="nb"&gt;pushd&lt;/span&gt; \\wsl$\&amp;lt;Your &lt;span class="kd"&gt;WSL&lt;/span&gt; &lt;span class="kd"&gt;Version&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;\
&lt;span class="nb"&gt;rmdir&lt;/span&gt; &lt;span class="kd"&gt;C&lt;/span&gt;:\Users\&amp;lt;Your &lt;span class="kd"&gt;Windows&lt;/span&gt; &lt;span class="kd"&gt;Username&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;\Code &lt;span class="na"&gt;/s /q
&lt;/span&gt;&lt;span class="nb"&gt;mklink&lt;/span&gt; &lt;span class="na"&gt;/d &lt;/span&gt;&lt;span class="kd"&gt;C&lt;/span&gt;:\Users\&amp;lt;Your &lt;span class="kd"&gt;Windows&lt;/span&gt; &lt;span class="kd"&gt;Username&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;\Code &lt;span class="kd"&gt;Z&lt;/span&gt;:\home\&amp;lt;Your &lt;span class="kd"&gt;WSL&lt;/span&gt; &lt;span class="kd"&gt;Username&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;\Code
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;em&gt;But how should I get my WSL version?&lt;/em&gt;
&lt;/h3&gt;

&lt;p&gt;Well, it's fairly easy. Just open up your WSL, type &lt;code&gt;cd $HOME&lt;/code&gt; and then &lt;code&gt;explorer.exe .&lt;/code&gt;. In the location bar type cmd like so&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vTVIthut--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9rh1q9zrdfgj50i3xvjw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vTVIthut--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9rh1q9zrdfgj50i3xvjw.png" alt="Cmd in adress bar"&gt;&lt;/a&gt;&lt;br&gt;
This will open WSL Filesystem in Windows explorer. Now click on the adress bar again and you should see something like this &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--p4k7qh2d--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/tdn5r5cau5381wz17xic.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--p4k7qh2d--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/tdn5r5cau5381wz17xic.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
The part that we need is that &lt;code&gt;Ubuntu-20.04&lt;/code&gt; in my case but that could be &lt;code&gt;fedora&lt;/code&gt; or &lt;code&gt;alpine&lt;/code&gt; or &lt;code&gt;Ubuntu&lt;/code&gt; in your case.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;em&gt;What this script does?&lt;/em&gt;
&lt;/h3&gt;

&lt;p&gt;Basically it will just mount your WSL as a network drive, and then it will create Windows Symlink, which will work in both Windows and WSL. Unlike the WSL symlinks which work only in WSL.&lt;/p&gt;

&lt;p&gt;When we have our script done go to &lt;strong&gt;File &amp;gt; Save as&lt;/strong&gt;, and then choose a location where you know that your script will be safe, so you don't accidentally delete it, and name it &lt;code&gt;mount_wsl.bat&lt;/code&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  2. Create a schedules task with highest privileges ⏱
&lt;/h1&gt;

&lt;p&gt;Now when we have our script we need to run it every time we boot into our machine. We also need to do that with the highest privileges because you need to be an admin to make a symlink from network drive to your base drive. &lt;/p&gt;

&lt;p&gt;So go ahead and search for &lt;em&gt;Task Scheduler&lt;/em&gt;. On the &lt;strong&gt;left sidebar&lt;/strong&gt; you will see &lt;strong&gt;Task Scheduler Library&lt;/strong&gt;. Click on it and on the &lt;strong&gt;right sidebar&lt;/strong&gt; click on &lt;strong&gt;Create Task...&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Now make sure you'll give a name to your task, then write a little description and &lt;strong&gt;Check "Run with highest privileges"&lt;/strong&gt;. Also make sure you'll change &lt;strong&gt;Configure for:&lt;/strong&gt; To Windows10&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YPvHwMU6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/uj70giy97y3ulcbie8k5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YPvHwMU6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/uj70giy97y3ulcbie8k5.png" alt="Win10 Scheduler"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next click on &lt;strong&gt;Triggers&lt;/strong&gt; tab and add new trigger. This will look fairly simple, Just make sure it's like this, and click OK.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--t77UwRev--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/08qjcabpopaopkx7ysuo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--t77UwRev--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/08qjcabpopaopkx7ysuo.png" alt="Triggers tab"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next click on Actions add New and Select the &lt;code&gt;.bat&lt;/code&gt; script we created earlier. &lt;/p&gt;

&lt;h1&gt;
  
  
  3. Profit 🤑
&lt;/h1&gt;

&lt;p&gt;Now when we restart our computer the network drive will be available in "This PC" and Code directory symlink to WSL will be in your User Directory. With significantly faster I/O Operations and git. Enjoy ✌&lt;/p&gt;

</description>
      <category>wsl2</category>
      <category>git</category>
      <category>windows</category>
    </item>
  </channel>
</rss>
