štvrtok 21. novembra 2019

Improving visibility of multiple hard-links of the same file

Command below color-differentiate files (in current working directory) having 2 to 9 hard-links (in whole filesystem) and prefixing all files (in current working directory) with command for finding all directory entries for particular inode.

Tested on WSL / Ubuntu 18.04:

ls -dali --time-style +"%Y-%m-%d %H:%M" * .* | sed 's/^/sudo find \/ 2> \/dev\/null -inum /g' | grep -e "[-xtTsS] [234567890] " -e ""

alias lnshow='ls -dali --time-style +"%Y-%m-%d %H:%M" * .* | sed "s/^/sudo find \/ 2> \/dev\/null -inum /g" | grep -e "[-xtTsS] [234567890] " -e ""'

echo "alias lnshow='ls -dali --time-style +\"%Y-%m-%d %H:%M\" * .* | sed \"s/^/sudo find \/ 2> \/dev\/null -inum /g\" | grep -e \"[-xtTsS] [234567890] \" -e \"\"'" >> ~/.profile

lnshow

streda 6. novembra 2019

Speeding up filesystem search indexing in WSL by keeping unnecessary drives unmounted

The Problem

Indexing search for locate was very slow, sometimes maybe infinetely. Idexing was starting up by sudo updatedb, but not finishing.

The Hypothesis

As seen via mount command in WSL, there were mounted several drives slowing down indexing search for locate:
  • C: (default system drive of Windows host) - needed sometimes
  • G: (drive from Google Drive File Stream) - however, not working correctly
  • multiple (?) N: drives (resulted from these last month experiments) - not needed already
I wanted to unmount and keep them unmounted.

The Solution

The /etc/wsl.conf was not existing initially in WSL (ls -al /etc/wsl.conf), so created it this way

sudo bash -c "echo [automount] >> /etc/wsl.conf"
sudo bash -c "echo enabled=false >> /etc/wsl.conf"

Restart WSL instance via Windows command-prompt (cmd.exe):

wsl --list --running
wsl --terminate "Ubuntu-18.04"ubuntu1804

Now we see in WSL via mount, that those Windows drives in WSL are not mounted, and sudo updatedb is remarkably faster.

Drives can be mounted and unmounted on demand - example:

sudo mount -t drvfs C: /mnt/c
sudo umount /mnt/c

More information about wsl.conf: https://devblogs.microsoft.com/commandline/automatically-configuring-wsl/.