Multipass on Mac

Multipass from Canonical is a tool for quickly deploying VM’s (running Ubuntu) on the native Hypervisor, the VM also has a kernel optimized for the Hypervisor.

Pros and Cons

  • Rapid provisioning with cloud-init
  • Better performance than Virtualbox
  • Difficult networking options (no bridge, no secondary network cards, no secondary IP addresses that work (some workarounds later)

First the basics

Create machines

$ multipass launch --name machine1 -d 8G -m 4192M -c 4
$ multipass launch --name machine2 -d 8G -m 1024M -c 1

Shell

$ multipass exec machine1 -- bash

List Machines

$ multipass list
Name              State             IPv4             Image
machine1          Running           192.168.64.2   Ubuntu 18.04 LTS
machine2          Running           192.168.64.3   Ubuntu 18.04 LTS

Problems with networking

Some things just don’t work very well. For example, using cloud-init to set a fixed IP address. The machine will ignore this and acquire a dhcp address from they hypervisor/bootp. Adding a second nic is not possible. Adding a second IP to the existing nic is possible but it will have limited functionality. Manually changing the IP will cause the multipass cmd to get disconnected from the VM making it hard to delete the VM or get a shell on it.

Workaround for static address on Mac

On your Mac after you have created a machine you will have a file called /var/db/dhcpd_leases this is where the machine gets its address from. Edit this file and assign the addresses you want (you must keep 192.168.). Restart your VM’s and they will be dynamically be assigned your static address.

sudo vi /var/db/dhcpd_leases
{
        name=machine2
        ip_address=192.168.64.102
        hw_address=1,aa:74:48:50:b9:b9
        identifier=1,aa:74:48:50:b9:b9
        lease=0x5e7b72c5
}
{
        name=machine1
        ip_address=192.168.64.101
        hw_address=1,56:2:58:38:b1:7d
        identifier=1,56:2:58:38:b1:7d
        lease=0x5e7b72c4
}

$ multipass list
Name              State             IPv4             Image
machine1          Running           192.168.64.101   Ubuntu 18.04 LTS
machine2          Running           192.168.64.102   Ubuntu 18.04 LTS

Other issues

DNS resolution becomes difficult if you use a VPN, but at least using the above and a hosts file you should be able to get by.

Tips for Fedora 28 on Digital Ocean

I’m moving again, from an Ubuntu 16.04 droplet with a rather complex deployment (in Brexit-land) to Docker containers on a Fedora 28 droplet (in Europe-land).

These are some tips I wanted to share along the way. But First..

$100 Free Credit on Digital Ocean

Now that’s out of the way lets talk about our new droplet. Its a $5 per month beast with 1 vCPU a whole 1 Gigabyte of RAM, 25 Gigs of SSD storage for the OS drive. I also added another 20 Gigs of block storage for Nextcloud.

Tip 1: Create a swap file

Performance on this droplet was great, until the memory usage climbed above 60%, then the performance was far from ideal. Sometimes fast, sometimes slow, occasionally stuttering.

Fedora has its swappiness set to 60%. This means when RAM is consumed above 60% the kernel should try and move some data out to swap. The problem is by default the droplet has no swap enabled. You could change the swappiness value to 1% if you wanted, but what happens when you do run out of RAM? Yea the kernel will kill a random process that is consuming RAM (in my case it likes to go for my database more often than not).

Instead I suggest to create, enable and mount on boot a swapfile:

# dd if=/dev/zero of=/swap bs=1024 count=1048576
# chown root:root /swap
# chmod 0600 /swap
# mkswap /swap
# swapon /swap
# echo "/swap none swap sw 0 0" >> /etc/fstab

This will stabilize our performance and if we do consume too much RAM, things will slow down, but continue to run.

Tip 2: Install Cockpit

Cockpit is a nice web based admin console. You can install it with
# dnf install cockpit

Once you have enable the socket and opened the firewall you will be able to log into your server on port 9090 using your local Linux account. This will be helpful later if you install Docker, or wish to troubleshoot SELinux issues.

It also has a built in terminal so if you disable ssh access or it is blocked for some reason (some public WiFi does this) then you can still manage your server.

Tip 3: Put SELinux in permissive mode while you deploy your apps

SELinux is helpful in production, but can be a right pain during development. Placing SELinux in permissive mode will allow you to work as if it was disabled, however you can open the SELinux panel in Cockpit and view both the rules that would be broken and how to allow the required access.

Once you’ve applied all the rules you can safely put SELinux in enforcing mode knowing it won’t break anything.

2 Weeks with a Macbook Pro 2017 in New York

Things change

Since I last posted, I’ve left my job of 17 years and started a new adventure with MongoDB.  My daily work machine  is no longer a Dell Latitude running Windows 10, but a 2017 Macbook Pro 15.  I still have my personal Dell XPS 13 happily running Solus and Windows 10, but how does the Mac stand up.

Transition

Moving from Windows to Mac OS would be a big leap, but moving from Gnome 3 to Mac OS is not a challenge at all.  Some of the keyboard shortcuts are different, some of the touch pad gestures are different, but essentially most things work just about the same.  That’s a very good thing.

Software Differences

Not having a package manager and having to go to websites and download things was a bit of a pain but easily solved by installing brew.  Windows not snapping to screen edges has been annoying me for some time, but I’m sure that can be solved.  Hitting X to close a window but instead the app minimizes to the dock and resets is actually closing confusing me daily.

The amount of times I’ve x’ed my web browser, then clicked it again a few minutes later expecting it to reload my tabs from the previous session, but instead being greeted with a fresh browser with no tabs.  So I mentally have to tell myself to do Command+Option+Q if I want to close something.

Hardware Differences

CPU/Memory and disk speed are as near as makes no difference.  I’m not going to complain about only having USB-C ports, I have one dongle with HDMI/USB-A and that’s enough.  My laptop is not connected to anything with a cable long enough for it to be a problem.

The keyboard is shocking.  I’ve tried really hard to get along with it, but it just slows you down constantly.  I used it for 2 weeks exclusively while in New York without touching another computer or external keyboard and still don’t like it.  I hope that changes soon as I type a lot.

Fingerprint sensor is great.  So quick and easy to unlock the machine when you have a complex password.

Touchpad is supposed to be amazing, buts its just average to me, nothing special.

Conclusion

You can get work done on this machine, you can install everything you need and get focused on the task at hand.  It would not be my first choice, but if your employer hands you one you’ll be very happy with it.  Just try get a Magic Keyboard/Mouse also.  Given the choice I’d go with a XPS 15 Developer Edition, but the difference is almost insignificant.

 

Solus Linux (and Windows) on Dell XPS 13 – 9360 Kaby Lake

Time to put Linux on my XPS 13.

Pick a distro, any distro.

Historically I’m an Arch Linux user and what is not to like about a rolling distribution with good software availability.   No reinstall’s every few months. I’ve tried Fedora 24 Live on this machine and it worked just fine but didn’t have some software I want/need.  I’m not a fan of Ubuntu or re-spins of Ubuntu.

I decided to give Solus gnome a go.  I like the fact that its also a rolling distro with a reasonably up to date kernel based on the latest LTS kernel.  I’ve heard good things about its updates and dual boot support on UEFI hardware.  As far as the software I need, well that’s an unknown as I start installing.

Windows Technical Debt

My existing Windows 10 install was not shrinkable despite only 100 of the available 512 Gigabytes of the disk being used.  I was looking at either deletion of the recovery partitions and trying to squeeze Solus into that space or a full re-install.

First I went into the UEFI with F2 and disabled secure boot.  Then changed the disk controller mode from RAID to AHCI.  This makes the existing windows install unusable as the factory enabled Bit-Locker encryption freaks out from the lack of secure boot.  Instructions to decrypt the drive are all you will see when you boot.  As I’ve already given up on this Windows install I decided to just wipe the drive.

Install Windows

We will install Windows 10 first, but we will boot the Solus installer first.  When the Solus Live environment was running I opened GParted and deleted all the existing partitions on the XPS 13’s internal NVMe drive.  Next boot windows and create one partition (I went with 200 Gigs) This will actually create a few partitions within that space.  Continue the Windows 10 install until finished.

Install Solus

Boot the Solus install media and again open GParted, create your swap partition (I have 16 Gigs of ram and made swap the same size).  Your root partition (around 200 Gig) and most importantly a 512MB partition as per the instructions here.

Booting each OS

My system was set to default boot windows in the UEFI.  Pressing F12 will present you with a boot menu where you can pick which loader to use.  I went into F2 and put Linux Loader as the default.  The boot menu provided by Solus didn’t add the option to boot Windows.  I’ll add that manually later, but for now I just have to press F12 any time I want to boot into Windows.

Software

This was the bit I was most worried about, but turned out to be easy.  Open gnome software center.  Install almost everything I want (Atom, Vivaldi, Docker, Kitematic, htop) go into the 3rd party section and install Android Studio. That’s it.  On Ubuntu I’d have to add PPA’s.  On Arch some of these are in pacman, some in AUR and some would have to come as snaps.  So I have everything I need, with minimal fuss and in future I don’t need to ask myself which tool I used to install this app.  Its all there in software center!

Testing

Wifi works great with the built in Killer Nic 1535.  Suspend/Hibernate worked first time with no issues.  HiDPI looks great in Gnome.  Tap to click is enabled by default and also works on the login screen (always a problem for me on Arch and Fedora).  Sound works good, battery life seems decent but requires more testing.   Bluetooth paired easily with my Mad Catz RATM wireless mouse. Touch screen works just like it should.

Conclusion

Very impressive distro so far, I still need to tweak the boot menu but that’s about it everything else has been pretty much perfect so far.  The mouse cursor is too small on the login screen with HiDPI but generally I just hit enter and type my password.  Android Studio virtual devices don’t start and need to be launched from the command line, but I’ve had that problem on every distro.  It’s an Android Studio problem.

I would highly recommend Solus as a distro for the XPS 13 9360 Kaby Lake. Easy install, works, performs and minimal fuss.

Dependency Hell

It all seemed so straightforward

I have a Udacity project to complete in 4 weeks, working in my personal time as part of the FastTrack course.  Take a semi-working app, add some features fix some bugs, call it done and submit.

Nothing crazy, move it from activities to fragments and create a master/detail layout using both for tablets and larger screens.  Implement a widget, which is new to me but doesn’t look difficult, optimise layouts for LTR and RTL languages and finally, add a screen with some graphs for details about the selected stock.

Then Yahoo happened

Having a lot going on in my life (planning a wedding, work commitments, etc.) I knew this project would be split into simpler tasks that could be achieved in 30 minutes to 1 hour.  This way I could squeeze some work into a lunch break and the bigger more complex pieces would be done in a few rare longer sessions.  The first long sessions I got the plan was to pull data for the graphs.  Except the Yahoo API had decided to change the URL that this data was downloaded from, which effectively meant that this historical data was missing.  Decision time, implement my own download and parse of a .csv file and add a bunch of work, or wait for the library the project came with to be updated.  Eventually about 5 days later, the library was updated to use the new URL’s and historical data was back.  Once I had that data the graphs got implemented pretty quickly.

Then Yahoo happened again

So I steadily worked through the rest of the project, taking a bit of time with Widgets as its a little bit different to what I’ve done before.  Finally it was time to dot the i’s and cross the t’s.  Oh hang on I’ve no data anymore… Yeap yahoo changed URL’s again, only this time they completely changed how the data is pulled. The library we use doesn’t look like it will be updated at all.  Essentially the upstream API that provides the data is gone… 2 days before the submission date.

Conclusion

If you depend on an API, best make it an official one with a defined road-map.

 

Dell XPS 13 9360

New laptop time!

My Inspiron 13 (7000 2-in-1) was a nice laptop.  It wasn’t the lightest but it was light enough.  It was a good size.  After adding an SSD is was plenty fast enough.  With the addition of the Killer Wireless 1535 and 8 Gigs of RAM it basically was just about perfect.  I had only a couple of complaints.

The screen resolution of 1366×768 was workable for everything except android VM’s and the soft touch finish was starting to come away in places and look worn in others.

I had previously set myself the goal of finishing the Android Basics Nanodegree in under 6 months. In order to get half the tuition back.  I managed it in just 5 months.  I took this money and added a little I had  saved and decided the laptop for me is an Dell XPS 13.  I went with this specification

  • Intel i7-7500u
  • 16 Gigs of RAM
  • 512 NVMe
  • QHD+ Touch Screen (3200×1800)

So far its been great, I like the keyboard, layout, touchpad, battery life.  I love the screen and the speed.

I’ll take some photos and talk about software development on it in a later post.

Lithuania

In September I spent more than 2 weeks in Lithuania, it was an adventure, lots of food, people and moving around the country.

Kaunas

We started by flying into Kaunas Airport, a tiny airport outside the countries second city.  Landing at midnight you don’t really see much.   We jumped straight into a taxi and headed out to our hotel.  Monte Pacis is a converted monastery that is still home to a number of nuns, but also functions as a hotel and a restaurant.

Its a strange place on the outskirts of the town, you can get Wine and Beer but not much else, the bar is outdoors only.  Fantastic if you want a relaxing couple of days

Comfortable room, decent food, peace and quiet.  Pretty soon though it was time to go explore and meet some people, but being a few kilometers outside the city we had to choose, taxi or “Trolley Bus”

img_20160830_1202073

So we walk down the road, see this old electric trolley bus and decide to ask the driver if this is going to the part of town we are interested in.  Bad call!  She practically had a meltdown that someone had the cheek to ask her a question.   From the banging of doors and shouting I guess that customer service was not high on her list of priorities.  After she chased us away, we waited for the next bus driver who gave us a free ride just 3 minutes down the road to a bus station and told us to get on the number 9.  That guy was much nicer.

So we got the number 9 trolley bus for €0.80, and that took us into the town.  I got a lot of funny looks from the locals, they seemed to be wondering why would someone from somewhere else want to be here on this bus.  Most of the next couple of days in Kaunas were spent visiting people.  After that we moved to Panevėžys for a few days.

Panevėžys

The fifth largest city in Lithuania was our home for a number of days, we spent a lot of time in peoples homes and visiting people, and a little bit of time in the city center.  We had great weather..

As it was September 1st, all students where dressed up for their first day of school, suits and dresses everywhere, the town was full of people looking their absolute best, great atmosphere, every restaurant was packed.

Rokiškis

My fiancee’s home town was next, a town with around 16,000 people only, we spent some time in family homes, visiting the gardens where people grow wonderful food and enjoy the great nature and weather as much as possible.  We spent some time at the Tyzenhaus building a site which has traditional Lithuanian buildings and crafts on display.

More to come in part 2..

SSH tunnel as socks proxy

You need:

  • A machine you can SSH too
  • Putty on your Windows client machine
  • A web browser you can change the proxy settings of

Configure your putty session and go to SSH/Tunnels.  Set source port to something like 8080 and destination to “Dynamic”.  Log in to the remote machine.

Configure the browser socks proxy to be 127.0.0.1:8080

Now all traffic in the browser is redirected to the proxy (port 8080 on your machine) which then flows out the SSH Tunnel to the remote machine, the remote machine gets the data from the Web and returns it back down the ssh tunnel.

So it looks like a normal unblocked connection to you, just a bit slower.  However in the background your actually encrypting your data and sending it to a remote machine that does then makes the request.  If you have a bandwidth limit on the remote machine remember your doubling up your data usage, so if you try download a 1 MB file the remote machine has to download it then send it up to you, that’s 2MB of data transfer.

Enjoy.

Python script for multiple image creation

Needing 5 sizes of each image for an android app is annoying, so I did what any sane person would do. I wrote a python script that does all the hard work 😉

Available on github.com, it should work with python 2.7 and 3.x, once you have “Image” installed

  • pip install Image
  • place some images in the same folder as the script and rung it

py-drawable-resize-1

  • You will see output like below, followed by the folders being created with the images inside

Back to writing the apps..

 

Android Basics Nanodegree with Udacity

So I’m currently learning all about Android application development.  I’ve made an app before while experimenting but decided to go with the Udacity course so I would not run into any trial and error rage quit scenarios while learning.

So far most of the apps have been simple single screen affairs with a few buttons slowly introducing Java concepts along the way.

Part 4 however is where the multi-screen fun starts, realistically I can’t wait to get to info exchange with a back end server and maybe build my own backed service.

Next though I’m going to try Android Studio under Arch Linux ?