How can I re-mount rootfs in WSL2 ubuntu 18.04? - windows-subsystem-for-linux

I've accidently umounted /dev/sdd which was rootfs ext4 of ubuntu18.04.
I thought it was usb filesystem.
As soon as I umounted it, bash couldn't find any command like ls, cd or something.
So I exited the terminal. After that, I can't get inside again.
What I can do ? Any Suggestion?

Related

Is there an way to make WSL2 mount its folders on another drive outside Windows Preview Build 20211?

I've this SSD drive that I bought only for work so I would like WSL2 to write on it. Found this article which I was following thru, to find out wsl --mount is working on Windows Preview Build 20211, not on my build (Win 10 1909 18363.1110).
Is there an way to do this?
Thanks!
Found out later, with a little change of terms on my research, that it could be done as in this tut here: https://www.sitepoint.com/wsl2/
To make it quick for anyone searching around here, you have to export your Linux image, unregister it from wsl and then import it again on the other drive. How it's done:
List your distros
In a Windows Powershell terminal, enter wsl --list. It should return what distros you have installed and if they're running.
Export your distro
In the same Powershell, enter mkdir D:\backup to make a dir for your backup then export it using wsl --export <distro> D:\backup\<distro>.tar. In my case, wsl --export Ubuntu D:\backup\ubuntu.tar.
Unregister the distro
You have to remove it from the C: drive with wsl --unregister Ubuntu and to make sure it worked, after the process is done list all distros again with wsl --list.
Import the distro on another drive
The syntax for this will be wsl --import <distroName> <target\directory> <origin\image>. So if you'd like to make an directory for your WSL in your new drive, just do mkdir D:\wsl or name it anyway you want. I already have a folder for that, so I went with wsl --import Ubuntu D:\wsl-dev D:\backup\ubuntu.tar.
You can verify if it's done by using the very same wsl --list.
And if you want to change your default user from root, follow below steps.
For Ubuntu 18.04, the command to change default user is
ubuntu1804 config --default-user <username>
Took me a while to figure out. Finally found it thanks to this link

Flatpak Intellij Idea - problem with subversion executable

After installing Intellij Idea using flatpak on Clear Linux I'm not able to make it run svn executable.
I added ---filesystem=host to flatpak permissions and tried to set executable path to /run/host/usr/bin/svn but with no luck (path is available/exists, though Intellij keeps complain)
svn command is normally available from system terminal.
When I try to run /run/host/usr/bin/svn command via Intellij Idea built-in terminal, I've got error that library is not available:
sh-5.0$ /run/host/usr/bin/svn
/run/host/usr/bin/svn: error while loading shared libraries: libsvn_client-1.so.0: cannot open shared object file: No such file or directory
I also tried set flatpak-spawn. Following command works perfectly fine in Intellij Idea built-in terminal:
/usr/bin/flatpak-spawn --host /usr/bin/svn, though when set as path to svn executable still gives me Intellij Idea error:
"The path to Subversion executable is probably wrong"
Could anybody please help with making it work?
TLDR: You probably need to add the path to svn into your IntelliJ terminal Path.
Details:
It looks like you are having a path issue. I had a similar problem running kubectl running PyCharm installed from a flatpak on Pop_Os.
If I try to run kubectl I see the following:
I have kubectl installed in /usr/local/bin. This is a screenshot from my 'normal' terminal.
In the PyCharm terminal this location is mounting under /run/host/usr/local/bin/.
If I look at my path in the PyCharm terminal, it is not there.
So I'll add the /run/host/usr/local/bin/ to my path and I can then run kubectl:
To make sure this comes up all the time, I need to add the PATH to the Terminal settings:
I can now execute any of the commands in my /usr/local/bin dir.
I found a really ugly solution for dealing with SVN with the JetBrains family, which does actually answer the question. But in a very roundabout way. Unfortunately Alex Nelson's solution didn't work for me.
You would think the Flatpak would come with a valid SVN, since it's actually part of the expected requirements for the program...
When in the terminal, you can run
cd ..
/usr/bin/flatpak-spawn --host vim ./svn
Then press i to go into input mode, then paste the following in the opened text file (Basically what it does is create an executable which passes it to the flatpak-spawn invocation):
#!/bin/bash
/usr/bin/flatpak-spawn --host /usr/bin/svn $#
Save and quit from vim (ESC, then :wq!). Make it executable:
chmod +x svn
Then in IntelliJ's menu, set the "path to svn" to
/home/<yourusername>/IdeaProjects/svn
It's worked for everything I've tried... Hope this helps out anyone else who was struggling with this.
I am using a similar solution to caluga.
#!/bin/sh
cd
exec /usr/bin/env -- flatpak-spawn --host /usr/bin/env -- svn "$#"
exec makes it replace the wrapper script process so the wrapper script process can end.
I'm using /bin/sh instead of /bin/bash as bash features are not needed.
using /usr/bin/env, but maybe not necessary if PATH is set up right.
remember to quote "$#" in case there are spaces in arguments.
I am putting it in ~/.local/bin and referencing it with its absolute path in the IntelliJ settings (Settings -> Version Control -> Subversion -> Path to Subversion executable).
I also was running into problems with IntelliJ saying that /app/idea-IC path does not exist. Figured that something outside the flatpak (i.e. svn or env) was trying to change directory to the working directory from where the wrapper script was invoked (inside the flatpak). Using cd allows the wrapper script to change to a directory that exists both inside the flatpak and on the host.
Fedora Silverblue or toolbox users might want to use dev tools inside their toolbox, in which case you can do:
#!/bin/sh
cd
exec /usr/bin/env -- flatpak-spawn --host toolbox run svn "$#"

Can you run gitk over SSH/SCP?

I've started editing files over ssh/scp with vim, and it works pretty good.
So given that this can be done; is there any way to use SSH / SCP to load a remote repository into gitk locally?
I tried gitk scp://root#192.168.XXX.XXX//home/demo but I just end up with a dialog that reads Cannot find a git repository here.
Or you can run the gitk on remote server, if you enable X11 Forwarding, if it is enabled and gitk installed on you server.
ssh -X root#192.168.XXX.XXX "cd /home/demo; gitk"
Even though it is not what you asked, it might help you:
You could simply mount it with sshfs.
sudo sshfs -o allow_other,\
IdentityFile=/home/ysragh/.ssh/id_rsa \
yzzi#wow2d.development.yggdrasil.group:\
/opt/wow2d /home/ysragh/wow2d
And then you can use Vim and/or gitk in your home directory as if you downloaded it :)
I'm doing this like all the time when developing with virtual machine images :)

Can't run tmux in Arch Linux VM

So I have installed tmux in Arch 2016.06.01. I am connected via SSH. When trying to run the program, I get this response:
tmux: invalid LC_ALL, LC,TYPE or LANG
Other programs open fine on this VM. Thanks!
I uncommented my locale in the /etc/locale.gen file and then generated it with locale-gen. Now tmux runs.

Found unknown Linux distribution on /dev/sdb2: grub configuration dual boot Arch Linux and NetBSD-7.0

I have Arch Linux on /dev/sdb1 and NetBSD-7.0 on /dev/sdb2.
On Arch Linux when I run sudo grub-mkconfig -o /boot/grub/grub.cfg I get a message like Found unknown Linux distribution on /dev/sdb2 but when I reboot, there is no grub option for that unknown Linux distribution which I know it is NetBSD-7.0.
How can I add NetBSD-7.0 to my grub menu option when rebooting.
There is a similar post, currently looking into it.
UPDATE: I mounted NetBSD partition with sudo mount -t ufs -o ro,ufstype=ufs2 /dev/sdb2 /mnt/ (ufstype=44bsd did not work) and then ran grub-mkconfig -o /boot/grub/grub.cfg but yet the issue persists.
UPDATE: Rebooted and pressed c to get the grub command line. Following commands booted the NetBSD-7.0:
ls
Ran ls to see the correct name of disks and partitions, /dev/sdb2 on Linux was (hd0,gpt2) on Grub. Then ran the following:
insmod ufs2
set root=(hd0,gpt2)
knetbsd /netbsd
boot
And NetBSD-7.0 booted.
To add NetBSD option to Grub menu, modified file /etc/grub/40_custom on Arch Linux like below:
menuentry "NetBSD-7.0"{
insmod ufs2
set root=(hd0,gpt2)
knetbsd /netbsd
}
However, after modifying 40_custom like above, NetBSD option does not appear on Grub menu. I don't know why.
Unless you have a typo, it looks like the 40_custom file is in the wrong directory. it should be located at /etc/grub.d/40_custom, notice the .d.
If your /boot is located on a separate partition, make sure that it is mounted with mount /boot before generating the grub.cfg. Otherwise your new grub.cfg won't be used.
Check which partition grub is loading the configuration from by running echo ${prefix} within the grub command line. It's possible that grub is loading the configuration from a partition that you don't expect.
Verify that netbsd was added to the config with grep -i netbsd /boot/grub/grub.cfg before rebooting to avoid some frustration after generating grub.cfg