[CentOS-virt] Centos 5.5 KVM GRUB / Virtio issue

Wed Jan 12 17:58:13 UTC 2011
Nenad Opsenica <nenad at panline.net>

Hi Ken,

grub is a bit tricky to install in such setup.
Try to use following script from within host machine - this works for me:

------------

losetup /dev/loop0 /dev/YOUR_VG/YOUR_LV
kpartx -av /dev/loop0

ln -fs /dev/mapper/loop0p1 /dev/loop01
grub --device-map=/dev/null <<-END
                device (hd0) /dev/loop0
                root (hd0,0)
                setup (hd0)
END
rm -f /dev/loop01
kpartx -dv /dev/loop0
losetup -d /dev/loop0

--------------

Best regards,

    Nenad



Ken Bass wrote:
> I have a virtual machine that had been running fine using a RAW disk 
> image (IDE).
>
> I am in the process of converting this virtual machine to use a single 
> LVM and virtio. (For LVM backup snapshots and easy resizing purposes (no 
> LVM within the guest))
>
> I create the LVM and copied all the files from the existing RAW image to 
> an ext3 under the LVM.
>
> However, I cannot get it to boot. It has to do with GRUB and I cannot 
> figure out why the stupid thing is not working as it should.
>
> I boot the guest using the Centos 5.5 DVD and select Rescue and chroot 
> /mnt/sysimage
>
> <><>
>
> fdisk -l shows:
>
> Disk /dev/vda: 21.4 GB, 21474836480 bytes
> 213 heads, 34 sectors/track, 5791 cylinders
> Units = cylinders of 7242 * 512 = 3707904 bytes
>
>     Device Boot      Start         End      Blocks   Id  System
> /dev/vda1               1        5792    20970496   83  Linux
>
> <><>
>
> cat /boot/grub/device.map  shows:
> (hd0)    /dev/vda
>
> <><>
>
> However grub cannot find the /boot/grub/stage1.
>
> I ran grub and did the following:
>
> device (hd0) /dev/vda
>   OK
>
> root (hd0,0)
>    Filesystem type is ext2fs, partition type 0x83
>
> setup (hd0)
>
>   Checking if "/boot/grub/stage1" exists... no
>   Checking if "/grub/stage1" exists... no
> Error 2: Bad file or directory type
>
> find /boot/grub/stage1
> Error 15: File not found
>
> <><>
>
> However, there is most definitely a /boot/grub/stage1 in the (hd0,1) - I 
> copied the entire boot directory from the RAW IDE image to the LVM.
> Even 'find /sbin/init' fails. Now find works at all.
>
> My host is Fedora 14.
>
> What is odd is that I created a different virtual machine by going 
> through the whole Centos 5.5 DVD Install process and that one works. In 
> this non working case, I've copied the files over to the LVM and it 
> seems GRUB is the only issue/difference. I can boot the DVD installed 
> one and run the above grub find command and it finds the stage1 fine.
>
> _______________________________________________
> CentOS-virt mailing list
> CentOS-virt at centos.org
> http://lists.centos.org/mailman/listinfo/centos-virt
>   

-- 
<http://www.panline.net> 	*Nenad Opsenica, M.Sc.EE*
Panline - VTkom d.o.o.

Bulevar Mihajla Pupina 6, Novi Sad, Serbia
Tel: (+381 21) 47 222 40; fax: (+381 21) 47 222 41