Skip to content

Instantly share code, notes, and snippets.



Last active Nov 8, 2019
What would you like to do?
Small scripts I use to run IntelliJ IDEA inside of WSL2 with an X11 server

1. Create ramdisk in /etc/fstab:

Open up a shell instance editing /etc/fstab:

$ sudo nano /etc/fstab

Inside the editor, append the following to create a new ramdisk. Adjust the 1024M segment to whatever size you want your ramdisk to be.

tmpfs /tmp/ramdisk tmpfs noexec,defaults,noatime,size=1024M,x-gvfs-show,mode=1777 0 0

Next, initialize the ramdisk by running the following:

$ sudo mount -a

2. Create ramdisk folders for your IntelliJ IDEA install:

Inside a shell instance, type the following:

$ sudo nano /usr/lib/tmpfiles.d/intellij.conf

Inside the new buffer, append the following:

d /tmp/ramdisk/intellij/caches 0777 root root — -
d /tmp/ramdisk/intellij/index 0777 root root — -

3. Symlink the IntelliJ IDEA index/cache folders:

Make sure no instance of IntelliJ IDEA is running when you run these commands

To get the configuration folder for your current install of IntelliJ IDEA, run the following in the shell:

$ cd ~/ &&  ls -la | grep .IntelliJ

Your output should look like the following:

drwxr-xr-x  4 keatonburleson keatonburleson  4096 Nov  7 13:00 .IntelliJIdea2019.2

This lets us know that we have our configuration stored in ~/.IntelliJIdea2019.2

Next, inside the shell, run the following (replacing .IntelliJIdea2019.2 with your version determined above):

$ ln -s /tmp/ramdisk/intellij/caches ~/.IntelliJIdea2019.2/system/caches
$ ln -s /tmp/ramdisk/intellij/index ~/.IntelliJIdea2019.2/system/index 

4. Done!

You should be good to go!

cd ~/
FULL_PATH=$(readlink -f ${INSTALL_DIRS[-1]})
echo "Correcting permissions at '${SYS_PATH}'"
sudo chmod 777 ${CACHES_PATH}
sudo chmod 777 ${INDEX_PATH}
APP_DIR=$(ls -td ~/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/*/ | head -1)
WIN_IP=$(grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' /etc/resolv.conf)
export DISPLAY="${WIN_IP}:0"
trap - SIGINT
exec /bin/bash $IDEA_LAUNCH "$@"
) > /dev/null 2>&1 &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment