If you are looking for the epic motorcycle journey blog that I've written, please see the Miles By Motorcycle site I put together. 
  • Tricks for Virtualizing a Redhat 6.1 installation.
    07/28/2007 12:46PM
    The machine this site is running on is an old dual PIII 600. The unfortunate thing is that some of the software running on it uses binary-only components that won't run under later versions of linux. So while I work on a replacement for those components, we're stuck running dns1 for the foreseeable future.

    The machine is getting long in the tooth so I needed a fall back plan.

    In the past I successfully virtualized a win95 machine using vmware. So I decided to try the same thing on dns1.

    dns1 has two drives. The first has four partitions on it. The second has one.

    See the article below on getting knoppix to boot off a USB CD ROM drive. The ATAPI cdrom on dns1 had long since died.

    Using dd I created single file images of each machine. In my case, I used had a second USB port on the machine and plugged an ext3 formatted external drive into it.

    First do an fdisk of your two drives and use the 'p' option to print out the partition table of each. You will need this information later when you go to edit your VMWare virtual machine configuration.

    In my case, the two drives were /dev/sda and /dev/sdb.

    fdisk /dev/sda
    press 'p' and hit enter. Copy the information it prints. Exit and repeat for /dev/sdb.

    dd if=/dev/sda  of=sda.dd
    dd if=/dev/sdb  of=sdb.dd

    (obviously you need to be in a directory where you want to deposit the files, either on a large usb drive or possibly samba mounted over some network. In my case I used a large USB drive formatted with the ext3 filesystem. FAT32 won't work as it has a 2gig file size limit.)

    7.5 hours later .... 

    I then copied the two nine gig image files over to a laptop where I could work with them.

    For creating the virtual machine setup I referred to this article. See the bottom of the article as you will most likely want to image the entire drive, not just individual partitions.


    Using VMWare 5.5.1 I created a new blank virtual machine with two 9 gig SCSI drives. To add the second drive go to "Edit this virtual machine" after you've created it. Click on hard disk. Click the Add button at the bottom.

    Some notes on what I did:

    Copy the image files to the directory where you created your new virtual machine.

    Per instructions in the article above edit the two vmdk files to match the geometry of your physical drives.

    In my case, the partition tables on the two drives looked like this:

    Disk /dev/sda: 255 heads, 63 sectors, 1106 cylinders
    Units = cylinders of 16065 * 512 bytes

       Device Boot    Start       End    Blocks   Id  System
    /dev/sda1   *         1       392   3148708+  83  Linux
    /dev/sda2           393      1106   5735205    5  Extended
    /dev/sda5           393       784   3148708+  83  Linux
    /dev/sda6           785       817    265041   82  Linux swap
    /dev/sda7           818      1106   2321361   83  Linux

    Disk /dev/sdb: 255 heads, 63 sectors, 1106 cylinders
    Units = cylinders of 16065 * 512 bytes

       Device Boot    Start       End    Blocks   Id  System
    /dev/sdb1   *         1      1106   8883913+  83  Linux

    The image files were:

    -rw-r--r-- 1 root root 9105018880 Jul 26 17:33 sda.dd
    -rw-r--r-- 1 root root 9105018880 Jul 26 17:33 sdb.dd

    When you edit the vmdk files use "vi". There will be some binary code leading up to the first text strings. Do not touch any of the binary, just edit the text.

    Since my two drives are identical, the two vmdk files are almost identical:

    # Disk DescriptorFile

    # Extent description
    RW 17767890 FLAT "sda.dd" 0

    # The Disk Data Base

    ddb.virtualHWVersion = "4"
    ddb.geometry.cylinders = "1106"
    ddb.geometry.heads = "255"
    ddb.geometry.sectors = "63"
    ddb.adapterType = "buslogic"
    ddb.toolsVersion = "0"

    It has to be "monolithicFlat' for the createType since you have a single image file. For the extent description the referenced article says that you take the size of the dump file and divide it by 512. That yielded 17783240 which is different than multiplying
    63 * 255 * 1106 = 17767890. I used the latter number and it seemed to work fine. Note that if you do not add the "0" at the end of the line, which I did by mistake in my first test, vmware will fail to recognize the drive.

    Also note that vmware does not support emulating an adaptec controller. There are two options, LSI and BusLogic. As the particular install of Redhat 6.1 I had on the old PIII did not have an LSI driver I opted to use the BusLogic driver. This causes a few complications which are dealt with below. The release notes for vmware indicated there may be some problems with the BusLogic driver under Redhat 6.1 but I have not noticed any yet.

    You may also have to edit the .vmx file if you did not choose to create virtual "SCSI" disks in the vmware step. See the references article for more details.

    You can try to boot your VMware virtual machine now and the you should get a boot prompt if you did everything correctly in the steps above, however your old Redhat 6.1 install will not find the file systems and will kernel panic.

    In order to get Redhat 6.1 to be able to talk to your new virtual drives you need to replace the driver you were originally using, in my case Adaptec, with a BusLogic driver. This means rebuilding the "initrd" file, which ended up being a real pain.

    You must find a boot CD that has the same major version of the kernel on it as your old distribution. In this case, RedHat 6.1 runs a Linux 2.2 kernel. Originally I tried to boot using a 2.4 Knoppix CD, but the mkinitrd script would fail. Duh, different major kernel versions.

    So I borrowed a RedHat 6.1 install CD and booted it in rescue mode. (i.e. type linux rescue at the prompt).

    The problem I now faced was the the old RedHat 6.1 CD did not create device entries for /dev/sda1, which is my boot partition.

    To create the device file manually you need to cd to the /dev/ directory and run the command:

    mknod sda1
    b 8 1

    Now you'll have a device file for the partition so you can mount it. (If your boot partition is another device, do a google search on "mknod and the name of the device you want to create and you'll find the parameters)

    Mount your boot partition, which in my case was an ext2 filesystem:

    mkdir /mnt/sda1
    mount -t ext2 /dev/sda1 /mnt/sda1

    You need to chroot into it:

    cdroot /mnt/sda1

    Now you can edit /etc/modules.conf to change your driver which in my case contained:

    alias scsi_hostadapter aic7xxx

    which I changed to

    alias scsi_hostadapter BugLogic

    then cd to /boot and run:

    mkinitrd -v -f /boot/initrd-2.x.y-zz.img 2.x.y-zz,

    Where x.y.-zz is the version of the kernel on your old machine, not the version that's running on the CD.

    Now in my case since it's an old RedHat 6.1 install I needed to run lilo for the changes to take effect.

    Shutdown and reboot and your virtualized copy of your physical machine should boot just fine.

    For additional information refer to these two articles:



    If you have any questions about what I did here please feel free to contact me.