Posts tagged “linux

LibVirt notes….

This blog posts contains shortcuts for creating VM’s in libvirt. I use these commands all the time and constantly find my sell referring to these notes, so I thought I would post them here for everyone else to use as well. To give credit where credit is due alot of this comes from Rhys Oxenham, Thanks Rhys!!

Step one get an image….

I usually download it to /var/lib/libvirt/images, the default location for libvirt, however you can stick it anywhere. For this example I used the latest (of this writing) rhel7 image form Red Hat.

Make sure the libvirt tools are installed
# dnf install libvirt qemu-kvm virt-manager virt-install libguestfs-tools libguestfs-xfs net-tools -y

I usually rename it something more manageable…
# mv rhel-guest-image-7.0-20140930.0.x86_64.qcow2 rhel7-guest-official.qcow2

Check the details of the image you downloaded:
# qemu-img info rhel7-guest-official.qcow2

Check the details of the image file system:
# virt-filesystems --long -h --all -a rhel7-guest-official.qcow2

Create new image, no data:
# qemu-img create -f qcow2 rhel7-guest.qcow2 40G

Re-size off official to new:
# virt-resize --expand /dev/sda1 rhel7-guest-official.qcow2 rhel7-guest.qcow2

Check that both the partition and the filesystem have been correctly resized
# virt-df -a rhel7-guest.qcow2

Turn this guest image into a backing file so we can use copy on write functionality to be space efficient with our new virtual machine:
# qemu-img create -f qcow2 -b rhel7-guest.qcow2 test-vm.qcow2

set the root password:
# virt-customize -a test-vm.qcow2 --root-password password:test

boot the machine:
# virt-install --ram 16384 --vcpus 4 --os-variant rhel7 \
--disk path=/var/lib/libvirt/images/test-vm.qcow2,device=disk,bus=virtio,format=qcow2 \
--import --noautoconsole --vnc \
--network network:default --name test

** if you want to connect to a bridge

  –network bridge=br-prov –network bridge=br-ext

Check that its running:
# virsh list --all

use arp to find out the IP that it has been allocated:
# VM_IP=$(arp | awk ' /virbr0/ {print $1}')
# echo $VM_IP

creating a passwordless SSH keypair:
# ssh-copy-id -i ~/.ssh/ root@$VM_IP

connect to VM
# ssh root@$VM_IP

Take a snapshot:
# virsh snapshot-create-as test test-snap-1

list all snapshots:
# virsh snapshot-list

If you ever need to restore VM you can execute the following command:
# virsh snapshot-revert --domain test


Playing with docker

Today I got some free time to play with Containers and docker on RHEL7, below are some of my notes that I found useful…….

Step 1 Install Docker on RHEL 7

# subscription-manager repos --enable rhel-7-server-extras-rpms
# subscription-manager repos --enable=rhel-7-server-optional-rpms
# yum install docker
# yum install device-mapper-libs device-mapper-event-libs
# systemctl disable firewalld
# systemctl stop firewalld
# systemctl start docker
# systemctl enable docker
# systemctl status docker

Step 2 get an Image:

To get Docker images from a remote registry and add them to your local system, use the docker pull command:

# docker pull <registry>[:<port>]/[<namespace>/]<name>:<tag>

To see the images on your system, type docker images

# docker images

Inspect an image: Run docker inspect

# docker inspect <full/name/of/image>

To remove images you no longer need, use the docker rmi command:

# docker rmi <image name>

If you want to clear out all your images, you could use a command like the following

# docker rmi $(docker images -a -q)


Step 3 run a Container:

When you execute a run command, you essentially create a new container from a Docker image. That container consists of the contents of the image, plus additional options you pass on the docker run command line.

docker run \
-d \
--name <name> \
--network=host \
-e TZ="<timezone>" \
-e option="<optioin>" \
-v <path/to/config>:/config \
-v <path/to/temp>:/temp \
-v <path/to/data>:/data \

List running containers:

# docker ps

Stop a container:

# docker stop myrhel_httpd

Restart a container:

# docker start myrhel_httpd

To remove containers you no longer need, use the docker rm command

# docker rm <name>

To see a list of containers that are still hanging around your system, run the docker ps -a

Other usefull stuff:

Shell access to the container while it is running:

docker exec -it <name> /bin/bash

See the logs given by the startup script in real time:

docker logs -f <name>

More Info:

Taste of Training, Summit 2015


This year, I had a chance to help out with the training labs at Red Hat Summit, something I had never done before. As a solutions architect, Its always good to interact with customers and see our products in action. The learning labs were a lot of fun and a resounding success.


config a vlan interface

I always forget how to do this, so adding this post for my reference. This is a basic example of how to add a vlan tag to a network interface……

# cat /etc/sysconfig/network-scripts/ifcfg-eth0

# cat /etc/sysconfig/network-scripts/ifcfg-eth0.200

RHEL7 notes

Below are some helpful tips when working with RHEL7. They are not always recommended however sometimes helpful, especially when new to RHEL7…..

Disable dynamic network interface naming:

# vim /etc/default/grub

add the following to GRUB_CMDLINE_LINUX line
“biosdevname=0 net.ifnames=0”

# grub2-mkconfig –output=/boot/grub2/grub.cfg


Set Hostname:

# hostnamectl set-hostname “hostname”

Disable network manager and firewalld:

# systemctl stop NetworkManager

# systemctl disable NetworkManager

# systemctl stop firewalld

# systemctl disable firewalld

Register with subscription-manager:

# subscription-manager list –available

# subscription-manager attach –pool=

# subscription-manager repos –list

       # subscription-manager repos –disable=*

# subscription-manager repos –enable <repo-name>

      # subscription-manager repos –enable=rhel-7-server-rpms –enable=rhel-7-server-extras-rpms




Example Packstack answer file with vxlan

Building on my previous post form James, Packstack is a pretty handy tool. Packstack is designed to easily set up test or proof-of-concept deployments. It uses Puppet modules to enable rapid deployment of OpenStack on existing servers over an SSH connection. PackStack does however make many assumptions in its configuration to simplify the installation process, and is not suitable for production deployments. Also it cannot deploy services in a highly available or load balanced configuration. See the Red Hat docs for more info.

vxlan has become the default plugin for layer2 networking for Neutron via the ML2 plugin, and makes deploying a simple multi-node configuration pretty straight forward. The example Packstack answer file below will produce a working OpenStack environment with three nodes, one controller, one networking node, and one compute node. It assumes two separate network segments, one on eth0 (public)and one on eth1(private). The public network contains the 192.168.1000/24 subnet and how the OpenStack services communicate between nodes and with the outside world. The private network is for our tenant networks and will contain the vxlan tunnels, this can be changed with the CONFIG_NEUTRON_OVS_TUNNEL_IF=eth1 option in the answer file below……

OpenStack Packstack Installation with External Connectivity

Handy info, specifically in regards to network-scripts

all things open

Packstack makes installing OpenStack REALLY easy. By using the –allinone option you could have a working self-contained RDO installation in minutes (and most of those minutes are spent waiting for packages to install). However, the –allinone option really should be renamed to the –onlywithinone today, because while it makes the installation very simple it doesn’t allow for instances spun up on the resulting OpenStack environment to be reachable from external systems. This can be a problem if you are trying to both bring up an OpenStack environment quickly and demonstrate integration with systems outside of OpenStack. With a lot of help and education from Perry Myers and Terry Wilson on Red Hat’s RDO team I was able to make a few modifications to the packstack installation to allow a user to use the packstack installation with –allinone and have external access to the instances launched on the host. While I’m…

View original post 656 more words