<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Virtualization &#8211; SophieDogg</title>
	<atom:link href="https://sophiedogg.com/tag/virtualization/feed/" rel="self" type="application/rss+xml" />
	<link>https://sophiedogg.com</link>
	<description>Dogg of all trades, Master of no one.</description>
	<lastBuildDate>Sat, 09 Oct 2021 12:02:52 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.6.1</generator>
	<item>
		<title>KVM Clocks and Time Zone Settings</title>
		<link>https://sophiedogg.com/kvm-clocks-and-time-zone-settings/</link>
		
		<dc:creator><![CDATA[SophieDogg]]></dc:creator>
		<pubDate>Wed, 21 Dec 2011 17:13:36 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[KVM]]></category>
		<category><![CDATA[QEMU]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Virtualization]]></category>
		<guid isPermaLink="false">http://sophiedogg.com/?p=221</guid>

					<description><![CDATA[So the other day there was an extended power outage down at the dogg pound, and one of my non-essential server racks had to be taken off-line. This particular server rack only has UPS battery backup, but no generator power (like the others), and upon reboot, the clocks in all my QEMU Linux VM&#8217;s were [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>So the other day there was an extended power outage down at the dogg pound, and one of my non-essential server racks had to be taken off-line.  This particular server rack only has UPS battery backup, but no generator power (like the others), and upon reboot, the clocks in all my QEMU Linux VM&#8217;s were wrong!  They kept getting set to UTC time instead of local time&#8230;  After much searching and testing, I finally found out what was necessary to fix this issue.  <span id="more-221"></span></p>
<p>First, we need to make sure that all of our time settings are correct.  Let&#8217;s compare the hardware clock settings to the current real time, which is <b>11:13AM EST</b>:</p>
<pre>[16:13] root@ns3:~ # hwclock
Wed 21 Dec 2011 04:13:49 PM EST  -0.297984 seconds
[16:13] root@ns3:~ # date
Wed Dec 21 16:13:07 EST 2011
[16:13] root@ns3:~ #</pre>
<p>Well, here we can see that the hardware and system clocks are wrong!  KVM/QEMU likes to keep its &#8220;hardware time&#8221; as UTC, so it takes the time from the host system and adjusts it to UTC, based off of the host system&#8217;s timezone setting.  The host system shows the correct time (and actually this physical host machine&#8217;s hardware time is set to local, not UTC).</p>
<p>Ok, well lets make sure our timezone is set correct.  The /etc/localtime file represents the timezone info for your particular time zone.  This can either be a symbolic link to the correct file, or a copy of the correct file.  On my system, it looks like this:</p>
<pre>[16:20] root@ns3:~ # ls -alh /etc/localtime
lrwxrwxrwx 1 root root 36 Dec 21 15:14 /etc/localtime -> /usr/share/zoneinfo/America/New_York
[16:21] root@ns3:~ #</pre>
<p>Now, you can either make a symbolic link using the command</p>
<pre>ln -s /usr/share/zoneinfo/America/New_York /etc/localtime</pre>
<p>or you can copy the zone file with the command</p>
<pre>cp /usr/share/zoneinfo/America/New_York /etc/localtime</pre>
<p>There are arguments for and against each method, use whichever method you prefer.</p>
<p>Next, we need to check our <tt>/etc/sysconfig/clock</tt> file to make sure it is correct.  My file looks like this:</p>
<pre>ZONE="America/New_York"</pre>
<p>Some users will add a line that says <tt>UTC="true"</tt> (or false), but it isn&#8217;t needed and can just add confusion.</p>
<p>Finally, we need to check the <tt>/etc/adjtime</tt> file; this file was the key!  The 3rd line in the file will say either UTC or LOCAL.  Since our hardware clock was set to UTC time (as shown above), we need to change our adjtime file to say UTC instead of LOCAL.  Here is what mine looks like:</p>
<pre>-15185.281863 1324482636 0.000000
1324482636
UTC</pre>
<p>So now everything should be set to keep the system time correct after a hard reboot (power off &#038; on), but our current clock is still wrong!  Well, we can fix the current time with the following command:</p>
<pre>[16:24] root@ns3:~ # hwclock --utc -s
[11:24] root@ns3:~ #</pre>
<p>This will set our system time from the hardware clock, stating that the hardware clock is kept in UTC time.</p>
<p>Now, in order to test everything, we need to completely power down the virtual machine and restart it.  Simply issuing a <tt>reboot</tt> won&#8217;t force our host machine to apply it&#8217;s time settings to the VM.  Previously, after every hard boot the time would be wrong, but now it&#8217;s correct!</p>
<p>You should also set up some NTP time synchronization to keep your time accurate; but this will at least keep the zone correct between power cycles.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Creating a new KVM server on a headless machine</title>
		<link>https://sophiedogg.com/creating-a-new-kvm-server-on-a-headless-machine/</link>
		
		<dc:creator><![CDATA[SophieDogg]]></dc:creator>
		<pubDate>Tue, 30 Aug 2011 16:40:40 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Virtualization]]></category>
		<guid isPermaLink="false">http://sophiedogg.com/?p=166</guid>

					<description><![CDATA[One of the things any good sysadmin dogg wants to do is setup some virtual servers. Who wants to actually stand in front of a server to do that?! What if the machine is headless (no monitor attached)? Well, as long as we have SSH access to the machine, we can do everything from the [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>One of the things any good sysadmin dogg wants to do is setup some virtual servers. Who wants to actually stand in front of a server to do that?! What if the machine is headless (no monitor attached)? Well, as long as we have SSH access to the machine, we can do everything from the dogghouse!<span id="more-166"></span></p>
<p>The first thing you want is to start with a nice server with a good OS installed. I&#8217;m starting with the CentOS 6 operating system, and a newer Dell Poweredge server. Obviously the more powerful the hardware, the better, but you will want something that supports full hardware virtualization, which is important for security, stability, and speed, among other things.  Check in your BIOS for something like &#8220;Enable Virtualization.&#8221;  Check with your hardware manufacturer for details.</p>
<p>After you have your initial server set up, you&#8217;ll need to add some packages for virtualization support. We&#8217;ll use the yum groupinstall command to get our necessary package groups, then install the bridge software separately, make sure everything is up to date, and finally restart the server so that we have the latest kernel running.</p>
<pre>bash# yum groupinstall "Virtualization" "Virtualization Client"
bash# yum groupinstall "Virtualization Platform" "Virtualization Tools"
bash# yum install bridge-utils
bash# yum update
bash# reboot</pre>
<p>When you reconnect to your host machine, make sure to forward some ports so you can tunnel to the VM&#8217;s console display! With putty, you can use a command like this:</p>
<pre>putty.exe -L 5900:127.0.0.1:5900 -L 5901:127.0.0.1:5901 user@server</pre>
<p>This will forward two ports for us, 5900 and 5901 to the localhost (the machine we&#8217;re connecting to) that we will use for VNC connections.  Our first VM will use port 5900, our second VM will use port 5901, and so on.  You can easily add more port forwards to your SSH connection to enable connecting to additional VM&#8217;s.</p>
<p>The first thing we need to do are set up some network bridges. There are a lot of different ways to configure network bridges, but we&#8217;re going to keep this one simple. Let&#8217;s say our machine has two physical network interfaces, eth0 and eth1. We&#8217;re going to assume that both interfaces are connected to the same network (so we can&#8217;t bridge them together), that we will use eth0 to connect to our physical machine (aka hypervisor, dom0, host, or manager), and that eth1 has no IP address. So, just create a separate bridge for each physical interface, br0 and br1.</p>
<p>Start by configuring eth0 (/etc/sysconfig/network-scripts/ifcfg-eth0):</p>
<pre>DEVICE="eth0"
HWADDR="12:34:56:78:90:ab"
NM_CONTROLLED="no"
ONBOOT="yes"
IPADDR=10.0.0.100
GATEWAY=10.0.0.1
TYPE=Ethernet
BOOTPROTO=none
NETMASK=255.255.255.0
USERCTL=no
PEERDNS=yes
IPV6INIT=no
SEARCH=mydomain.com
DNS1=10.0.0.1
DNS2=10.0.0.2
DNS2=8.8.8.8
BRIDGE=br0</pre>
<p>You could optionally configure eth0 to use DHCP, if desired. Be careful when remotely making changes to your active network connection; a misconfiguration could make you unable to connect!</p>
<p>Next, lets configure eth1 (/etc/sysconfig/network-scripts/ifcfg-eth1):</p>
<pre>DEVICE="eth1"
HWADDR="12:34:56:78:90:cd"
NM_CONTROLLED="no"
ONBOOT="yes"
BRIDGE=br1</pre>
<p>Restart the network connections to make sure everything is working so far:</p>
<pre>bash# service network restart</pre>
<p>Now that our physical interfaces are configured, lets configure some bridges! We can just edit the bridge scripts, so open the files and configure them already!</p>
<p>Bridge device br0 (/etc/sysconfig/network-scripts/ifcfg-br0):</p>
<pre>DEVICE=br0
BOOTPROTO=none
ONBOOT=yes
TYPE=Bridge</pre>
<p>Bridge device br1 (/etc/sysconfig/network-scripts/ifcfg-br1):</p>
<pre>DEVICE=br1
BOOTPROTO=none
ONBOOT=yes
TYPE=Bridge</pre>
<p>Restart the network services again, and we&#8217;re ready to go!</p>
<pre>bash# service network restart</pre>
<p>Check that our bridge devices exist with the following command:</p>
<pre>bash# brctl show
bridge name     bridge id               STP enabled     interfaces
br0             8000.842b2b03fa01       no              eth0
br2             8000.0010186e94e8       no              eth2</pre>
<p>This shows us that br0 has interface eth0, and br1 has interface eth1.</p>
<p>Ok, so now that we have our host correctly configured, we need an OS to install! You can use a disk drive with the OS installation, install from something provided on the network, or go get a .iso of your favorite OS, and install from there. We&#8217;ll just use an .iso. Take a look at the following command:</p>
<pre>bash# virt-install -n newbawx --vcpus=1 -f /home/vm/newbawx -s 60 -r 2048 --nonsparse -w bridge:br1 --vnc --accelerate -c /tmp/Fedora-15-x86_64-DVD.iso --os-type=linux --os-variant=fedora13 --noautoconsole
Starting install...
Creating storage file newbawx                            |  60 GB     04:43
Creating domain...                                       |    0 B     00:00
Domain installation still in progress. You can reconnect to
the console to complete the installation process.</pre>
<p>First we use the <tt>virt-install</tt> command to create a new virutal machine named newbawx. We give it a hard drive size of 60GB (-s 60), 2GB of RAM (-r 2048), tell it to use bridge 1 (-w bridge:br1), and have it use a Fedora 15 .iso as a virtual CD drive to install from (-c /tmp/Fedora-15-x86_64-DVD.iso). Don&#8217;t forget the <tt>--vnc</tt> option to enable VNC access to the guest console. Notice that the os-variant is fedora13; that is because it is the highest os-variant parameter currently supported for Fedora!</p>
<p>After the <tt>virt-install</tt> command is run, we can optionally set the VM to automatically start with the host server:</p>
<pre>bash# virsh autostart newbawx
Domain newbawx marked as autostarted</pre>
<p>Next, fire up your favorite VNC client and connect to 127.0.0.1:5000. You will be greeted with the installation walkthrough for your guest OS!</p>
<p>Also, if you wanted to delete and remove a virtual machine named newbawx:</p>
<pre>bash# virsh destroy newbawx
bash# virsh undefine newbawx
bash# rm -rf /home/vm/newbawx</pre>
<p>XML files containing your virtual machine settings are located in <tt>/etc/libvirt/qemu/</tt>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
