Migrating guests using VMDK raw devices

This is for discussing general topics about how to use VirtualBox.
Post Reply
l1x
Posts: 6
Joined: 23. Sep 2009, 16:49
Primary OS: OpenSolaris 11
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: FreeBSD

Migrating guests using VMDK raw devices

Post by l1x »

I was googling around but found nothing.

I have created the raw devices using the following command:

Code: Select all

VBoxManage internalcommands createrawvmdk -filename /opt/lv0 -rawdisk /dev/mapper/vg0-lv0 -register
The question is how can I move the guest to a new host(copy the xml file of course). What happens if i want to change the host OS from Fedora to OpenSolaris for example?

Thank you in advance.
Etepetete
Posts: 400
Joined: 7. Oct 2009, 10:19
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Slackware 14.2
Location: Berlin

Re: Migrating guests using VMDK raw devices

Post by Etepetete »

It shouldn't be a problem. Copy the files to where you need them. Then register the VM see the manual here. As far as the host is concerned, if you have VBox installed correctly and you do not already have a VM named like the new one you want to register, it should work fine. (Don't forget to place the VDI on the other host in the correct folder :wink: )
l1x
Posts: 6
Joined: 23. Sep 2009, 16:49
Primary OS: OpenSolaris 11
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: FreeBSD

Re: Migrating guests using VMDK raw devices

Post by l1x »

Do you understand what does the raw device mean in this context? I presume you might have overlooked that 3 letters in the subject.

So a VMDK file looks the following if it is a raw device:

Code: Select all

# cat lv1

# Disk DescriptorFile
version=1
CID=71cae7c6
parentCID=ffffffff
createType="fullDevice"

# Extent description
RW 819200000 FLAT "/dev/mapper/vg0-lv1" 0

# The disk Data Base
#DDB

ddb.virtualHWVersion = "4"
ddb.adapterType="ide"
ddb.geometry.cylinders="16383"
ddb.geometry.heads="16"
ddb.geometry.sectors="63"
ddb.uuid.image="3c7e5d0c-007b-40e9-9b47-9b98489b108e"
ddb.uuid.parent="00000000-0000-0000-0000-000000000000"
ddb.uuid.modification="0d8bc9bf-5955-4cba-8823-72afe9f45197"
ddb.uuid.parentmodification="00000000-0000-0000-0000-000000000000"
ddb.geometry.biosCylinders="1024"
ddb.geometry.biosHeads="255"
ddb.geometry.biosSectors="63"
Basically this file can be recreated on the other host wo/ issue. The problem is: how to backup and restore the raw device itself?

DD would be one solution because the drive geometry is the same in this case...
Etepetete
Posts: 400
Joined: 7. Oct 2009, 10:19
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Slackware 14.2
Location: Berlin

Re: Migrating guests using VMDK raw devices

Post by Etepetete »

Is this an alternative?
l1x
Posts: 6
Joined: 23. Sep 2009, 16:49
Primary OS: OpenSolaris 11
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: FreeBSD

Re: Migrating guests using VMDK raw devices

Post by l1x »

More like there is a one way to do the backup/restore on the local host using the same raw device.

Shut down the guest:

Code: Select all

dd if=/dev/vg/lv | bzip2 > /vmbackup/guest.img.gz
This is surely not efficient way to do it.

Another way would be to use the virtualbox clonehd stuff. I am going to check to doc.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: Migrating guests using VMDK raw devices

Post by mpack »

l1x wrote:Another way would be to use the virtualbox clonehd stuff.
That seems like the obvious solution to me.
l1x
Posts: 6
Joined: 23. Sep 2009, 16:49
Primary OS: OpenSolaris 11
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: FreeBSD

Re: Migrating guests using VMDK raw devices

Post by l1x »

Code: Select all

[root@alfa ~]# VBoxManage clonehd /opt/lv0 /opt/backup/lv0_backup
It is working this way. I am curious if the backup -> raw device way is working as well.....
l1x
Posts: 6
Joined: 23. Sep 2009, 16:49
Primary OS: OpenSolaris 11
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: FreeBSD

Re: Migrating guests using VMDK raw devices

Post by l1x »

The RAW device to file is working well, I was able to use clonehd to backup the guest to one file. The question is: how to use that file to restore the OS?

The created file:

Code: Select all

UUID:                 4442c7df-8dcb-403d-abec-7bf659267c56
Accessible:           yes
Description:
Logical size:         50000 MBytes
Current size on disk: 9553 MBytes
Type:                 normal (base)
Storage format:       VMDK
Location:             /opt/backup/lv0_backup
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: Migrating guests using VMDK raw devices

Post by mpack »

l1x wrote:The RAW device to file is working well, I was able to use clonehd to backup the guest to one file. The question is: how to use that file to restore the OS?
The procedure you just used makes the guest OS fully virtual, the VDI file can be moved to different hosts and there is no reason for a physical copy of the partition to exist. If you change hosts in the future all you need do is create a new VM and mount that VDI in it.

If you are asking how to go from virtual back to physical then that can only be done with third party disk imaging tools.
Post Reply