1

I am moving my project from CentOS 6 to CentOS 7 and need to deal with the changes in the boot requirements introduced by CentOS 7, particularly the upgrade from grub to grub2. The gist of the problem is this:

In my CentOS 6 based work, I had my hard drive sliced into various partitions and each hosted a VM, installed with virt-install. I used a pre-created CentOS 6 image that I untar'ed directly into a partition that was hosting a VM, allowing me to use the --import option of virt-install. Each VM's partition was further partitioned into boot, swap, and root-fs partitions. I manually created device.map grub.conf files and ran the required grub install commands to make the VM bootable.

In CentOS 7, things have changed a bit. When grub2 is installed on a GPT drive it requires an additional "bios_grub" partition. So now my VM partitions are sub-partitioned into four partitions instead of the three I had under CentOS 6.6. If for example I was installing a VM under /dev/sda4, parted would show something like this:

    # parted -s /dev/sda4 print
    Model: Unknown (unknown)
    Disk /dev/sda4: 75.2GB
    Sector size (logical/physical): 512B/4096B
    Partition Table: gpt
    Disk Flags:

    Number Start End Size File system Name Flags
    1 1049kB 2097kB 1049kB primary bios_grub
    2 2097kB 136MB 134MB ext3 primary boot
    3 136MB 153MB 16.8MB linux-swap(v1) primary
    4 153MB 75.2GB 75.0GB ext4 primary

The problem is I can't get the VMs I create to boot. Well, the VMs start, but they hang immediately. There is no error and virsh shows they are running, but the transfer from the BIOS to grub doesn't take place. The commands I run to install grub are as follows (again assuming the VM is being installed on /dev/sda4):

    # chroot /mnt/rootfs/grub2-install --force /dev/sda4
    Installing for i386-pc platform.
    Installation finished. No error reported.

    # chroot /mnt/rootfs grub2-mkconfig -o /boot/grub2/grub.cfg
    Generating grub configuration file ...
    Found linux image: /boot/vmlinuz-3.10.0-229.el7.x86_64
    Found initrd image: /boot/initramfs-3.10.0-229.el7.x86_64.img
    done

and the VM create command looks like this:

    # virt-install --connect=qemu:///system --network bridge=br0,mac=RANDOM,model=virtio --name=vm1 --disk path=/dev/sda4,bus=virtio --force --vcpus=1 --ram=1024 --check-cpu --accelerate --hvm --nographics --noreboot --import

    Starting install...
    Creating domain...
    Domain creation completed. You can restart your domain by running:
    virsh --connect qemu:///system start vm1

Unfortunately, as I said, the VM does start, but it immediately hangs. The BIOS does not make the transition to grub to boot CentOS. The same basic approach works for CentOS 6 so I assume I am missing some key step here, most likely related to how I am installing grub2. If anyone is experienced in this area and has any advice, I'd appreciate some input.

Peter

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.