<?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>Kirichkov.com &#187; CentOS</title>
	<atom:link href="http://kirichkov.com/tag/centos/feed/" rel="self" type="application/rss+xml" />
	<link>http://kirichkov.com</link>
	<description>Bravo Sierra of all sorts</description>
	<lastBuildDate>Wed, 16 Nov 2011 15:13:32 +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>Migrating trixbox/CentOS installation to new hardware</title>
		<link>http://kirichkov.com/203/migrating-trixboxcentos-installation-to-new-hardware/</link>
		<comments>http://kirichkov.com/203/migrating-trixboxcentos-installation-to-new-hardware/#comments</comments>
		<pubDate>Sun, 28 Feb 2010 08:19:06 +0000</pubDate>
		<dc:creator>Georgi</dc:creator>
				<category><![CDATA[Rants]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://kirichkov.com/?p=203</guid>
		<description><![CDATA[It turns out that migrating a linux box to a new hardware is not as easy task as it used to be. I&#8217;m running a Trixbox system on an old 1 GHz Pentium III machine. The owner of the box got another antique &#8211; a Dual 1.4 GHz Pentium III ProLiant DL360 G2 with two [...]]]></description>
			<content:encoded><![CDATA[<p>It turns out that migrating a linux box to a new hardware is not as easy task as it used to be. I&#8217;m running a <a href="http://trixbox.org/" target="_blank">Trixbox</a> system on an old 1 GHz Pentium III machine. The owner of the box got another antique &#8211; a Dual 1.4 GHz Pentium III ProLiant DL360 G2 with two SCSI drives. So I was tasked with migrating the trixbox to the new hardware. It took me about 20 hours to get this working, but all the work can be done in 3-4 hours, depending on how much data you have. This guide requires you to have a basic knowledge of the linux architecture and the linux commands, as well as what is in the <strong>/dev</strong> directory. Due to the fact that trixbox is CentOS-based this guide can easily be applied to migrating a regular CentOS installation .<br />
<span id="more-203"></span><br />
Let me guide you through the procedure how to migrate all your data and information. Here are the necessary ingredients:</p>
<ol>
<li>Two <a href="http://www.sysresccd.org/" target="_blank">System Rescue CDs</a> (one for each machine) &#8211; download is free</li>
<li>Uplink ethernet cable &#8211; or a regular if one of the machines has auto-sensing ethernet NICs</li>
<li>Keyboard, monitors, etc. for both machines. Using a customized System Rescue CD you can do it all over the network, but I used monitors and keyboards, hence I cannot guide you how to make a customized System Rescue CDs</li>
</ol>
<p>The following steps should lead to the complete migration of your trixbox system:</p>
<ol>
<li>Stop the old trixbox and boot it from the first System Rescue CD</li>
<li>Boot the new trixbox-to-be with the second System Rescue CD</li>
<li>Connect both boxes via ethernet cable</li>
<li>Setup the network<br />
<blockquote class="terminal"><p><code>00:00 root@sysresccd /root % net-setup eth0</code></p></blockquote>
<p>The following settings are assumed for the first machine. If you change any of the addresses please note to change them in all operations mentioned bellow:</p>
<blockquote><p>Network type: &#8220;Wired&#8221;, Manually specify IP address<br />
IP Address: 192.168.1.1<br />
Netmask: 255.255.255.0<br />
Broadcast: 192.168.1.255<br />
Gateway: (leave blank)</p></blockquote>
</li>
<li>Do the same for the new machine, just set the IP address to 192.168.1.2 (again, if you decide to use different IPs change accordingly, bellow)</li>
<li>Mount the partitions on the old machine: A typical installation will have separate partitions for / (root), and /boot, thus:<br />
<blockquote class="terminal"><p><code>00:00 root@sysresccd /root % cd /mnt</code><br />
<code>00:00 root@sysresccd /mnt % mkdir hda</code><br />
<code>00:00 root@sysresccd /mnt % mount /dev/hda2 /mnt/hda</code><br />
<code>00:00 root@sysresccd /mnt % mount /dev/hda1 /mnt/hda/boot</code></p></blockquote>
<p><em>hdaX: change accordingly to your configuration &#8211; if you have SCSI drive this will be sda1-8, or if you have a special RAID controller (which was my case) the devices might be in a subdirectory of /dev, e.g.: /dev/cciss/c0d0p2 instead of /dev/hda2.</em></li>
<li>If your new machine&#8217;s hard drives are not partitioned just yet, type <strong>wizard</strong> on the command line of the new machine and use GPartED to partition your new hard drive. <strong>wizzard</strong> will start a graphical interface from where you can start GPartED. I advise you to keep the same partitions as the one you already have on your old machine &#8211; first partition is <strong>/boot</strong>, second partition is <strong>/</strong>, and third partition is swap. Make sure you set the same labels for each partition as they are on the old trixbox</li>
<li>Mount the partitions on the new machine:<br />
<blockquote class="terminal"><p><code>00:00 root@sysresccd /root % cd /mnt</code><br />
<code>00:00 root@sysresccd /mnt % mkdir hda</code><br />
<code>00:00 root@sysresccd /mnt % mount /dev/hda2 /mnt/hda</code><br />
<code>00:00 root@sysresccd /mnt % mkdir /mnt/hda/boot</code><br />
<code>00:00 root@sysresccd /mnt % mount /dev/hda1 /mnt/hda/boot</code></p></blockquote>
<p><em>hdaX: change accordingly to your configuration &#8211; if you have SCSI drive this will be sda1-8. I strongly advise you to keep the directory of the mount point of the root partition (/mnt/hda) intact as its name is irrelevant to the system and it will be easier to follow this guide.</em></li>
<li>View the labels of your partitions on your <strong>old machine</strong> (you may skip this if you already labeled your new drives when partitioning):<br />
<blockquote class="terminal"><p><code>00:00 root@sysresccd /mnt % e2label /dev/hda1<br /> /boot</code><br />
<code>00:00 root@sysresccd /mnt % e2label /dev/hda2<br />/</code></p></blockquote>
</li>
<li>Set the new labels on your <strong>new machine</strong>:<br />
<blockquote class="terminal"><p><code>00:00 root@sysresccd /mnt % e2label /dev/hda1 /boot</code><br />
<code>00:00 root@sysresccd /mnt % e2label /dev/hda2 /</code></p></blockquote>
<p>If you do not set the labels to be the same on your old machine you&#8217;ll end up with an unbootable OS.</li>
<li>Change the password for root on your new box (type anything you can remember):<br />
<blockquote class="terminal"><p><code>00:00 root@sysresccd /mnt % passwd</code><br />
<code>Password:</code></p></blockquote>
</li>
<li>Start pushing the content to your new box. Type on the old box:<br />
<blockquote class="terminal"><p><code>00:00 root@sysresccd /mnt % rsync -av /mnt/hda 192.168.1.1:/mnt/hda</code></p></blockquote>
</li>
<li>When rsync is done transferring your files unmount all disks on your <strong>old system</strong> and shut it down:<br />
<blockquote class="terminal"><p><code>00:00 root@sysresccd /mnt % umount /mnt/hda/boot</code><br />
<code>00:00 root@sysresccd /mnt % umount /mnt/hda</code><br />
<code>00:00 root@sysresccd /mnt % shutdown -h now</code></p></blockquote>
</li>
<li>Chroot to the root (/) partition of your <strong>new system</strong>:<br />
<blockquote class="terminal"><p><code>00:00 root@sysresccd /mnt % cd hda</code><br />
<code>00:00 root@sysresccd /mnt/hda % chroot . bin/bash</code></p></blockquote>
</li>
<li>Setup GRUB on your <strong>new system</strong>:<br />
<blockquote class="terminal"><p><code>[00:00 root@new /] # grub</code><br />
<code>grub&gt; root(hd0,0)</code><br />
<code>grub&gt; setup(hd0)</code></p></blockquote>
<p><em><strong>hd0,0</strong> should be where your boot partition is located and <strong>hd0 </strong>should be the hard drive which will holds your MBR. You might have to edit /boot/grub/devices.map so that <strong>hd0</strong> points to the device name representing your new hard disk</em></li>
<li>Exit the chroot environment:<br />
<blockquote class="terminal"><p><code>[00:00 root@new /] # exit</code></p></blockquote>
</li>
<li>Reboot the system:<br />
<blockquote class="terminal"><p><code>00:00 root@sysresccd /mnt/hda % reboot</code></p></blockquote>
</li>
<li>Remove the CD from the tray and let your new machine boot from the hard drive</li>
<li>That <strong>SHOULD</strong> be it!</li>
</ol>
<h2>Modify your initrd image to add an additional kernel module</h2>
<p>As I said above &#8211; that SHOULD be it, but I doubt very much that this will be it. Most probably you will run into a bunch of problems. Before wondering what&#8217;s going on make sure your new hardware is supported by Trixbox/CentOS. My new hardware for example was using a <a href="http://cciss.sourceforge.net/">HP Smart Array RAID controller</a>. It turned out that this device is supported but the driver was built as a module. Due to this, I was stuck &#8211; the kernel needed a driver to access the hard drive, but the driver (kernel module) was located on the hard drive, thus the kernel could not load it.</p>
<p>There are 2 possible solutions to this:</p>
<p>1. Recompile the kernel and compile the required module (and all modules it depends on) statically in the kernel</p>
<p>2. Modify your Initial Ramdisk image (initrd.img) to accommodate all required modules</p>
<p>In order to recompile the kernel, you can folow the <a href="http://wiki.centos.org/HowTos/Custom_Kernel" target="_blank">CentOS Custom Kernel HOWTO</a>.</p>
<p>If you have never recompiled a kernel, or prefer to go the easy way &#8211; choose the second option</p>
<p>The Initial Ramdisk image is an image that holds a mini-filesystem that holds the bare essentials of a root filesystem and it is used, among other things, to store essential kernel modules &#8211; for accessing your SCSI RAID hard drives, for example.</p>
<p>Here is a quick tutorial how to add a kernel module, in my case the cciss.ko HP/Compaq Smart Array Controller. I used <a href="http://smshaker.wordpress.com/2009/04/09/adding-network-driver-to-pxe-initrdimg/" target="_blank">this tutorial</a> to help me figure out how the initrd image is build. You can also use mkintird to make an image, but I preferred going the manual way.</p>
<ol>
<li>Boot again with the System Rescue CD your <strong>new system</strong> and mount the hard drives (all of them, on their respective mount points)</li>
<li>Use a search engine to find out the driver that you are missing &#8211; I will use <strong>cciss.ko</strong> as an example</li>
<li>Mount your hard drive again and change to the directory of the mount point:<br />
<blockquote class="terminal"><p><code>00:00 root@sysresccd /root % mkdir /mnt/hda</code><br />
<code>00:00 root@sysresccd /root % mount /dev/hda1 /mnt/hda/boot &amp;&amp; cd /mnt/hda</code></p></blockquote>
</li>
<li>Chroot to the hard drive:<br />
<blockquote class="terminal"><p><code>00:00 root@sysresccd /mnt/hda % chroot . bin/bash</code></p></blockquote>
</li>
<li>Copy your current initrd to <strong>/root</strong> on the hard disk. The ramdisk is located in <strong>/boot</strong> and is named <strong>initrd-<em>a.b.c-d.e.f</em>.el5.img</strong>. <em><strong>a</strong></em> to <strong><em>f</em></strong> in the filename represent numbers. When copying the initrd image rename it simply to initrd.img.gz:<br />
<blockquote class="terminal"><p><code>[00:00 root@new /] # cp /boot/initrd-a.b.c-d.e.f.el5.img /root/initrd.img.gz</code></p></blockquote>
</li>
<li>Unpack the image:<br />
<blockquote class="terminal"><p><code>[00:00 root@new /] # cd /root</code><br />
<code>[00:00 root@new /root] # gunzip intird.img.gz</code><br />
<code>[00:00 root@new /root] # mkdir intird</code><br />
<code>[00:00 root@new /root] # cd initrd &amp;&amp; cpio -i –make-directories &lt; ../initrd.img</code></p></blockquote>
</li>
<li>Locate the kernel module you need and all the modules it dependents on and copy them into /root/initrd/lib:<br />
<blockquote class="terminal"><p><code>[00:00 root@new /root] # cd /lib/modules/a.b.c-d.e.f.el5/</code><br />
<code>[00:00 root@new /lib/modules/a.b.c-d.e.f.el5/] # find . -iname "*cciss*"</code><br />
<code>./kernel/drivers/block/cciss.ko</code><br />
<code>[00:00 root@new /lib/modules/a.b.c-d.e.f.el5/] # cp ./kernel/drivers/block/cciss.ko /root/initd/lib/</code></p></blockquote>
<p><em>*  Replace cciss above, with the name of your missing kernel module</em>.<br />
Repeat these steps for every depending module.
</li>
<li>Go to <em>/root/initrd</em><br />
<blockquote class="terminal"><p><code>[00:00 root@new /lib/modules/a.b.c-d.e.f.el5/] # cd /root/initrd</code></p></blockquote>
</li>
<li>edit the init file and make sure you add an <strong>insmod</strong> command for every module you need to load, in the appropriate order, e.g.:<br />
<blockquote class="terminal"><p><code>insmod /lib/cciss.ko</code></p></blockquote>
</li>
<li>create the appropriate device nodes, e.g.:<br />
<blockquote class="terminal"><p><code>mkdir /dev/cciss</code><br />
<code>mknod /dev/cciss/c0d0 b 104 0</code><br />
<code>mknod /dev/cciss/c0d0p1 b 104 1</code><br />
<code>mknod /dev/cciss/c0d0p2 b 104 2</code></p></blockquote>
<p>See the man page for <strong>mknod</strong> for more information.</li>
<li>Pack the initrd image:<br />
<blockquote class="terminal"><p><code>[00:00 root@new /root/initrd/] # (find . | cpio –quiet -c -o) &gt; ../initrd.new.img</code><br />
<code>[00:00 root@new /root/initrd/] # cd ..</code><br />
<code>[00:00 root@new /root/] # gzip initrd.new.img</code></p></blockquote>
</li>
<li>Create a backup copy of your initrd image in case something goes wrong:<br />
<blockquote class="terminal"><p><code>[00:00 root@new /root/] # mv /boot/initrd-a.b.c-d.e.f.el5.img /boot/initrd-a.b.c-d.e.f.el5.img.old</code></p></blockquote>
</li>
<li>Move the initrd image to /boot<br />
<blockquote class="terminal"><p><code>[00:00 root@new /root/] # mv initrd.new.img.gz /boot/initrd-a.b.c-d.e.f.el5.img</code></p></blockquote>
</li>
<li>Reinstall grub<br />
<blockquote class="terminal"><p><code>[00:00 root@new /root/] # grub</code><br />
<code>grub&gt; root (hd0,0)</code><br />
<code>grub&gt; setup (hd0)</code><br />
<code>grub&gt; quit</code></p></blockquote>
</li>
<li>Reboot the system</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://kirichkov.com/203/migrating-trixboxcentos-installation-to-new-hardware/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

