Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

My question is how to convert a pre-created OpenVZ OS template which are in tar.gz format (such as these) to an image file in order to be able boot it with other virtualization solutions such as QEMU or VirtualBox.

In order to achieve this, I made an empty image file, I partitioned it, and made two partition, a primary partition and a extended partition for swap. I made the first partition ext3 (0x83) and the other one swap (0x82). Then I made the first one bootable, and copied the content of tar.gz to the first partition. But when I try to boot, it hangs at the first stage of booting.

enter image description here

share|improve this question
add comment

1 Answer

An OpenVZ template lacks a number of important files needed to boot a non-container based guest, for example it lacks a kernel and a bootloader (GRUB). Actually, a whole /boot directory is missing on the OpenVZ template, so you need to get it somewhere. A way to go is to install a very minimal setup of a distribution you need using "normal" installation procedure such as CD or network-based installation and copy /boot to your OpenVZ-converted image using a LiveCD then. You will need to set up GRUB manually after that using the same LiveCD. Another approach is to set up a minimal set of packages using normal install and rsync everything from an OpenVZ template to your new image then.

share|improve this answer
    
Thanks Alex, I'm trying to test this, and I'll report back, is it enough just to replace /boot directory from the minimal installation ? –  Medi Nov 20 '11 at 14:53
    
It seems it's more complicated than just copying the boot folder. It needs to be partitioned specifically for CentOS(as I need it), which should have Volume-Group and Logical Volumes, and also we nee a partition for /boot folder, /dev folder should be created for tar.gz template, /etc/fstab and /etc/resolv.conf and other network config files should be edited manually and then grub and kernel should be installed manually, there may be other stuff I'm not aware of, but since I didn't find a complete solution or a step by step procedure, I gave up for now :( –  Medi Nov 21 '11 at 0:06
    
Yes, you are right, copying /boot folder is not enough. I think copying /boot and installing GRUB using a LiveCD will lead you to a bootable system, but you will need to configure the network, etc as you pointed out. –  Alex Nov 21 '11 at 1:25
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.