Categories
Uncategorized

Slow Linux / Docker VM on Hyper-V

On recent versions of Hyper-V i found that many of my linux VMs (home assistant, docker hosts, etc) were really slow. This came to a head when i had terrible performance of portainer on my docker swarm and containers on the docker swarm were slow.

To cut a long story short the issue is Receive Segment Coalescing (RSC) and thanks to this site i learnt how to fix it.

Ether logon to each hyper-v host or use a remote PS session and issue the following command for the virtual switch the VMs are connected to. In my case the virtual switch is call External:

Set-VMSwitch -Name External -EnableSoftwareRsc $false

Alternatively if you want to do it for the whole hyperv host use:

netsh int tcp set global RSC=Disabled
Categories
Uncategorized

Enable RDP Remotely

Sometimes one forgets to enable RDP before one removed the keyboard and mouse and places the server somewhere else. Here is easiest way to enable it.

Enter-PSSession Server01
netsh firewall set service remotedesktop enable
netsh firewall set service remoteadmin enable

First line makes a remote connection.

Next two lines are executed on the remote machine.

Note: these only work if powershell remoting has been enabled on all servers, by default it is. For windows clients you will need to have run this command first on the remote machine (so you need to do this when you install).

Enable-PSRemoting

For more information see:

Of course if you now have PS remoting working maybe you don’t need RDP 😉

Categories
Linux Windows WSL

Easiest way to bridge WSL (windows subsystem for linux)

Its really hard to use WSL2 like a linux box due to how hard it is to make incoming connections from other machines to your WSL instance.

Well a new an hidden feature in the latest WSL preview fixes that. You will need at least version 0.51.2.0 to implement bridging to the host. Here is how to implement it.

  1. issue the wsl –shutdown command
wsl --shutdown
  1. install a new virtual switch using Hyper-V say wsl-switch
  2. to %userprofile%\.wslconfig add the following (if the file doesn’t exist create it)
[wsl2]
networkingMode=bridged
vmSwitch=wsl-switch

Now when you restart WSL you will have a bridge session. This has also be known to cure some of the weird network issues seen with WSL where network connectivity stops working, no DNS connectivity – without the need for messing with scripts and config files. YMMV

Categories
containers docker Linux

Installing docker on Linux – the easy (and official) way.

**updated 3/14/22 to use docker compose v2**

When i first started to learn how to install docker on raspberry pi, Linux, etc i found many large articles with many steps to tell me how to do it – pages of commands and instructions.

I don’t know why they make it so hard and the ‘received wisdom’ of 5 years ago is still repeated to this day (modern search engines don’t help). I think you will find this simpler, it is the official supported docker way to do this.

Install your preferred linux distro and ssh into it (don’t bother with gui).

For Distros like Debian after you install, login and have root privileges do the following

$ curl -fsSL https://get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh
$ sudo apt-get install docker-compose-plugin
$ sudo service docker start

The great part of doing it this way is you can rerun the script to do updates or even just use apt-update \\ apt-upgrade.,

For OS that doesn’t have python 3 installed by default (for example Raspbian) you need to do a couple of extra steps:

$ curl -fsSL https://get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh
$ sudo usermod -aG docker pi
$ sudo apt-get install docker-compose-plugin

Hope that helps.

Bonus for those who need more of a breadcrumb trail and know how to create VMs but want linux help….

  • Download latest Debian ISO (i prefer full install just incase networking gives you grief)
  • Create VM
    • 200GB
    • 2 CPU
    • 4GB RAM
  • Boot from CD and choose non graphical install of debian with SSH and tools only.
  • Create root and yourusername as prompted
  • Login as root on console, install basics:
    • apt-get update
    • apt-get upgrade
    • apt-get install nano sudo curl
  • Add user to sudo group
    • usermod -aG sudo yourusername
  • Login via SSH as yourusername and sudo every command from this point forward
  • Install docker
    • curl -fsSL https://get.docker.com -o get-docker.sh
    • sudo sh get-docker.sh
    • sudo apt-get install docker-compose
    • sudo service docker start