Easily convert from VirtualBox to KVM in Linux
I have been converting some of my old VirtualBox images to KVM, which is the virtualization standard in Linux.
Its really easy, although, if you run into booting issues of the converted image, the last tip here will save you some time.
To convert from VirtualBox to KVM, look for your VDI images.
qemu-img convert -f vdi -O qcow2 [VBOX-IMAGE.vdi] [KVM-IMAGE.qcow2]
e.g. qemu-img convert -f vdi -O qcow2 FreeBSD-7.2.vdi FreeBSD-7.2.qcow2
You can now import the converted image using virt-manager or the CLI tool virt-install.
In Virtual Machine Manager, go to Disk 1 >> Advanced options and change ‘Storage format’ to qcow2.
This prevents boot errors like ‘boot failed: not a bootable disk’ when you launch the VM.
WebRTC – Why Skype will become less dominant
If you know me, then you know that am not much of a Skype fan. If I have to make Internet based calls, my go to app is Jitsi, which uses my own managed Asterisk server as its proxy. Asterisk allows for all types of calls including SIP-to-SIP, and international calls terminated by regular phones.
But that’s me. For most people Skype is the dominant app for Internet calls. So when people ask me whether I am on Skype, my answer in most cases is ambivalent. While I have a Skype ID, I rarely use it. Why you ask? It is a long story. Really – its a long story. Bottom line, I no longer use Microsoft software, and most of my work is done using open source software.
It is important to note that Skype data and calls are handled via proprietary channels and routed to servers we really don’t know about. Also, keep in mind that while it might not matter to you, Skype has become a surveillance tool for many Governments. Take a look at this article. And yes, the NSA is also in on it.
Google Hangouts
The current popular alternative to Skype is Google Hangouts. Hangouts is really good and does a good job when you need to do one-to-one voice and video calls, and even conferencing. The only requirement is that all the participants must be signed into the Google ecosystem. The latter statement kind of points to why, I still have a hard time using Hangouts. What’s the problem, you may ask? Well, for one, you are still tied to Google’s infrastructure. Just like the Skype situation, all calls go via Google’s servers. Also, Google has a very terrible record of axing services – Take the example of Google Reader, Google Buzz/Wave, Google Voice’s XMPP implementation to name but a few.
Open source VoIP software
Currently, there’s no open source software that perfectly replaces Skype. OK, may be it exists, but may not be as simple to use as Skype. In the open source world, traditionally, you’d use PBX systems such as Asterisk (See my previous article on setting up asterisk). These servers would bridge internal and external calls.
The problem though is that most networks are heavily militarized (i.e. firewalls) – Most block the commonly used Voice over IP (VoIP) protocol of SIP. So if I have to setup a video or voice conference for four company users, assuming two are in Nairobi, and the other two are in Kampala, I would have to ensure that the company’s PBX server they will use to connect is on a network that has SIP ports open. For a techie, this is not hard to setup, as you only need to ensure that port forwarding for VoIP services is enabled. However, this process tends to be cumbersome.
The other hurdle is that the four users each have to install a SIP client on their PCs (in case they are not using hard phones). Skype solves this issue, by simply having users install from a central repository, and then users sign up all in one place. In the open source world, its not as simple as that, as users need to first pick a SIP client. Many examples exist, but my favorites are Jitsi and Linphone. Then, the server administrator needs to provide the users with a username/password or extension. Again, for the savvy, there are always ways to automate and make this simple, but not for the typical user.
I believe, this is why Skype has been the go to place for VoIP services. However, things are about to change with the recent introduction of a technology known as WebRTC
WebRTC – Real-Time communications
WebRTC, is a free and open source project that allows real time communication using web browsers. That’s right – You can now make calls using your web browser! It enables peer to peer audio, video and data communications between web browsers. Recent versions of Chrome, Firefox, and Opera now support WebRTC.
WebRTC solves the challenges of open platforms I mentioned above by allowing the web browser to act as a sip client during video and voice calls. In fact, the original server is needed only during the initialization stage, thereafter, the client browsers, will communicate with each other directly.
So here’s how it would work: My four users in Nairobi and Kampala would go to a website URL that I would send to them, and simply sign in and immediately start the conference. No drama, No fuss.
WebRTC, while a very young technology, promises to revolutionize the way we communicate. For one, the communication will no longer rely heavily on middle men.
It is now possible to have ‘Call or Chat with us’ links on web pages allowing for website visitors to directly talk to the web managers. Think of it as a kind of support desk.
WebRTC, also means users do not need to be bothered with installing software or plugins on their PCs or mobile devices in order to chat or talk. Just use the existing web browser where most users already spend most of their time on the Internet.
Of course, Skype will continue to be with us for some time, but the proliferation of mobile platforms will see more and more software vendors turn to WebRTC to do cool things on these devices.
Why SystemD will start your next Linux system
For a long time, the default boot and initialization mechanism in Linux was the System V (SysV) init daemon. Along the way, many Linux distributions have attempted to move away from this primitive form of booting. Why you ask? For one thing, it makes the boot process a lot slower, since processes have to be started one at a time. It is also a nightmare to maintain the scripts that Administrators write to manage these start processes, as each package maintainer or administrator, does ‘their own thing.’
So Ubuntu, one of the most popular Linux distributions moved to upstart in late 2006, but this init daemon they adopted, was not widely embraced. Debian, OpenSuse, Fedora, and Red Hat at some point in the last five years supported upstart. Red Hat Enterprise Linux (RHEL) version 6 and derivatives such as CentOS still use upstart. But all of them are ditching upstart for something better, i.e. SystemD. In fact, the Debian technical committee recently voted and they will switch to SystemD in upcoming releases, leaving Ubuntu no choice but to follow.
It now looks like SystemD will be the default initialization and boot method for Linux systems for many years to come. But what does systemD do different?
What is SystemD?
SystemD, is a system and services manager for Linux that was developed by a team from Red Hat, spearheaded by Lennart Poettering, the creator of pulseaudio, and Avahi. SystemD makes Linux systems boot faster since processes are ran in parallel. Once started, processes are monitored, and restarted if they crash. SystemD also reduces the dependency on shell scripts to do much of the work.
Other systemD features, include a cron-like job scheduler, an integrated login manager, which offers ‘multi-seating’ functions. It also has a new an improved logging mechanism called the journal, that will likely replace syslog, the current logging facility on Linux systems.
Below is some technical information to get you as the administrator started with systemD. Please note that there are several manuals and online resources available that will help you understand systemD, I will mention a few at the end of this post.
How to get started with systemD
SystemD is installed by default on recent versions of Fedora, and Arch Linux. For other distributions like Debian and Ubuntu, you might have to wait a bit for systemd to be packaged as the default init system. It is actually recommended that installation is done by the distribution vendors. But if you are the brave type, you can of course install it from source.
Pick up the source tarball and follow the instructions contained in the README file included with the sources.
After installation is completed, you will need to start converting your old startup scripts to systemD. At this time, only SysV init scripts for commonly used services, have been ported to systemD. So you will need to know how to write a service file for rarely used daemons or for that program you are developing. Below is an example of a systemd service file. By the way, these are what those files in “/etc/init.d” used to be.
How to write a systemD service file
Open up your favorite editor such as vim as follows:
vim /tmp/squid.service
Am using squid here as an example, so replace it with the name of your service. Enter the following snippet:
[Unit]
Description=Squid caching proxy
After=syslog.target network.target nss-lookup.target
[Service]
Type=forking
EnvironmentFile=/etc/sysconfig/squid
ExecStartPre=/usr/libexec/squid/cache_swap.sh
ExecStart=/usr/sbin/squid $SQUID_OPTS -f $SQUID_CONF
ExecReload=/usr/sbin/squid $SQUID_OPTS -k reconfigure -f $SQUID_CONF
ExecStop=/usr/sbin/squid -k shutdown -f $SQUID_CONF
PIDFile=/var/run/squid.pid
[Install]
WantedBy=multi-user.target
At a minimum, you will need these three sections; unit, service, install.
Unit definitions
Description: A string describing the service and what it does.
After: If service depends on another one, then indicate that it should come after those targets. Notice in my example that one of the pre-requisites for this service is the network service. You will see that often, as most services expect the network to be already running, so always include it.
You can also add ‘Before’ which does the opposite and starts this service before units listed.
Hint: You can read more about unit definitions by calling up the manpage: man systemd.unit
Service definitions
Type: You must always have a type, which can either be forking, simple, oneshot, dbus, or notify. For most daemons, forking should suffice, as it forks the processes by putting them in the background after start.
EnvironmentFile:This is the file which contains the options used by your service daemon. This can be omitted, but can be a life saver occasionally
ExecStartPre: This is the command that is called before the main process – see ExecStart
ExecStart: This is the command that the daemon runs. You can also point to a script on your system e.g. =/bin/sh -c “/usr/sbin/my-cool-script.sh”
ExecStartPost: This is the command that is called after the main process – see ExecStart
ExecReload: This is the command that is called in order to reload the daemon’s configuration file.
ExecStop: This is the command that is used to stop your service.
PIDFile: Enter the file path containing the process ID of your service. SystemD reads this file after startup.
Hint: You can read more about service definitions by calling up the manpage: man systemd.service
Install definitions
This section is optional, but can be used to set the target level
WantedBy: Set a target where this service will be grouped. Like run levels in SysV language.
Hint: You can read more about various special targets by calling up the manpage: man systemd.special
Activating your systemd service
When you are done writing the service file, copy it to: /usr/lib/systemd/system/
cp -v /tmp/squid.service /usr/lib/systemd/system/
You will need reload the systemd daemon:
systemctl --system daemon-reload
In order for the service to start automatically at boot time, enable your systemd service as follows:
systemctl enable squid.service
Now when you want to start, stop, reload or check the status of this service; do the following:
systemctl COMMAND squid.service
; where COMMAND is either {start|stop|reload|status}
This how-to barely scratches the surface. There are lots of neat tricks you can perform with systemD that your old dog SysV and upstart could not. So take the time to learn it.
Resources:
SystemD website: http://www.freedesktop.org/wiki/Software/systemd
Lennart’s Blog: http://0pointer.de/blog(Look for the SystemD series for Administrators)
Mailing List: http://lists.freedesktop.org/archives/systemd-devel
Man pages: systemd- (Use tab completion to see all available man pages)
Uganda’s Digital TV migration: Still a messy, on and off affair
With the June 2015 international deadline for TV migration only a year away, Uganda’s digital TV migration process is still very much a messy affair. Very few Ugandans know that in a few months, they could find themselves not able to watch their favorite TV programs.
The pilot testing phase in the greater Kampala area continues to be an on and off affair. Not all TV stations currently broadcasting in analogue format are on board the digital train. For example, only the following are currently being transmitted via DVB-Terrestrial.
Bukedde2
EATV
LTV
NBS
NTV
Record
UBC
Urban
WBS
For all channels broadcasting, the reception has somewhat degraded when compared to last year. The audio and video quality is also generally poor. For a complete status, please check out the Digital TV in Uganda Status page.
As for consumer awareness, there are very few Ugandans who are aware of the migration process. Uganda Communications Commission(UCC) (UCC), the body in charge of steering the digital TV migration, has in the past few months been running Ads on local TV, but it looks like even those Ads, have not had a change in the awareness and preparedness of the masses.
Compounding the problem is the lack of Analogue-to-Digital TV converter boxes (or decoders) on the market. As of today, the only providers of these boxes have been the pay TV providers such as Star Times and Go TV. Yet, these providers require you to subscribe to their services on a monthly basis. It seems the providers, have ignored the call by UCC, that they de-scramble the Free-to-Air channels on their boxes. This effectively means that for the ordinary Ugandan, moving to digital TV today means subscribing to a pay TV provider.
It is hoped that in a few months, the decoders will be available on the market. This after five firms were approved to import and sell these devices.
My advice to early migrants, is that while not available locally, take a look at hardware known to work on the Digital TV Uganda site. We’ll continue to update the list as more people come on board.
How to setup a 3G Wireless Hotspot using Linux
The prevalent and most used type of Internet in Uganda currently is 3G via a USB modem or dongle. Have you found yourself somewhere; may be on travel, or at home, and you need to share your Internet connection with a friend or family members via WiFi? Do you wish you could just plug in your laptop, and just use your WiFi-enabled phone or tablet to surf? Are you a Linux user? Well its very easy to setup a WiFi hotspot for yourself using free and open source software.
There are several ways to do this, however, if you use Linux say on your laptop (or server), what you need is an application called hostapd. It is already installed in most Linux distributions like Redhat/Fedora, CentOS, Ubuntu, Debian, etc. If not simply install it as follows:
yum install hostapd (or use apt get for Debian based systems like Ubuntu)
Of course, you will need to have a Wireless device enabled on your laptop (or server box), and the chipset should support AP (Access Point) mode. To test this:
iw list (Look for modes section to see if AP mode is supported on your Wireless device
Also, you need to setup the Wireless interface device. In this post I am using an IP address of 172.16.0.1 for my Hotspot and ‘wlan0’ as the device name e.g.
ifconfig wlan0 172.16.0.1
Please remember that the above will not survive a reboot, so you need to permanently add it to your network configuration. On Redhat based systems:
vim /etc/sysconfig/network-scripts/ifcfg-wlan0
Add these parameters:
TYPE=Wireless
BOOTPROTO=static
IPADDR0=172.16.0.1
NAME=”wlan0″
ONBOOT=yes
Now edit the configuration file for hostapd to suit your needs.
vim /etc/hostapd/hostapd.conf
A typical hostapd.conf file looks like this:
ctrl_interface=/var/run/hostapd
ctrl_interface_group=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
wpa_passphrase=AVERYSECRETPASSPHRASE
interface=wlan1
ssid=MY-HOTSPOT
hw_mode=g
channel=6
driver=nl80211
The most important changes to make in the above file are:
ssid: The name you want your hotspot to be called
wpa: The encryption type. Use WPA2 and above always
wpa_passphrase: the password users will need to access your hotspot
After you have modified and saved the above file, enable hostapd services, so they also start during boot time.
systemctl enable hostapd.service or chkconfig hostapd on (old way)
systemctl start hostapd.service or service hostapd start (old way)
You will need some facility to dynamically offer IP addresses to clients of your hotspot. One very useful tool is called dnsmasq. Dnsmasq is a lighweight DHCP and DNS server. You can install it using your package manager e.g.
yum install dnsmasq
Once installed, edit the configuration file for dnsmasq to suit your environment:
vim /etc/dnsmasq.conf
The most important changes to make in the above file are:
interface=wlan0
domain=example.com
dhcp-range=172.16.0.10,172.16.0.199,12h
dhcp-option=3,172.16.0.1
Enable dnsmasq to start now and at boot time:
systemctl enable dnsmasq.service or chkconfig dnsmasq on (old way)
systemctl restart dnsmasq.service or service dnsmasq restart (old way)
The next step is to dial your ISP using either the GUI (NetworkManager) or the CLI tools like the ones I wrote about earlier. If you use the GUI tools, you will need to allow the laptop (server) to act as a gateway. This can be achieved simply:
/bin/echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE (NOTE: This assumes you are connected using a 3G modem with an assigned interface node of ppp0)
Once you are connected, and gateway has been setup, your clients should be able to connect to your Hotspot using the SSID and passphrase you setup above.
That’s it. Happy New year!
Digital TV in Uganda: Current Status
I’ve added a status page showing current OTA DVB-T channels broadcasting in Uganda.
You can access it at Digital TV Uganda.
Uganda’s digital TV migration is still in its testing phase and only the Kampala area is receiving these streams.
DVB-T tuning data for Uganda
I recently submitted initial DVB-T scan data for Kampala to the dvb-apps package upstream. If you are testing DVB-T2 in Uganda using Linux, please go ahead and clone the latest git sources at:
http://git.linuxtv.org/dtv-scan-tables.git
Its still early, but at least with the latest sources, you do not have to tinker around in your app.
Also, I’m looking for testers in the region. If you’re already using DVB-T with Linux, please contact me.
Uganda’s Digital TV migration has stalled
For nearly a month now, Uganda’s Free-To-Air digital TV signals have been off. After many followers of this project breathed a sigh of relief when the transmission began a couple of months ago, it has once again become clear why the transition to digital TV in Uganda will really be messy.
To date, the testing phase for the greater kampala area has really been nothing short of a gimmick. The channels allotted to free over-the-air broadcasters have been intermittent, and when off, no communication has been provided. Also, there’s no publicly available schedule – just press statements from officials.
Most perplexing is the fact that the body in charge of migration i.e. Uganda Communication Commission (UCC) has been running adverts on local media announcing Digital TV and its benefits. Even, for someone who understands what digital TV is all about, I find these ads very unhelpful considering that they’s really no concrete migration schedule or ‘call to action.’ Also, why advertise at this point if no test or pilot program is even available. All I see that the adverts are doing is simply creating anxiety as opposed to informing the public.
I would like to suggest the following to UCC:
A signal test period with start and end dates be advertised to the public. This can be done on website, social media, and the local papers.
Notify the public when the channels are switched off such as during maintenance, upgrades etc
Furthermore, there ought to be a forum where TV owners and especially early adopters can provide feedback on TV quality signals etc. The current web pages on the UCC’s website on Digital TV migration do not provide any updates whatsoever.
Also, there’s currently no recommended manufacturer list of DVB-T2 converters that TV owners should buy. How about outlets where these tuners can be purchased? I know there are the pay TV providers, but that is not enough.
In summary, I highly recommend that UCC come out with regular updates on TV migration. Where exactly are we? The deadline date is really too close for such a venture!
OK, I know with all the issues being experienced with procurement, politics etc this may be too much to ask of Uganda Communications Commission to do.
But come on guys, Ugandans deserve better, and would want to know what exactly is going on with this important project. If you have issues tell us, we understand the environment!
How to create your own Linux install image
I was reading this google+ post by Linux’ very own Linus Torvalds. One of the comments reads “I feel like Mom and Dad are fighting. I love Fedora and I love Linux :)” Clearly, Linux distributions come with their own specific set of packaging rules and guidelines. Sometimes, it does not make sense to everyone. And when that someone else is Linus, people will go ‘bonkers’ to either agree or disagree with him. But why the noise?
To any one who’s not ventured into the murky waters of Linux kernel building and packaging, you may be wondering why a topic like this one solicits such responses even if its not coming from the man who invented Linux. Believe me – it is a big deal.
Due to the rapid development of open-source software, the Linux kernel and packages on the original CD/DVD images tend to become outdated over a short period of time. Sometimes, those packages become insecure and vulnerable. Furthermore, with all the latest and cool hardware devices that vendors are producing every other day, the Linux kernel has to be upgraded so as to be fully usable by those devices.
So in my opinion, Linus Torvalds is half right, since non-techie users need to get Linux working straight out of the box. My feeling though is that the main distros are really not meant for the Linux newbies. That is why re-spins seem to be a lot popular with new Linux users. So if you made it this far and are still reading this, how do you go about creating a re-spin? Here is one way:
Lately, I’ve been spending sometime, creating customized versions of the Fedora Linux images. I use these Fedora re-spins for the embedded products I’ve been working on such as the JambulaPi, TV STB etc. BTW, these re-spins of Fedora are open source and free, so I plan on posting them to a public site in a not too distant future!
A very useful tool for creating custom images for Fedora Linux is called livemedia-creator. Livemedia-creator uses Anaconda, kickstart and Lorax to create bootable media such as live iso’s that use the same install path as a normal system install.
To install it:
sudo yum install lorax
Then, take a look at the readme file located at /usr/share/doc/lorax-*/README.livemedia-creator. There you will find examples on how to set up your very own customized Linux distribution. A kickstart file is highly recommended as you can add other repositories for installing software that is not originally included in the Fedora releases. Also, it lets you do things like adding initial users, etc. Take a look at Kickstarting Fedora Linux installations.
Digital (Free-To-Air) TV now available in Uganda
Finally, Digital TV broadcasting has started in Uganda. Below is a list of channels I was able to scan for the Kampala area. See my previous post on how to scan for these channels.
service = UBC TV (UCC)
service = UBC STAR TV (UCC)
service = East AFRICA TV (UCC)
service = ITV (UCC)
service = CITIZEN TV (UCC)
service = WBS TV (UCC)
service = BUKEDDE TV 1 (UCC)
service = BUKEDDE TV 2 (UCC)
service = URBAN TV (UCC)
service = RECORD TV (UCC)
service = TOP TV (UCC)
service = NTV (UCC)
service = UBC TV (UCC)
service = LIGHT TV (UCC)
service = MIRACLE TV (UCC)
service = CCTV (UCC)
service = NBS (UCC)
service = CAPITAL TV (UCC)
service = BOUQUET SERVER 1 (UCC)
service = BOUQUET SERVER 2 (UCC)
service = RTV (UCC)
service = KBC (UCC)
service = TBC 1 (UCC)
service = BBC WORLD (UCC)
Of these, only six (TV: UBC, EATV, ITV, WBS, BUKEDDE-1, and NTV) are currently broadcasting via DVB-T.
And the fun part for the Linux people out there – How to play these channels.
If using VLC, create a channels.conf file (i.e. scan using Xine format). When done, simply run:
#> vlc .xine/channels.conf
All the channels will be populated as a playlist. Then select your favorite channel to watch.
NOTE: If you are playing using a remote SSH session i.e. embedded device: something like this will work:
vlc -I dummy -V xv -f --width 1024 --height 768 dvb-t:// :dvb-caching=300 :dvb-frequency=474000000 :dvb-inversion=-1 :dvb-bandwidth=8 :dvb-a-fec=2/3 :dvb-transmission=8 :dvb-b-modulation=QPSK :dvb-guard=1/4 :dvb-hierarchy :program=ENTER_PROGRAM_NUMBER_HERE e.g. for UBC enter 1 (see channels.conf file)
Initial observations: Audio quality is a bit off for some channels like NTV – I guess this will improve over time as the broadcasters get their act together.