Inizio  >  Docs  >  Linux  >  How to  >  xen  


VMware Convertor: GrubInstaller failed – / 38: grub: not found

I encountered the following when trying to do a VMware Conversion of an Ubuntu 9.10 system. It failed at the last 99% with the following error.


How to fix your Grub after a VMware Convertor

Here are the steps I took to fix this and boot the system again.

First, boot your system with the Ubuntu 9.10 Server ISO image (the desktop version won't work). Make sure your boot order in the Virtual Machine's BIOS is changed to boot from CDROM first.


Now, you should be prompted with several install options from the Server ISO. Choose the "Rescue a broken system".

You'll be prompted with a few questions, such as location, language, keyboard layout and network config. Make sure you enter it all. You will need an internet connection to proceed, so check if your network connections are OK.

After you've booted, you'll be prompted to choose a partition to mount as your root filesystem. In my case, that was /dev/sdb1. On the /dev/sda1 was my /boot mount and the /dev/sda2 contained the swap partition. So I choose /dev/sdb1 as root file system.


After the prompt, choose the option to get a shell on that partition.

~# fdisk -l /dev/sda1: boot /dev/sda2: swap /dev/sdb1: root

With fdisk -l I verified my partition layout. Next, mount the /boot partition.

~# mkdir /boot ~# mount /dev/sda1 /boot

And run the grub2 install & configure.

~# apt-get install grub2 ~# upgrade-from-grub-legacy

You'll be prompted where to install the grub bootloader next. If you're unsure, check both partitions.

Next up: unmount your Server ISO and reboot the system, it should boot just fine now.




Converting Xen Linux VMs to VMWare ESXi

1. In VMWare Fusion or Workstation, do a basic install of Debian Squeeze onto a flat-file (not split into 2GB segments and preallocated) VMDK that is slightly larger than your virtual Xen disk with a separate VMDK for swap.
2. Downgrade it to Grub 1 using apt-get install grub-legacy, grub-install /dev/sda, update-grub (as Grub 2 is not compatible with /boot/grub/menu.lst files as generated by xen-create-image).
3. Shut down and make a copy of the VMDK.
4. Boot the VM back up and re-install Grub2 using apt-get install grub.
5. Edit /boot/grub/grub.cfg and replace root=UUID=xxxxxxxxxx in the linux lines with root=/dev/sda1
6. Shut down the VM and attach the VMDK you copied in step 3 as an additional disk (this will be the target disk for our conversion).
7. Boot it up and make sure that you’re getting a Grub2 screen (i.e. it is not booting from the copied VMDK).
8. Using mount, check that your root disk is sda1 (which usually should be the first disk, not the copied disk). Using ls /dev/sd*, make sure it sees the target disk as sdc.
9. dd if=/path/to/xen/vm/disk.img of=/dev/sdc1 bs=1048576
10. mount /dev/sdc1 /mnt; cd /mnt
11. nano etc/fstab: replace swap disk /dev/xvda1 with /dev/sdb1 and root disk /dev/xvda2 with /dev/sda1
12. nano etc/inittab: replace hvc0 with tty1
13. nano boot/grub/menu.lst: replace /dev/xvda2 with /dev/sda1
14. umount /mnt
15. Attach the new virtual disk to a VM and boot a rescue system. There, drop to a shell on /dev/sda1 and apt-get update, apt-get install grub
16. Reboot
17. Done!


Convert XEN Vm to Vmware (redhat5 /centos5)

on the source:


yum install kernel-2.6.18-194.el5 (kernel version found with yum search kernel) 

check Grub configuration:


must boot from the new kernel (without xen) should be like this:



title CentOS (2.6.18-194.el5)

root (hd0,0)
kernel /vmlinuz-2.6.18-194.el5 ro root=/dev/VolGroup00/LogVol00 
initrd /initrd-2.6.18-194.el5.img

title CentOS (2.6.18-53.el5xen)

root (hd0,0)
kernel /vmlinuz-2.6.18-53.el5xen ro root=/dev/VolGroup00/LogVol00 console=xvc0
initrd /initrd-2.6.18-53.el5xen.img 


after that make the conversion (with Vmware converter or with qemu(?))

start the new Vm machine with the Centos(Redhat) setup DVD and chose: Linux rescue
follow the wizard:
- disable network;
- mount drives in /mnt/sysimage

on the shell:

chroot /mnt/sysimage

Modify /etc/modprobe.conf to add the proper SCSI and network card modul

alias eth0 xennet
alias scsi_hostadapter xenblk

will be replaced by

alias scsi_hostadapter mptbase
alias scsi_hostadapter1 mptspi
alias scsi_hostadapter2 ata_piix

Modify /etc/inittab by removing the # in front of the getty and puting a comment in front of the line containg the xen console:

1:2345:respawn:/sbin/mingetty --noclear tty1  


mkinitrd -v -f /boot/initrd-2.6.18-194.el5.img 2.6.18-194.el5



Xen -> VMware VM Migration Steps (Kernel Step)

The kernel on the VM to be migrated must support fully virtualized operation. The kernels used for para-virtulized machines using RHEL/Fedora/CentOS as a guest do not support fully virtualized operation by default. The best way to deal with this is to also install a standard kernel in the machine, port the machine and finally remove the Xen kernel.

1. Since this is a highly risky procedure, FIRST CREATE A BACK-UP OF YOUR VIRTUAL MACHINE!!!

2. Download a kernel with the same version number and architecture as the Xen kernel, except it should be the a generic one. Use the distribution CD/DVD or any other repository to get it.

3. Use RPM tools to install the kernel.

4. Modify /etc/modprobe.conf to add the proper SCSI and network card modules:

alias eth0 xennet  alias scsi_hostadapter xenblk 

will be replaced by

alias eth0 pcnet32 alias  scsi_hostadapter mptbase  alias scsi_hostadapter1 mptspi  alias scsi_hostadapter2 ata_piix 

Modify /etc/inittab by removing the # in front of the getty and puting a comment in front of the line containg the xen console:

1:2345:respawn:/sbin/mingetty --noclear tty1  2:2345:respawn:/sbin/mingetty  3:2345:respawn:/sbin/mingetty  4:2345:respawn:/sbin/mingetty  5:2345:respawn:/sbin/mingetty  6:2345:respawn:/sbin/mingetty

This is a one way action. Once modified the kernel modules, you won'tbe able to properly start the machine, and you will receive a Kernel panic error message.

Xen - > VMware VM Migration Steps (Disk Step)

To convert a XEN machine in a .vmdk format to be used with VMware, a tool called qemu will be used. QEMU is a generic and open source machine emulator and virtualizer. It is also a fast processor emulator using dynamic translation to achieve good emulation speed.

1. Download qemu from DAG repository. Use the EL5 package for any Fedora/RHEL5/CentOS5 that you use.

2. Convert the XEN machine to VMware:

qemu-img convert <source_xen_machine> -O vmdk <destination_vmware.vmdk>  <dest_vmware.vmdk>

3. At this point, we have a valid VMware Server 1.xx disk image. This can be powered on onto any VMware Server. We need to do it anyway in order to build a .VMX file that will be later used. This stage also confirms whether the newly machine runs properly. </dest_vmware.vmdk>

3.1 Create a new virtual machine. Do not create a new HDD, but use the previously created vmdk.

3.2 Power it on in order to validate that it is usable and to allow the machine to reconfigure itself.

4. Move the VMware Server virtual machine to a Windows workstation running VMwareConverter.

5. Using VMware Converter, convert the VMware Server virtual machine to VMware ESXi.

Xen -> VMware VM Migration Steps (ESX Step)

1. Configure the virtual machine to boot first from CD-ROM drive.

2. Modify the machine's HDD SCSI controller type from BUS Logic to LSI Logic.

Edit Virtual Machine Settings > SCSI Controller 0 > Change type > LSI Logic.

3. Boot using Knoppix or the distribution's first CD.

4. Mount the VM's disk and chroot to it.

5. Get the disk architecture using fdisk -l, and modify /etc/fstab accordingly.

6. Create a new initrd image. You also must know the version of the running kernel. For example, if you are running kernel 2.6.18-1234, then the initrd command would look like this:

# mkinitrd -v -f /boot/initrd-2.6.18-1234.img 2.6.18-1234

7. Edit /boot/grub/menu.lst to boot from this initrd.

8. Keep your fingers crossed and reboot the machine.

Don't forget to re-configure your network card.

External references:

Configure two network bridge

CentOS 5.5

su -

vim /etc/xen/xend-config.sxp

#(network-script network-bridge)
(network-script twoNetBridge)

vim twoNetBridge
/etc/xen/scripts/network-bridge "$@" vifnum=0 bridge=xenbr0 netdev=eth0
/etc/xen/scripts/network-bridge "$@" vifnum=1 bridge=xenbr1 netdev=eth1


service xend restart


Ubuntu 8.04

sudo vim /etc/xen/xend-config.sxp

#(network-script network-bridge)
(network-script twoNetBridge)

sudo vim /etc/xen/scripts/twoNetBridge

/etc/xen/scripts/network-bridge "$@" netdev=eth0
/etc/xen/scripts/network-bridge "$@" netdev=eth1

service xend restart

Torna sù


Xen has a feature which lets you pass a PCI device through to an unpriviledged domain. Only the unpriviledged domain has access to this specific PCI device – the priviledged domain binds to the PCI device with a dummy drive that stops the dom0 from accessing it as well.

This could be used for passing a SCSI controller or NIC through to one domain, eg. for a file server or FireWall domU.

What you'll need

You'll have to compile in the right PCI backend driver for Xen.

    CONFIG_XEN_PCIDEV_FRONTEND=y (for DomU kernels)
CONFIG_XEN_PCIDEV_BACKEND=y (for Dom0 kernels)

You'll also need the PCI ID of the device in question, in the <tt>xx:xx:x</tt> notation displayed by lspci(8). Note that the formatting is important – don't drop or add leading 0's!

In some cases it is required to set the <tt>pciback.permissive</tt> option – this is for drivers which need to write to registers on the PCI device itself. Apparently some NICs will fail to operate without this, and from what I've read it doesn't hurt to have it enabled regardless.

Kernel options

In <tt>grub.conf</tt>, add something like the following to your <tt>module</tt> line corresponding to the dom0 kernel.

pciback.permissive pciback.hide=(03:00.0)

This assumes the device we are passing through has a PCI ID of <tt>03:00.0</tt>.

Xen config file

In your Xen config file for the domain, add a line that looks like the following, again assuming a PCI ID of <tt>03:00.0</tt>:

pci = ['03:00.0']

Note that if this is a network interface, it will come up in addition to any you specify with your <tt>vif</tt> config option.

Avete allestito un server Xen con tante belle macchine virtuali?
Avete configurato un domU solo per Samba che funge anche da server di stampa?

Ok, allora vi sarete chiesti come fare a condividere la vostra stampante locale collegata fisicamente alla dom0.

Di default infatti Xen (che non virtualizza, ma paravirtualizza) non passa alcun device reale alle macchine virtuali, ma bastano 2 semplici modifiche ed ecco che la vostra domU sara' come fisicamente collegata ai vostri dispositivi, siano essi stampanti USB o altro.

Per prima cosa, ed e' quella piu' difficile, bisogna individuare su quale bus e' installato il dispositivo da passare alla domU. Comandi come lspci hwinfo o lsusb vi saranno senz'altro di aiuto.

Ad esempio, ho una stampante collegata tramite USB:

root@dom0:~# lsusb
Bus 004 Device 001: ID 0000:0000
Bus 003 Device 001: ID 0000:0000
Bus 002 Device 002: ID 03f0:8704 Hewlett-Packard
Bus 002 Device 001: ID 0000:0000
Bus 001 Device 003: ID 1241:1603 Belkin
Bus 001 Device 001: ID 0000:0000

Ok, la mia HP e' collegata al bus 002:

root@dom0:~# lspci |grep USB
00:10.0 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 80)
00:10.1 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 80)
00:10.2 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev 80)
00:10.3 USB Controller: VIA Technologies, Inc. USB 2.0 (rev 82)

In tutto ci sono 4 bus, quindi il bus 002 dovrebbe corrispondere con il device pci 00:10.1, ora inizia la configurazione vera e propria, modficate il votro file /boot/grub/menu.lst aggiungendo quanto vedete in grassetto qui sotto:

module /vmlinuz-2.6.24-16-xen root=/dev/mapper/xenbuntu-root ro console=tty0 pciback.hide=(00:10.1)

Ora l'ultimo step, modificare il vostro file di configurazione della macchina virtuale /etc/xen/domu.cfg aggiundo la riga


Facciamo partire la macchina virtuale e controlliamo con lsusb:

root@dom0:~# lsusb
Bus 001 Device 002: ID 03f0:8704 Hewlett-Packard
Bus 001 Device 001: ID 0000:0000

La nostra stampante e' stata correttamente rilevata

Torna sù

creazione macchina

mkdir hylafax
cd hylafax/
mv /root/58.59.tgz .

dd if=/dev/zero of=hylafax.img bs=1k seek=4048k count=1
dd if=/dev/zero of=hylafax.swp bs=1k seek=1048k count=1

mkfs.ext3 hylafax.img
mkswap hylafax.swp
mount -o loop hylafax.img /mnt/
cd /mnt/
tar xfpvz /root/Desktop/hylafax/58.59.tgz

cd /mnt/
mkdir proc
mkdir sysfs
mkdir mnt
mkdir tmp
chmod +rwxt tmp/
chmod ugo+rwx tmp/
vim etc/fstab
vim etc/sysconfig/network-scripts/ifcfg-eth0.bak
etc/sysconfig/network-scripts/ifcfg-eth0.bak etc/sysconfig/network-scripts/ifcfg-eth0
rm etc/sysconfig/network-scripts/ifcfg-eth1
rm etc/sysconfig/network-scripts/ifcfg-eth0.bak
vim etc/sysconfig/network-scripts/ifcfg-eth0
cp -av /lib/modules/ /mnt/lib/modules/



kernel = "/boot/vmlinuz-"
ramdisk = "/boot/initrd-"
memory = 1024
name = "hylafax"
vif=[ 'mac=00:16:3e:4f:bd:c8,bridge=xenbr0', ]
#disk = ['tap:aio:dev/loop10,sda1,w', 'tap:aio:dev/loop10,sda2,w', ]
disk = ['file:/root/Desktop/hylafax/hylafax.img,sda1,w','file:/root/Desktop/hylafax/hylafax.swp,sda2,w',]
root = "/dev/sda1 ro"
extra = ' xencons=tty ROOT=/dev/sda1 single'

 xm create /etc/xen/vm/hylafax -c

Torna sù

UBUNTU 8.04 HowTo

Based on:



Install OS (host) and SSH server

aptitude update
aptitude safe-upgrade
aptitude install openssh-server

Install Xen Kernel and utils

aptitude install xen-utils-3.2 ubuntu-xen-server


uname -a
Linux itb-s0030 2.6.24-26-xen #1 SMP Tue Dec 1 19:54:57 UTC 2009 x86_64 GNU/Linux
xm list
Name                                        ID   Mem VCPUs      State   Time(s)
Domain-0                                     0  1879     4     r-----    720.6

Create VM WebServer

sudo -s
mkdir -p /opt/xen/vm
cd /opt/xen/vm

Create VM disks
dd if=/dev/zero of=webServerRoot.img bs=1k seek=8048k count=1
1+0 records in
1+0 records out
1024 bytes (1,0 kB) copied, 0,000115246 s, 8,9 MB/s

dd if=/dev/zero of=webServerSwap.img bs=1k seek=2048k count=1
1+0 records in
1+0 records out
1024 bytes (1,0 kB) copied, 0,00010514 s, 9,7 MB/s

dd if=/dev/zero of=webServerOpt.img bs=1k seek=8048k count=1
1+0 records in
1+0 records out
1024 bytes (1,0 kB) copied, 0,000115246 s, 8,9 MB/s

ls -al
total 10104
drwxr-xr-x 2 root root        128 2009-12-11 16:50 .
drwxr-xr-x 3 root root         72 2009-12-11 16:49 ..
-rw-r--r-- 1 root root 8438940672 2009-12-11 16:49 webServerRoot.img
-rw-r--r-- 1 root root 2147484672 2009-12-11 16:50 webServerSwap.img

Create filesystems on Images

mkfs.ext3 webServerRoot.img

mke2fs 1.40.8 (13-Mar-2008)
webServerRoot.img is not a block special device.
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
516096 inodes, 2060288 blocks
103014 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2109734912
63 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:

    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Writing inode tables: done                           
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 21 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

mkfs.ext3 webServerOpt.img
mkswap webServerSwap.img

Setting up swapspace version 1, size = 2147479 kB
no label, UUID=59fd6b42-207f-40d1-baaf-4df3a21eaaa8

mount root image
mount -o loop webServerRoot.img /mnt/

if beyound a proxy
export http_proxy=

Install ubuntu 8.04 with debootstrap

debootstrap --arch amd64 hardy /mnt

Mount service directory (dev proc)
mount --bind /dev /mnt/dev
mount proc /mnt/proc -t proc

Copy network configuration/apt configuration files
cp /etc/resolv.conf /mnt/etc/resolv.conf
cp /etc/network/interfaces /mnt/etc/network/

cp /etc/apt/sources.list /mnt/etc/apt/sources.list

cp /etc/apt/apt.conf /mnt/etc/apt/

Create and populate modules dir for guest
mkdir -p /mnt/lib/modules/2.6.24-26-xen/
cp -R /lib/modules/2.6.24-26-xen/* /mnt/lib/modules/2.6.24-26-xen/


mkdir /mnt/lib/modules/`uname -r`
cp -R /lib/modules/`uname -r`/* /mnt/lib/modules/`uname -r`/

Enter in chroot on guest
chroot /mnt /bin/bash

update repository index and system

apt-get update
apt-get upgrade

Starting Up from debbootstrap it's necessary to setup language packs:

sudo apt-get install --reinstall openssh-server bash-completion language-pack-en language-pack-it vim ssh nfs-common mc

Create User (sudoer) and group:
useradd -m nikoz
passwd nikoz
groupadd admin
usermod -a -G admin,adm nikoz

check /etc/passwd that shell for nikoz is BASH and not SH

Modify fstab:
vim /etc/fstab
# /etc/fstab: static file system information.
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/hda1               /               ext3    defaults        1       2
proc            /proc           proc    defaults        0       0
/dev/hdb1       none            swap    sw              0       0
/dev/hdc1       /opt/           ext3    defaults    1    2  /media/nfs_44       nfs             auto,defaults,nolock        0 0  /media/nfs_32       nfs             auto,defaults,nolock        0 0

Modify /etc/network/interfaces and change the IP address of the guest OS

iface eth0 inet static
    address <---

Exit chroot:

Copy sudoers file:
cp /etc/sudoers /mnt/etc/

umount  /mnt/dev /mnt/proc /mnt

Create Vm configuration file:
mkdir /etc/xen/vm
vim /etc/xen/vm/webserver.cfg

kernel      = '/boot/vmlinuz-2.6.24-26-xen'
ramdisk     = '/boot/initrd.img-2.6.24-26-xen'
memory      = '512'

#  Disk device(s).
root        = '/dev/hda1 ro'
disk        = ['tap:aio:/opt/xen/vm/webServerRoot.img,hda1,w',
#disk        = ['phy:/dev/sda2,hda1,w',]
#  Hostname
name        = 'domu1'
#  Networking
vif         = [ 'mac=00:16:EF:FE:00:11' ]
#  Behaviour
on_poweroff = 'destroy'
on_reboot   = 'restart'
on_crash    = 'restart'
vcpus        = '2'
extra = 'xencons=tty1'

Start the Vm:
xm create /etc/xen/vm/webserver.cfg -c

Start Vm at boot time:

ln -sf /etc/xen/vm/webserver.cfg /etc/xen/vm/auto

Setup Web Server:

Change hostname:
vim /etc/hostname

vim /etc/hosts       localhost.localdomain   localhost       ITB-S00322   
# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

for a centralized nfs server apt archive

cd /var/cache/apt/

mv archives/ archives.local

ln -sf /media/nfs_32/archives/server/8.04/64/ archives


Install all Packages:
sudo apt-get install mysql-server mysql-client libmysqlclient15-dev apache2 apache2-doc apache2-mpm-prefork apache2-utils libexpat1 ssl-cert libapache2-mod-php5 php5 php5-common php5-curl php5-dev php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-mysql php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl