2017-05-10

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!


2016-02-24

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 192.168.122.115 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:
 /etc/NetworkManager/dnsmasq.d/local.conf
with lines similar to this:
 listen-address=127.0.0.1,192.168.122.1
 address=/.openshift.example.com/192.168.122.115
 dhcp-range=192.168.122.20,192.168.122.30,2h

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:
 /etc/NetworkManager/NetworkManager.conf 

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

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
 nameserver 127.0.0.1

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


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.






2016-02-21

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.




2016-01-24

Try OpenStack at TryStack.org

If you are interested in learning OpenStack but do not have hardware to set it up yourself, one of the easiest ways to test it out is to browse to http://trystack.org and give it a try there.

Trystack is a sandbox installation of OpenStack sponsored by Dell, NetApp, Cisco and Red Hat.

You'll get a free access to test your stuff on Trystack, but there's one important rule:

Rule No. 1: Remember that TryStack is designed exclusively as a testing sandbox. We wanted a fast, easy way for developers to test code against a real OpenStack environment, without having to stand up hardware themselves. It probably goes without saying that this is not the place for production code - you should host only test code and test servers here. In fact, your account on TryStack will be periodically wiped to help make sure no one account tries to rule tyrannically over our democracy. Play nice in the sandbox!

In order to get access you need to use your Facebook account to log in.



IMPORTANT NOTE: In order to log in with the Facebook link, you must be a member of the TryStack Facebook group. API access is available by resetting your password in the web interface using the settings for your account and selecting API Access.

Once you've joined the Facebook group and logged in, you'll find yourself quickly at the rather empty OpenStack view.




If this is your first time testing OpenStack, you'll probably want to click Images, choose one and click Launch Instance.

You won't be able to login into your instance as root password, you'll need to upload your SSH public key first. This seems to be the most common question on the user forum...

Now you are own your way becoming the next OpenStack expert. Have fun!

And once you are ready to setup your own OpenStack installation, go to https://www.rdoproject.org/ for free community version of OpenStack or to http://www.redhat.com/en/technologies/linux-platforms/openstack-platform for Red Hat's enterprise version.



2016-01-17

Streaming videos from Linux to Apple TV

Apple TV is nice and affordable device to access Netflix and Youtube from your television. It also nicely integrates with your Apple computers. But what if you don't have any Apple computers and you have some content on your Linux which you'd like to watch on your TV set using Apple TV?

As we all know Apple is not very famous of following industry standards, for example in this case they don't support DLNA specification which would allow streaming content across different device vendors.

I'm using Fedora Linux on my home computer, and it comes with DLNA compatible sharing built-in. To enable it go to Settings > Sharing > Media Sharing > Add a folder containing some media files.

As Apple TV doesn't have any DLNA compatible applications, and on the devices before 4th generation you can't even install any apps you'll need to work around the problem some way. On 4th gen Apple TV you can install VLC which will fix the problem.

For older Apple TV's you'll need to use your phone as a remote control and trick the Apple TV to start streaming. Magically it actually does support streaming this way... You can install AllConnect app for Android or IOS from http://allconnectapp.com/.

AllConnect is able to browse your shared DLNA library from your Linux computer, and it can use Apple TV as a target device. After you start a media streaming, your phone is not involved in the streaming in any way, it goes directly from your computer to your Apple TV.

Dear Apple, why to make things this complicated? Oh right, to promote iTunes Store.  Standards? Who needs them...


2015-09-19

Sales Engineers, Solution Architects, Technologists, ...

Short version

Please join a LinkedIn group for Sales Engineers: https://www.linkedin.com/grp/home?gid=8403310

Long version

We are being called Pre-Sales, Sales Engineers, Solution Architects, Technical Sales, Technologists, Evangelists and so on. Many names for one of the most important assets of any product company.

We learn how your products are being made, we learn how to use your products, we learn what problems they solve solve.

We know your customers, we know their needs, we know how to position the product against your competitor.

We study new technologies, we learn new methods, we develop solutions to problems you didn't know even existed.

Sales Engineering is one of the most difficult jobs in the world.

There's a group for all of us. Independent of our customers, not controlled by our employers. Non-profit, advertisement free. 

Sales Engineering Wordwide



2015-09-15

Color coding your shell prompt

Someone asked me how to get colors into your bash shell prompt. Easy!

Add this your ".bashrc". Additionally I've added a text variable which could be used to show for example "OpenStack", "KVM" or similar to identify on which datacenter you are operating on.



# User specific aliases and functions
datacenter="[Red Hat]"
export PS1='\[\e[1;32m\]\u@\h:\w\e[1;31m${datacenter}\e[1;32m$\[\e[m\] '

Test by running: "source .bashrc"

The color codes are highlighted. Some example colors:
Black 0;30
Red 0;31
Green 0;32
Brown 0;33
Blue 0;34
Purple 0;35
Dark cyan 1;36

(0=bright, 1=dark color)

Your terminal should look something like this now:


2015-08-12

Nested KVM virtualization with RHEV

If you want to run Red Hat Enterprise Virtualization (RHEV) or it's community version oVirt on your laptop for demonstration or learning purposes you need to enable nested virtualization for KVM. By default you'll get an error about unsupported CPU type.

I have Fedora running on my laptop and have two virtual machines running on virt-manager named "rhevm" and "rhevh". 

On the physical host, in my case Fedora enable nesting: 

# nano /etc/modprobe.d/kvm-nested.conf
Add this line to the file (file might not exist by default): options kvm_intel nested=1

Reload the KVM kernel module:

# modprobe kvm_intel
# modprobe -r kvm_intel

Then edit the "rhevh" virtual machine to use host-passthrough mode:

# virsh edit rhevh

Change from < cpu mode='custom' match='exact' > to < cpu mode='host-passthrough' >

You are now ready to start your virtual machines and play with RHEV, with nested virtualization.

Please note that this is not recommended or supported for production environments.

2015-04-02

All in one cloud

Cloud in a box

I'm running Fedora on my laptop with 8GB of RAM. I recently swapped the original HDD to a SSD disk to see if the performance could be improved. Before the swap I had tested running OpenStack on the laptop but it was rather slow once I deployed more than one instance.

The SSD disk seemed to be performing quite well on normal desktop use, so I wanted to see what happens if I start to give some load on it.

I installed RHEL7 on a virtual machine with Virtual Machine Manager, and then installed Red Hat Enterprise Linux OpenStack Platform - or RHEL OSP - on it. So far so good.

Next step was to deploy Red Hat CloudForms - a hybrid cloud orchestrator - on a VM, this time on RHEL 6.6. That went well also.

Finally I connected CloudForms to the OpenStack controller via API, and started to deploy some virtual instances on my tiny cloud. Still after deploying 6 pieces of a small CirrOS instances, my laptop had enough CPU cycles and memory to run the normal desktop operations.

So, if you fancy of having a small cloud in a box for demonstration or learning purposes it's possible. Just ensure you have fast enough SSD disk and plenty of RAM available.





2015-01-03

Setup a PHP development environment on Fedora 21

So you've installed Fedora 21 and are struggling on getting PHP to work? Done that been there...

These step-by-step instructions will help you setup the environment in a way you can easily develop and test an application with PHP and MariaDB on your workstation.

Let's assume we want to use the following directory as the root directory for our project:
 /home/twillber/www/project1

Directory permissions

Ensure that everyone - or at least Apache -has permissions to access that directory. Do the same for all directories in it's path.
 chmod a+rx /home/twillber/www/project1

Since we are operating in your home directory SELinux should have no issues with this. If you decide to go outside of your own home directory you'll probably need to set the correct context to the www directory.

Install packages

First we'll install the required packages for PHP and MariaDB (replacement of MySQL).

 yum install httpd php mariadb-server php-pear-MDB2-Driver-mysqli
 systemctl enable httpd

 systemctl enable mariadb
 systemctl start mariadb

Apache configuration

 Create file /etc/httpd/conf.d/mylocal.conf with the following content:

 < Directory "/securehome/twillber/www">
  DirectoryIndex index.php index.html
  Options +Indexes +FollowSymLinks +MultiViews
  Require all granted
 < /Directory>
 Alias /project1 /home/twillber/www/project1/
 Alias /project2 /home/twillber/www/project2/


Ready to go

At this point you probably want to create some kind of index.php into your working directory. Maybe even use mysqli API to connect to MariaDB, write some HTML and CSS and make the next killer app!

But first, restart Apache:
 systemctl restart httpd

Then use your favorite browser and see the magic:

 http://localhost/project1