Who's online
There are currently 0 users and 3 guests online.
User login |
Physical to Virtual Machine Conversion On FedoraThe following is a short write-up of how I accomplished converting my mythtv master-backend to a virtual machine. I did this for the purpose of hardware flexibility, which allowed me to run my backend on my fileserver while I upgraded it's hardware and OS. This should apply to almost any linux version, but the target machine I performed this on was Fedora 6. It was performed on a running machine. Step 1: Prepare the Virtual Disk In my case I created this device on a storage partition that wasn't being converted to the virtual machine. You can easily use an NFS or SMB mount point if need be. You have 2 options for disk creation; either dd or qemu-img.
#Create a disk of desired size (in this case 10G)
qemu-img create disk.img 10G or dd if=/dev/zero of=./mydisk.img bs=1M count=10000 Step 2: Setup loop device for partitioning losetup /dev/loop0 ./mydisk.img Step 3: Partition the virtual disk #Create desired partitions (i.e: /boot, /, swap) Step 4: Create loop device mappings for partitions
#run kpartx to get loop mappings
kpartx -av /dev/loop0 #Verify mappings exist Step 5: Create required file systems on respective devices
#mkfs on appropriate /dev/mapper/loop devices
mkfs.ext3 /dev/mapper/loop0p1 (/boot) mkfs.ext3 /dev/mapper/loop0p3 (/) mkswap /dev/mapper/loop0p2 (swap) Step 6: Prepare directories for file-system mount #Mount / loop device to /mnt #create /boot #mount /boot Step 7: Rsync exiting data to virtual devices cd /mnt Step 8: Make system changes to allow booting in vmware
#Modify /boot/grub/grub.conf & /etc/fstab for proper disk paths
/dev/hda is default for this type of disk image vi /mnt/etc/grub.conf vi /mnt/etc/fstab.conf #Umount the disks Step 9: Install the bootloader
#Install grub (this takes a little magic)
#Create offset loop device for partition1 /boot #Create a symlink for /dev/loop to satisfy grub #Enter grub cli #Set the device #Set root device #install the bootloader #now exit #Now clean up the links and loop devices Step 10: Convert the disk to the desired format
qemu-img -c -f raw ./mydisk.img -O vmdk ./mydisk.vmdk
If you have any questions or corrections please email me using the link at the top of the page.
|
Shameless Begging... |