<?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>inutility.net</title>
	<atom:link href="http://inutility.net/feed" rel="self" type="application/rss+xml" />
	<link>http://inutility.net</link>
	<description>for all things useless</description>
	<lastBuildDate>Thu, 08 Dec 2011 14:17:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Acronym overload: Migrating Xen PVM hosts to KVM HVM hosts</title>
		<link>http://inutility.net/2011/12/08/acronym-overload-migrating-xen-pvm-hosts-to-kvm-hvm-hosts</link>
		<comments>http://inutility.net/2011/12/08/acronym-overload-migrating-xen-pvm-hosts-to-kvm-hvm-hosts#comments</comments>
		<pubDate>Thu, 08 Dec 2011 14:17:34 +0000</pubDate>
		<dc:creator>al</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[Virtualisation]]></category>

		<guid isPermaLink="false">http://inutility.net/?p=86</guid>
		<description><![CDATA[I have a server I&#8217;ve been using which does not have  hardware virtualisaton (HVM). On this I&#8217;ve been using Xen paravirtualisation (PVM). This is all well and good, except the server is approaching six years old and I&#8217;ve a shiney &#8230; <a href="http://inutility.net/2011/12/08/acronym-overload-migrating-xen-pvm-hosts-to-kvm-hvm-hosts">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I have a server I&#8217;ve been using which does not have  hardware virtualisaton (HVM). On this I&#8217;ve been using Xen paravirtualisation (PVM). This is all well and good, except the server is approaching six years old and I&#8217;ve a shiney new server that does support HVM that I&#8217;d like to use.</p>
<p><strong>Warning: Acronym overload ahead&#8230;</strong></p>
<p><span id="more-86"></span>Given that the virtual machines (VM), in Xen parlance these are known as DomU, are not going to change I thought it easier to try and migrate the hosts over one by one.</p>
<p>They are all running Debian, though not all the same version nor the same architecture (i386/amd64). Some are running Lenny rather than Squeeze and I don&#8217;t want to force myself to upgrade just yet.</p>
<p>The plan of action. This is a plan, not exact details. I&#8217;ll probably add them in blow</p>
<ul>
<li>Create a logical volume (LV) on the host with LVM to contain all of the VM disk space.</li>
<li>Create a &#8220;test&#8221; VM. This is required as I&#8217;m going to create an LVM volume group (VG) within the LV I just created, and I seem unable to do this on the host. I could be wrong about that</li>
<li>Add the VM LV as a secondary disk to the &#8220;test&#8221; VM &amp; start the &#8220;test&#8221; VM</li>
<li>On the VM disk create two partitions. One 500Mb (for /boot) and one containing the rest for LVM.</li>
<li>Create LV paritions for / /var /usr &amp; /home as neccessary. Mount in the usual file structure</li>
<li>Stop services on the source machine (except SSH obviously) and rsync files over SSH</li>
<li>Modify files as neccessary (such as /etc/fstab) to accomodate changes</li>
<li>Chroot to the mount point and install LVM2 if not installed.</li>
<li>Shut down &#8220;test&#8221; VM</li>
<li>Create VM for the copied machine and include the KVM host&#8217;s kernel &amp; initrd. This will allow it to boot as Xen PVMs do not have a kernel or Grub</li>
<li>Start the KVM, all should boot okay if you updated. This will fail if LVM2 package is not installed</li>
<li>Install a kernel and Grub. Shut down the VM</li>
<li>Remove the KVM hosts kernel &amp; initrd and start the VM It should boot Grub in the VM and all should be well</li>
</ul>
<p><em>I expect to add a more detailed description on this later.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://inutility.net/2011/12/08/acronym-overload-migrating-xen-pvm-hosts-to-kvm-hvm-hosts/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fun with KVM on Squeeze</title>
		<link>http://inutility.net/2011/09/16/fun-with-kvm-on-squeeze</link>
		<comments>http://inutility.net/2011/09/16/fun-with-kvm-on-squeeze#comments</comments>
		<pubDate>Fri, 16 Sep 2011 22:45:46 +0000</pubDate>
		<dc:creator>al</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[kvm]]></category>
		<category><![CDATA[squeeze]]></category>
		<category><![CDATA[virtualisation]]></category>

		<guid isPermaLink="false">http://inutility.net/?p=73</guid>
		<description><![CDATA[Have recently received a server from a friend which I&#8217;m going to be using to replace my existing one. It&#8217;s currently running a handful of virtual hosts with Xen using paravirtualisation. The new server has hardware virtualisation so I thought &#8230; <a href="http://inutility.net/2011/09/16/fun-with-kvm-on-squeeze">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Have recently received a server from a friend which I&#8217;m going to be using to replace my existing one. It&#8217;s currently running a handful of virtual hosts with Xen using paravirtualisation. The new server has hardware virtualisation so I thought I would try KVM as it seems more in vogue these days. There is a useful <a href="http://www.howtoforge.com/virtualization-with-kvm-on-a-debian-squeeze-server" target="_blank">KVM/Debian Squeeze Howto </a>on HowtoForge.com which gave me a good grounding on most things.</p>
<p>It seems quite good so far, but not without some minor issues.</p>
<h2><span id="more-73"></span>Boot order</h2>
<p>I experienced a problem between the cgroups and libvirt-bin. By default it seems that cgroups (<em>/etc/init.d/cgred</em>) starts before libvirt-bin and this stopped my virtual machines from starting up. It gave the following errors trying to start the &#8220;test1&#8243; virtual machine (VM).</p>
<pre>warning : qemudParsePCIDeviceStrs:1422 : Unexpected exit status '1', qemu probably failed
error : qemuSetupCgroup:3416 : Unable to create cgroup for test1: No such file or directory
error : qemuRemoveCgroup:3501 : internal error Unable to find cgroup for test1#012
warning : qemudShutdownVMDaemon:4067 : Failed to remove cgroup for test1</pre>
<p>Not being too knowledgeable with the new dependency based boot system it took me a while to work out how to get it to change the order but eventually I edited /etc/init.d/libvirt.bin and changed the line</p>
<pre># Required-Start:    $network $remote_fs $syslog</pre>
<p>to</p>
<pre># Required-Start:    $network $remote_fs $syslog cgred</pre>
<p>Then you need to apply this change with the following command:</p>
<pre>insserv libvirt-bin</pre>
<p>This makes the dependency make sure it starts after cgred. Whether this is the &#8220;official&#8221; way I don&#8217;t know, but this now works correctly for me.</p>
<h2>Starting VM at boot</h2>
<p>By default new virtual machines do not start with the computer but this can be enabled:</p>
<pre>virsh autostart &lt;vmname&gt;</pre>
<p>as well as disabled</p>
<pre>virsh autostart &lt;vmname&gt; --disable</pre>
<h2>Shutting down VMs on reboot/shutdown</h2>
<p>As I only have on server I will be wanting to (at least try to) shut down virtual machines when I shutdown or reboot rather than killing them which seems to happen by default. <a href="http://exain.wordpress.com/2009/05/22/auto-shutdown-kvm-virtual-machines-on-system-shutdown/">An entry on Vivek&#8217;s blog </a>has a script which can do this. It has been noted in the comments that this does not get called with the new Debian dependency boot scripts.</p>
<p>I have, for now hacked my libvirt-bin init.d script, amendnig the &#8220;<em>stop</em>&#8221; section to call this script just before the libvirt daemon is shutdown.</p>
<p>Not the most elegant, but works for now. I&#8217;ll have to try and tidy that up.</p>
]]></content:encoded>
			<wfw:commentRss>http://inutility.net/2011/09/16/fun-with-kvm-on-squeeze/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debian Squeeze, Active Directory &amp; Samba</title>
		<link>http://inutility.net/2011/08/04/debian-squeeze-active-directory-samba</link>
		<comments>http://inutility.net/2011/08/04/debian-squeeze-active-directory-samba#comments</comments>
		<pubDate>Thu, 04 Aug 2011 11:45:12 +0000</pubDate>
		<dc:creator>al</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[samba]]></category>
		<category><![CDATA[squeeze]]></category>
		<category><![CDATA[winbind]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[Windows Server 2008]]></category>

		<guid isPermaLink="false">http://inutility.net/blog/?p=30</guid>
		<description><![CDATA[This originally started as a note to myself should I ever need to revisit this, but I have expanded it a bit to make it a bit more general in case others might find it useful. I use Debian Squeeze &#8230; <a href="http://inutility.net/2011/08/04/debian-squeeze-active-directory-samba">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This originally started as a note to myself should I ever need to revisit this, but I have expanded it a bit to make it a bit more general in case others might find it useful.</p>
<p>I use Debian Squeeze on our Linux servers. I have been trying to get them to authenticate off of our Active Directory/Windows Server 2008. Previously we used OpenLDAP and this worked well, but with AD I&#8217;d rather have one authentication system. One password rather than two.</p>
<p>My experience with Winbind has not been favourable. Despite documentation and plenty of blogs with <a title="Debian joining windows domain" href="http://zeldor.biz/2010/12/debian-join-windows-domain/" target="_blank">well written examples</a> of how to do it I could not get it to work for me. Most of what is written is from there.</p>
<p><span id="more-30"></span>In this blog I will use the following settings on my network which I will use in my examples. You will wish to change them to reflect your own settings:</p>
<p>server1.int.inutility.net &#8211; 192.168.188.10 &#8211; Windows Active Directory &amp; WINS server<br />
server2.int.inutility.net -  192.168.188.11 &#8211; Windows Active Directory server<br />
linux.int.inutility.net &#8211; 192.168.188.20 &#8211; Debian Linux box to authenticate against AD<br />
INUTILITY &#8211; Windows Domain<br />
INT.INUTILITY.NET &#8211; Kerberos/AD Realm</p>
<h2>Preparation</h2>
<h3>Active Directory</h3>
<p>You can edit this using the &#8220;Active Directory Users &amp; Computers&#8221; program on your Windows server, finding a user (or group) and going to the &#8220;UNIX Attributes&#8221; tab. If you do not have this tab then you are missing the &#8220;Identify Management for UNIX&#8221; role, and you probably want to investigate that before following this.</p>
<h3>DNS</h3>
<p>If you are just using Windows DNS and Windows DHCP then you are probably already set for this and can probably skip this section.</p>
<p>You need to make sure your domain name is correct.  If you use a mixture of Windows &amp; Linux services (for DHCP &amp; DNS) then you need to make sure your /etc/resolv.conf has the correct &#8220;domain&#8221; setting to match the DNS of your Windows servers. If not it is possible you may experience a problem later. This may be set manually or automatically from your DHCP server</p>
<p>Secondly you need to make sure your Windows DNS servers are configured. My /etc/resolv.conf is</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="text" style="font-family:monospace;">domain int.inutility.net
search int.inutility.net
nameserver 192.168.188.10
nameserver 192.168.188.11</pre></td></tr></table></div>

<h3>NTP</h3>
<p>It&#8217;s good practice to have time syncronised up. My Windows servers both provide NTP service.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">apt-get install ntp</pre></div></div>

<p>Edit the /etc/ntp.conf file, commenting out the existing debian servers and adding in your servers</p>
<p>Line 21</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>21
22
23
24
25
26
27
</pre></td><td class="code"><pre class="text" style="font-family:monospace;">#server 0.debian.pool.ntp.org iburst
#server 1.debian.pool.ntp.org iburst
#server 2.debian.pool.ntp.org iburst
#server 3.debian.pool.ntp.org iburst
&nbsp;
server server1.int.inutility.net iburst
server server2.int.inutility.net iburst</pre></td></tr></table></div>

<p>You will then need to restart the NTP daemon:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">/etc/init.d/ntpd restart</pre></div></div>

<p>This may take some time to syncronise your Debian server&#8217;s clock with that of the Windows Servers&#8217;. Check your syslog. <strong>ntpd -q</strong> will report information on your time servers and syncronisation.</p>
<h2>Installation</h2>
<h3>LDAP Authentication</h3>
<p>This allows you to authenticate your users against the Active Directory using LDAP. It allows you to SSH into your server as your AD users and is required to access your server using Samba.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">apt-get install libnss-ldapd libpam-ldapd nslcd unscd</pre></div></div>

<p>This is not to be confused to libpam-ldap and libnss-ldap (no d at the end) which are older methods of LDAP authentication that I have not satisfactorily got working with Active Directory.</p>
<p>It will ask you a few questions while the packages install. For LDAP server URI I entered both my AD servers:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">ldap://server1.int.inutility.net/ ldap://server2.int.inutility.net/</pre></div></div>

<p>You can leave it at one server, or add as many as you want separated by spaces.</p>
<p>You will be asked for your LDAP server search base. It will guess this based on your DNS domain, but sometimes it gets the ending wrong (espcially with country codes). I entered:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">dc=in,dc=inutility,dc=net</pre></div></div>

<p>You will then need to select the Name Services to use with LDAP. Select &#8220;<em>group</em>&#8220;, &#8220;<em>passwd</em>&#8221; and &#8220;<em>shadow</em>&#8220;. It will then finish installation, but there is still a bit to be configured.</p>
<p>It will automatically edit your PAM files (in /etc/pam.d) and your /etc/nsswitch.conf with correct entries so you do not have to unless your set up is a bit unusual. For historical reasons our UIDs start at 500 so I edited the /etc/pam.d/common-* files so the &#8220;<em>minimum_uid</em>&#8221; entry was <strong>500</strong>, not the default <strong>1000</strong>.</p>
<p>I use TLS encryption to my servers, using a certificate we have purchased. It requires intermediate certificates which it terms a bundle. You may not require the &#8220;<em>tls_cacertfile</em>&#8221; entry, but you may require the &#8220;<strong>ca-certificates</strong>&#8221; Debian package installed. Using the &#8220;<strong>tls_reqcert demand</strong>&#8221; entry makes sure that if the certificate is not verified the connection will not proceed.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>25
26
27
28
</pre></td><td class="code"><pre class="text" style="font-family:monospace;"># SSL options
ssl starttls
tls_reqcert demand
tls_cacertfile /etc/ssl/certs/bundle.crt</pre></td></tr></table></div>

<p>You also require some entries in this file so it knows where to pull all the user information from:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>36
37
38
39
40
41
42
43
44
45
46
47
</pre></td><td class="code"><pre class="text" style="font-family:monospace;"># Mappings for Active Directory
pagesize 1000
referrals off
filter passwd (&amp;amp;(objectClass=user)(!(objectClass=computer))(uidNumber=*)(unixHomeDirectory=*))
map    passwd uid              sAMAccountName
map    passwd homeDirectory    unixHomeDirectory
map    passwd gecos            displayName
filter shadow (&amp;amp;(objectClass=user)(!(objectClass=computer))(uidNumber=*)(unixHomeDirectory=*))
map    shadow uid              sAMAccountName
map    shadow shadowLastChange pwdLastSet
filter group (&amp;amp;(objectClass=group)(gidNumber=*))
map    group  uniqueMember     member</pre></td></tr></table></div>

<p>After restarting nslcd you should then be able to check users &amp; groups are listed using the <strong>getent</strong> tool:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">/etc/init.d/nslcd restart
Restarting LDAP connection daemon: nslcd.
getent passwd al
al:*:1000:100:Al:/home/al:/bin/bash</pre></div></div>

<p>You should now be able to SSH into your machine as your Active Directory users, though they may not have home directories (see also the section &#8220;<em>Automatic creation of user&#8217;s home directory</em>&#8221; towards the bottom of the page).</p>
<h3>Kerberos</h3>
<p>Install the Kerberos packages:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">apt-get install krb5-config krb5-user</pre></div></div>

<p>Then edit /etc/krb5.conf to include entries for your realm:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="text" style="font-family:monospace;">[libdefaults]
 default_realm = INT.INUTILITY.NET</pre></td></tr></table></div>

<p>and</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>39
40
41
42
43
44
45
</pre></td><td class="code"><pre class="text" style="font-family:monospace;">[realms]
        INT.INUTILITY.NET= {
                kdc = 192.168.188.10:88
                admin_server = 192.168.188.10
                default_domain = int.inutility.net
        }
        ATHENA.MIT.EDU = {</pre></td></tr></table></div>

<p>and</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>122
123
124
125
</pre></td><td class="code"><pre class="text" style="font-family:monospace;">[domain_realm]
        .int.inutility.net = INT.INUTILITY.NET
        int.inutility.net = INT.INUTILITY.NET
        .mit.edu = ATHENA.MIT.EDU</pre></td></tr></table></div>

<h3>Samba</h3>
<p>Firstly you&#8217;ll need to install the samba packages:</p>
<pre>apt-get install samba samba-common samba-common-bin</pre>
<p>I was asked only for my &#8220;<em>Workgroup/Domain Name</em>&#8221; which I entered in as &#8220;<strong>INUTILITY</strong>&#8221; during installation.</p>
<p>Then you need to make some edits to your /etc/samba/smb.conf.</p>
<p>Add the Kerberos realm:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>37
38
39
</pre></td><td class="code"><pre class="text" style="font-family:monospace;"># Change this to the workgroup/NT-domain name your Samba server will part of
   workgroup = IFS-LON
   realm = LONDON.IFS.ORG.UK</pre></td></tr></table></div>

<p>Add in WINS server:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>48
49
50
</pre></td><td class="code"><pre class="text" style="font-family:monospace;"># WINS Server - Tells the NMBD components of Samba to be a WINS Client
# Note: Samba can be either a WINS Server, or a WINS Client, but NOT both
   wins server = 192.168.188.10</pre></td></tr></table></div>

<p>To use Active Directory security:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>99
100
101
102
103
</pre></td><td class="code"><pre class="text" style="font-family:monospace;"># &quot;security = user&quot; is always a good idea. This will require a Unix account
# in this server for every user accessing the server. See
# /usr/share/doc/samba-doc/htmldocs/Samba3-HOWTO/ServerType.html
# in the samba-doc package for details.
   security = ads</pre></td></tr></table></div>

<p>To configure SAMBA not to be the master browser for the domain.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>210
211
212
213
214
215
</pre></td><td class="code"><pre class="text" style="font-family:monospace;"># Domain Master specifies Samba to be the Domain Master Browser. If this
# machine will be configured as a BDC (a secondary logon server), you
# must set this to 'no'; otherwise, the default behavior is recommended.
   domain master = no
   local master = no
   preferred master = no</pre></td></tr></table></div>

<p>Restart the samba services to load these settings.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">/etc/init.d/samba restart</pre></div></div>

<h3>Joining the domain</h3>
<p>You can not joing the domain with the following command (or another administrator account can be used)</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">net ads join -U Administrator</pre></div></div>

<p>This suceeds, but reports:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">kerberos_kinit_password LINUX$@INT.INUTILITY.NET failed: Client not found in Kerberos database</pre></div></div>

<p>This is something I&#8217;ve not been able to trace down yet, but everything works as expected. I have been advised that this may in fact be down to our incorrect reverse DNS.</p>
<p>You should now be able to access the machine using <strong>\\LINUX</strong> as per a normal Windows server.</p>
<h2>Other useful things</h2>
<h3>Automatic creation of user&#8217;s home directory</h3>
<p>If you edit /etc/pam.d/common-session you can add an entry to automatically create a user&#8217;s home directory upon login:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>28
</pre></td><td class="code"><pre class="text" style="font-family:monospace;">session     required      pam_mkhomedir.so skel=/etc/skel umask=0022 silent</pre></td></tr></table></div>

<p>This saves you having to manually copy the /etc/skel files for any users who have not logged into the system before.</p>
<h3>Leaving the AD Domain</h3>
<p>This can be done using the command below and removes your computer&#8217;s entry from the Active Directory:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">net ads leave -U Administrator</pre></div></div>

<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://inutility.net/2011/08/04/debian-squeeze-active-directory-samba/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

