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….
https://www.rdoproject.org/resources/image-resources/
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/id_rsa.pub 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 \
Image/name
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
NAME=eth0
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
#IPADDR0=192.168.100.11
#PREFIX0=24
#GATEWAY0=192.168.100.1
#DNS1=192.168.100.1
#DOMAIN=redhat.local
# cat /etc/sysconfig/network-scripts/ifcfg-eth0.200
NAME=eth0.200
VLAN=yes
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
IPADDR0=192.168.100.11
PREFIX0=24
GATEWAY0=192.168.100.1
DNS1=192.168.100.1
#DOMAIN=redhat.local
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
reboot
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……
(more…)
OpenStack Packstack Installation with External Connectivity
Handy info, specifically in regards to network-scripts
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
guestfish in 3 simple steps
libguestfs is a very handy library for manipulating image files. guestfis is a utility that uses libguestfs that allows you to mount an image file and make changes inside the image. One of the coolest features of libguestfs is that it does not require root prevelages to run or access an image file. The below example shows how to use guest fish to mount an make a change to a machine image.
1) install guestfish
# yum install guestfish2) connect to the image
guestfish –rw -a ~/Downloads/rhel-server-x86_64-kvm-6.4_20130130.0-4.qcow23) edit image
><fs> run><fs> list-filesystems
><fs> mount /dev/vda1 /
><fs> vi /etc/fstab make any changes you need to ><fs> umount /
><fs> exit
Additional info:
Download machine images:
http://openstack.redhat.com/Image_resources
Documentation
Upgrade to Fedora 19; Easy as 1, 2 ,3…
Upgrade form Fedora 18 to 19 with FedUp with 3 easy steps..
1. Install FedUp
$ sudo yum install fedup
2. Run FedUp
$ sudo fedup-cli --network 19
3. Executing the Upgrade
Reboot and select System Upgrade form Grub menu.
* there are some recommended post upgrade steps but they are optional, I do recommend cleaning up your yum repos with a distro sync see the link below for more info
Managing OpenStack with The Foreman
Great post
What is a Cloud?
The term “Cloud Computing” gets thrown around a lot these days, and while it does solve a lot of interesting problems, there is also a lot of confusion on what it really is, and I have not seen an easy to read, high level overview.
So, What is a Cloud?
While this seems like a simple question, usually its not easy to answer. This is because CLOUD means different things to different people, and it solves different problems for different customers. However, in its simplest form, a CLOUD is really just computing delivered as a service. Whether its Infrastructure as a Service (IAAS) like Amazon EC2, Platform as as Service (PAAS) like Google app engine, or Software as a Service (SAAS) like SalesForce.com; all the end user cares about is, I need a resource to run a workload and I don’t care how or what happens under the covers, as long as I get the results I need.
my Gnome3 experience

I have been avoiding updating to a newer version of Fedora for a while now, mainly because I have been very hesitant about the new Gnome3 desktop environment. Recently I took the Fedora 18 plunge and this post contains a couple of tricks and tips I learned along the way.
Atrix CM7
I have been really frustrated with my phone lately. I’ve wanted to flash it with a non ATT ROM for while now however I haven’t had the time and the Atrix’s locked boot loader has made this project a non-starter for me. Not to mention that all the tools required to flash Android devices require windows boxes which is beyond me.
When the phone’s blue-tooth stopped working it was the last straw. I had some spare time today and commandeered my girlfriends windows laptop for a couple hours to give it a try. There is a lot of info out there on how to do do this, however the instructions were still not very clear to me. After reading a couple different xda forum posts and watching a couple of videos, I gave it a shot. Basically there are three things you need to do: 1)Unlock the boot-loader, 2) root the phone, 3) install a custom ROM. This post contains a steps I used to install CM7 on my ATT Motorola Atrix 4g. For more info check out this thread at XDA forums….
http://forum.xda-developers.com/showthread.php?t=1154600
However if you are still confused like I was, here are the three steps that need to be done and the order I did them in……
HUFFISLAND back up
After being down for a bout a year we are back up and running. I have imported some old tech post and have more to come, stay tuned…..
How to clean a LUN
RHEV 3.0 and earlier requires a clan LUN to create a new storage domain. This is done intentionally so you do not overwrite existing data. However if you want to force RHEV to use a LUN with existing data you can wipe out the first 512 bytes of the lun to fool RHEV in to thinking the LUN is empty.
basically there are two steps………
1. Find the path to the LUN
Run the command “multipath -ll” on a host to see whether it “sees” the SAN luns or not, the output will look something like this if it “sees” the LUN:
mpath1 (3600d0230003228bc000339414edb8101) [size=100 GB][features=”0″][hwhandler=”0″]
\_ round-robin 0 [prio=1][active]
\_ 2:0:0:6 sdb 8:16 [active][ready]
\_ round-robin 0 [prio=1][enabled]
\_ 3:0:0:6 sdc 8:64 [active][ready]
If you do not see the LUN in the multipath output it means that the host can not access the LUN, ie its not presented correctly to the host. Check you SAN ACLS. If you are using ISCSI make sure you are logged in. see my post on ISCSI notes for more info.
2. “Clean” the LUN. The LUN must be empty to add to the RHEV-M. You can use “dd” to wipe out the first 512 bytes of the lun to fool RHEV in to thinking the LUN is empty.
dd if=/dev/zero of=/dev/path/to/LUN bs=1024k count=10
doc:https://access.redhat.com/discussion/after-re-installation-rhev-lun-not-visible-rhevm-gui
how-to setup Win 2008R2 as NFS server
Sometimes it is helpful to set up windows as a NFS server to transfer files between a windows and Linux machine. This is especially useful when setting up a RHEV (2.2 not relevant any more with 3.0) environment and you do not have a NFS server or extra Linux box available for your ISO or Export domain. Its pretty straight forward however having this doc and the exact folder permission saves some time when setting up a NFS server in Windows.
Spice qxl drivers guest
To configure a virtual guest to use the qxl drivers for Video when using Spice create the file “/etc/X11/xorg.conf.d/01-qxl.conf” and add the following lines”
Section "Device" Identifier "Viedocard0" Driver "qxl" EndSection
how-to Create Virtual Bridge
This is kinda old, but pretty helpful. I find myself referring to these notes often so I thought I would share
1. Create Virtual Bridge
# brctl addbr br0
verify with: brctl show
2. Create network script, edit /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE=br0
TYPE=Bridge
BOOTPROTO=dhcp
ONBOOT=yes
3. Edit eth0 network script add…
BRIDGE=br0
4. Add your physical interface to the bridge
# brctl addif br0 eth0
verify with: brctl show
5. Restart your network services
# service network restart
References:
http://www.linux-kvm.com/content/using-bridged-networking-virt-manager
iscsi notes
discover:
# iscsiadm -m discovery -t sendtargets -p 192.168.1.100
login:
# iscsiadm -m node -T iqn.1991-05.com.microsoft:winserver-win -server-iscsi-target-target -p 192.168.1.100 –login
find mapping:
# ll /dev/disk/by-path/ -> /sdb
make part:
# fdisk /dev/sdb
format:
# mkfs.ext3 /dev/sdb1
mke2fs 1.39 (29-May-2006)
/dev/sdb1 is apparently in use by the system; will not make a filesystem here!
logout:
# iscsiadm -m node -T iqn.1991-05.com.microsoft:winserver-win
-server-iscsi-target-target -p 192.168.1.100 –logout
On target:
Define an iSCSI target name:
# tgtadm –lld iscsi –op new –mode target –tid=1 –targetname iqn.2010-10.local.rhev:target1
To view the currect configuration:
# tgtadm –lld iscsi –op show –mode target
Add it as a logical unit to the target:
# tgtadm –lld iscsi –op new –mode logicalunit –tid 1 –lun 1 -b /dev/sdb
addip:
tgtadm –lld iscsi –op bind –mode=target –tid=1 –initiator-address=192.168.1.102
Hello world!
sup