Converting a Generation 2 HyperV VM to boot in KVM\Openstack

Brining a HyperV Gen2 VM into Openstack

Convert the vhdx to raw and into ceph
qemu-img convert -f vpc -O raw AC-TS01-C.VHD rbd:volumes/AC-TS01.raw

Attach the old(Existing) disk and the new blank disk to a linux box
Install clonezilla from apt
On the new disk create a new partition(This will be an MBR partition not a GPT partition and is key to being able to boot in KVM)
Clone the Windows volume(Just the big volume, ignore the small piss-ant recovery volumes)
Might then need to mount this volume on a windows box to check the NTFS partition is ok, if it’s not showing a drive letter I had some success with resizing the partition with Easus partition manger, which presumable re-wrote the ntfs partition headers and then the disk appeared in windows
THEN you need to boot the os, it’ll fail

Attach a windows server ISO, boot to recovery(Needs to be the correct OS recovery environment. I tried using a 2016 DVD to recover 2012 R2 and it didn’t work)

bcdboot C:\windows
bcdboot C:\windows /s c: /f ALL



Then reboot and all good
If you haven’t preinstalled virtio might need to boot on sata then install virtio drivers

Running CollectD as a container


FROM ubuntu:18.04
RUN apt update
RUN apt-get --no-install-recommends install collectd -y
RUN apt install -y python-pip
RUN pip install collectd-gnocchi

Running the container

docker run -it --net=host --privileged -v:collectd.conf: /etc/collectd/collectd.conf collectDContainerImage collectd -C /etc/collectd/collectd.conf -f

Run cryptominer while the screen is locked

dbus-monitor --session "type=signal,interface=org.gnome.ScreenSaver" | 
while read MSG; do
LOCK_STAT=`echo $MSG | grep boolean | awk '{print $2}'`
if [[ "$LOCK_STAT" == "true" ]]; then
echo "was locked"
killall ethdcrminer64
screen -d -m /home/user/Downloads/Claymore/ethdcrminer64 -epool -ewal 0xaddresshere/m3 -epsw x -allpools 1 -gser 2 -allcoins exp
echo "was un-locked"
killall ethdcrminer64

Swap space notes

Whats using swap space

for file in /proc/*/status ; do awk '/VmSwap|Name/{printf $2 " " $3}END{ print ""}' $file; done | sort -k 2 -n -r | less

Who is eating all of my RAM?

ps aux --sort=-%mem | head

Where are my swap files

 cat /proc/swaps

How to add more swap space

1. Create empty file:
This file will contain virtual memory contents so make file big enough for your needs. This one will create 1Gb file which means +1Gb swap space for your system:

dd if=/dev/zero of=/media/fasthdd/swapfile.img bs=1024 count=1M

If you want to make 3Gb file then change count value to count=3M. See man dd for more information.

2. Bake swap file:
Following command is going to make “swap filesystem” inside your fresh swap file.

mkswap /media/fasthdd/swapfile.img

3. Bring up on boot:
To make sure that your new swap space is activated while booting up computer you should add it to filesystem configuration file /etc/fstab. Add it to end of file, this is recommended because other filesystems (at least one that contains swap file) must be mounted in read-write mode before we can access any files.

# Add this line to /etc/fstab
/media/fasthdd/swapfile.img swap swap sw 0 0

4. Activate:
You can either reboot your computer or activate new swap file by hand with following command:

swapon /media/fasthdd/swapfile.img

Original articles

Putty SSH settings to stop garbled output

Using ubuntu 18 and tools like glances and iftop would often mangle the output

Changing the default Puttty settings
‘Connection > Data > ‘Terminal-type string’ to ‘putty’ instead of ‘xterm’
and setting your PuTTY settings under Translation and ensure that you have UTF-8 set as the character set then save this as the default profile and enjoy 🙂

Copy files from Andorid phone using ADB – Quicker than MTP

When backing up photos form my Android phone i found that the phone didn’t present as a mass storage device, it would only appear as a MTP\PTP device and the file copy speed was terrible.

So some research led me to using the ADB command, you’ll need to enable USB debugging before this will work.


Find your files

adb shell ls /storage/

Back em up

adb pull /storage/self/primary/DCIM/Camera /home/user/photos/

Exchange Autodiscover with HTTP redirect method

Server 2012 R2
Create a new Website on the CAS “autodiscover-redirect”
create a virtual directory called “autodiscover”
Click the virtual directory then open “Http Redirect
enter the url of the exchange server e.g. “” (Must be HTTPS)
Ensure both “Redirect all requests to excact destination” and “Only redirect requests to content in this directory” are ticked
Test using either or a mobile / outlook client.

Configure MikroTik VPN using Radius and NPS on Windows AD

Configure NPS on a Domain controller:
(Based on Windows Server 2019)
Install NPS Role
open NPS admin console
Select “RADIUS server for Dial-Up or VPN Connections” and click “Configure VPN or Dial-Up
Select “VPN Connections” and click Next
Click “Add” and fill in details as required (IP must be the IP of the router)
Take note of the Shared Secret
Click next on the rest of the screens (add groups as required)

Note: Before users will be able to authenticate using Radius “Allow Access” on the “Dial-in” Tab for the user in AD will need to be selected as “Control Access throught NPS Network Policy” does not work at least for Windows Server 2016 and above.

on the Mikrotik:
Click “Radius” then “+”
Complete the following:
Service: ppp
Domain: domain
Address: IP of NPS Server
Secret: Password defined while setting up NPS
Src Address: The IP of the interface (Must match the IP Specified in while setting up NPS)

Add the following rule in the firewall:
chain: input, Action: Accept, Protocol: TCP, Dst. Port: 1723
chain: input, Action: Accept. Protocol: 47 (gre)