Running graphical Linux apps on Windows with WSL

As you have probably heard by now, Windows now comes with something amazing called WSL - Windows Subsystem for Linux.

WSL allows you to run your favourite CLI tools on a Windows workstation. Install WSL from Windows Store, search for Ubuntu for example. Read more about WSL in here: https://msdn.microsoft.com/en-us/commandline/wsl/about

What WSL does not natively support is running graphical applications, aka. X applications.

Trying will result in: Error: Can't open display.


Luckily there are usually ways to go around official limitations, in this case by installing a 3rd party X server on Windows. One example is VcXsrv which can be downloaded from here: https://sourceforge.net/projects/vcxsrv/

Ensure you have installed/enabled WSL, install VcXsrv and go to your Linux by launching Bash on Ubuntu on Windows. Run the following commands:

 sudo apt install x11-apps
 export DISPLAY=:0

In Fedora you'd use dnf instead of apt, naturally.

Running xeyes should look something like this:


Running Fedora 26 on Azure

Fedora 26 was released earlier this week. I wanted to test how it works on Azure, and since Fedora is not currently available from Azure Marketplace I had to create my own VM image.

Connected to Fedora 26 server running on Azure
Here is a small how to document I wrote during the exercise, feel free to try it out yourself!

Download the installation ISO

I used the Server edition since there's not much use for the graphical tools on Azure.

Create a local VM

I used a Windows 10 laptop running Hyper-V to create a local VM with the following details:

  • generation 1 VM type (Hyper-V specific)
  • 8GB disk (note: larger the file longer it takes to upload to Azure!)
  • 1024 RAM startup memory (depending on your laptop's RAM size)

NOTE! do not make snapshots/checkpoints during VM creation. Otherwise exporting the image becomes difficult at least in Hyper-V.

Fedora 26 installation

  • Standard partition (not LVM since Azure can't handle LVM booting well currently)
  • XFS filesystem
  • remove swap (Azure will add it later automatically)
  • add only root password, no users

After installation is complete turn off the VM and remove the installation DVD ISO drive if needed.

Modify the VM

Linux VMs need to be modified a bit to be Azure compatible.

Start your new Fedora VM, log in and verify your networking works at this point:
 ip addr show

Update the system:
 dnf -y update

Edit network configuration to disallow Network Manager to mangle with the main interface:

# add/edit these lines, remove all others including IPv6:

Turn of static udev rules for network devices, could break when cloning VMs:
 ln -s /dev/null /etc/udev/rules.d/75-persistent-net-generator.rules

Ensure networking is started on boot:
 systemctl enable network

Reboot and verify you still get an IP address. Much easier to fix at this point if you broke something.

Modify some boot options. Note the two console= parameters to allow messages also on local console for debugging, remove other parameters if needed)

 GRUB_CMDLINE_LINUX="rootdelay=300 console=tty0 console=ttyS0 earlyprintk=ttyS0 net.ifnames=0"

Generate new grub files:
 grub2-mkconfig -o /boot/grub2/grub.cfg

Ensure the Hyper-V drivers are included in the image:
 add_drivers+=" hv_vmbus "
 add_drivers+=" hv_netvsc "
 add_drivers+=" hv_storvsc "

 dracut –f -v

Install Azure Linux Agent from Fedora repository:
 dnf -y install WALinuxAgent python
 systemctl enable waagent
 dnf clean all


Apply the Azure agent settings:
 waagent -force -deprovision
 export HISTSIZE=0

On your virtualization manager convert the disk to .vhd + fixed size file fedora26.vhd. The exact procedure depends on your hypervisor technology.

Create managed disk and VM

Upload the fedora26.vhd to Azure as "page blob" via Azure cli or portal. In this example I used "rg1" and "container1".

Create a managed disk, using Azure CLI 2.0 in this example:
 az disk create --resource-group rg1 --name fedora26managed --source https://username.blob.core.windows.net/container1/fedora26.vhd

Verify its really there:
 az disk list -g resourcegroup1 --output=table

Create your vm with 5GB (or more) additional data disk:
 az vm create --resource-group rg1 --location westeurope --name fedora26 --os-type linux \
 --admin-username username --ssh-key-value ~/.ssh/id_rsa.pub --attach-os-disk fedora26managed \
 --size Standard_DS1 --data-disk-sizes-gb 5

At this point your new Fedora 26 server VM should be created, up and running happily.

Azure portal

 Disclaimer: I work for Microsoft as Cloud Solution Architect since 2017/06.


Resize Linux VM system disk on Azure

So you have created a Linux VM in Azure with too small disk? Resizing the disk is possible, but requires couple of steps which I will describe here.

My resource group is named "group1" and the VM is named "rhel7a". The Linux VM I used is a RHEL, but the commands are applicable for at least CentOS and Fedora as well.

Running Azure CLI 2.0 on your laptop (or management server):
First step is the enlarge the device on Azure.

Turn off your VM by stopping it, otherwise it's not possible to modify the disk:
# az vm stop --resource-group group1 --name rhel7a

Deallocate the VM:
# az vm deallocate --resource-group group1 --name rhel7a
Check your VM disk name and expand it to for example 40GB:
# az disk list -g group1 --output table

# az disk update --resource-group group1 --name rhel7a_disk1_30de1433bf824608b0c3ee6c8b2b52a0 --size-gb 40

Start the VM:
# az vm start --resource-group group1 --name rhel7a

Now login and continue inside the VM:
# ssh username@13.95.xx.xx

This part happens inside the Linux VM:

First we will make expand the partition and check the disk name you are about to modify:

# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2        19G  1.4G   16G   4% /
devtmpfs        1.7G     0  1.7G   0% /dev
tmpfs           1.7G     0  1.7G   0% /dev/shm
tmpfs           1.7G  8.3M  1.7G   1% /run
tmpfs           1.7G     0  1.7G   0% /sys/fs/cgroup
/dev/sda1       976M  140M  769M  16% /boot
/dev/sdb1       6.8G  2.1G  4.4G  32% /mnt/resource
tmpfs           345M     0  345M   0% /run/user/1000

Modify the partition by deleting and re-creating it. Data will not be lost:

# fdisk /dev/sda
Command (m for help): p
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200    83875364    40888082+  83  Linux

Command (m for help): d
Partition number (1,2, default 2): 2

Partition 2 is deleted

Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): p
Partition number (2-4, default 2): 2
First sector (2099200-83886079, default 2099200): (press enter here)
Using default value 2099200
Last sector, +sectors or +size{K,M,G} (2099200-83886079, default 83886079): (press enter here)
Using default value 83886079
Partition 2 of type Linux and of size 40 GiB is set

Command (m for help): p

At this point you'll need to reboot the server:
# reboot

Now log in again with ssh and continue by resizing the ext4 filesystem:
# resize2fs /dev/sda2
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/sda2 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 5
The filesystem on /dev/sda2 is now 10222020 blocks long.

For xfs filesystem you can do: xfs_growfs -d /dev/sda2

Verify the filesystem is seen at correct size:

# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2        39G  1.4G   36G   4% /
devtmpfs        1.7G     0  1.7G   0% /dev
tmpfs           1.7G     0  1.7G   0% /dev/shm
tmpfs           1.7G  8.3M  1.7G   1% /run
tmpfs           1.7G     0  1.7G   0% /sys/fs/cgroup
/dev/sda1       976M  140M  769M  16% /boot
/dev/sdb1       6.8G  2.1G  4.4G  32% /mnt/resource
tmpfs           345M     0  345M   0% /run/user/1000

And we are ready!


Prepare your laptop for OpenShift - Local DNS resolver settings

I wanted to setup OpenShift demo on my laptop running on a virtual machine, running on IP with Virtual Machine Manager.

OpenShift requires you to have a working DNS with wild card resolver, for example *.openshift.example.com should resolve to the IP address of the VM.

Usually you would insert required IP addresses to /etc/hosts -file, but it doesn't support wildcards.

This is where dnsmasq comes very handy, it's a simple local DNS server which can be easily configured for this kind of setup. The trick here is that dnsmasq and NetworkManager overwriting your /etc/hosts -file will cause some funny side effects every time you reconnect to a network.

Luckily NetworkManager nowadays supports dnsmasq, but needs some manual configuration in order to work perfectly for this use case:

edit file:
with lines similar to this:

As we are replacing the normal dnsmasq configuration, it's important to bind to the network interface(s) needed by libvirt, and also to provide dhcp server to your VMs.

edit file:

and add dns and dhcp lines, do not touch the plugins line:
 plugins=ifcfg-rh,ibft   # note that this is Fedora-specific line

Make sure the dnsmasq service is disable because NetworkManager will start it automatically. If it's enabled you will have problems.
 systemctl disable dnsmasq
 systemctl stop dnsmasq

That's it, you are now ready to test everyting.
 systemctl restart NetworkManager

Everything should work now. If you look into /etc/resolve it should have only local host as nameserver:
 # Generated by NetworkManager
 search redhat.com

And ensure your wildcard resolver works also:
 host testing.openshift.example.com
 testing.openshift.example.com has address

Even when switching wlan networks and connecting to VPN networks the resolver should work.

With this configuration dnsmasq will use the DHCP discovered DNS servers which NetworkManager gives it at the time of connection.


Silence of the lambs - How to prepare for an open office with technology

While preparing for office relocation it occurred to me that working in an open office would be quite different from my current working environment. Last years I've been working in semi-silent shared room for four persons, with ability to close the door if the person next door was having a marathon conference call on a speaker phone.

In the new open office there are no doors to close, so alternative solutions needed to be found.

The new office will have a fitted carpet which should reduce unnecessary sounds, but wouldn't eliminate the typical human habit of speaking or yelling too loudly across the room.

My initial plan is to not install any speakerphones on the desks. People would need to take the calls on their mobiles which hopefully will reduce the length of the calls. Alternatively headsets should be used when attending conference calls. For larger groups attending conference calls there are meeting rooms available, reducing the noise in the open office.

Finally there's the solution provided by powerful but yet small sized computer: noise-cancelling headset.

Several of my colleagues around the world recommended purchasing Bose QuietComfort 25 headset with noise-cancelling functionality. After trying them for couple of hours I wished the company would allow me to expense them because they are good. 

They are so good that despite the hefty ~290€ retail price in Finland, I ended up paying them from my own pocket as the noise-cancelling feature is very useful when flying.

I do travel a lot between Europe and Asia, enjoying good sound or lack of any sound is probably the best thing one can hope for from a long 10-hour flight.

QC25 comes with a handy hard case which protects the headset from damages during travels. Included in the retail case is also an airplane adapter needed on some older planes.

The headset had two models for sale, depending on if you wanted a remote for iPhone and Android phone. The remote with a microphone is attached on the headset's cable.

I'll update the review later after using the headset for some time, but the initial impression is very good.

The headset sits tight but not too tight on my head, and the sound quality is OK. Due to the noise-cancelling technology there is little noise to be heard if you don't play any music, but I assume it can't be heard if the background is more noisy than my living room during a night.

Some reviewers have experienced malfunction of one of the speakers after one year, I hope my unit isn't one of those "Monday" pieces.