HOWTO: manage VDIs and import native installations
Posted: 27. Sep 2007, 12:39
Still working on this.
Edit: ...no more. 1. Introduction First of all. HAVE A BACKUP OF YOUR DATA! There are some chances to destroy them. I've decided to migrate completely to Linux and run still needed Windows installations only in VirtualBox. So I have to convert my Windows Installations to Virtual Disk Images and manage these VDIs, e.g. increase, decrease or change their type from dynamically expanding to fixed-size etc. I have summarized my experience and information to this here in the hope it may also be helpful for others. In my examples below I use a Debian etch host system with Windows XP as guest, so Ubuntu should also work direct with them. But with another environment please adapt them to your needs. First solutions I have posted here: modify a VDI http://forums.virtualbox.org/viewtopic.php?t=364 import native WinXP http://forums.virtualbox.org/viewtopic.php?t=1404 Here is another solution from rcman80: http://forums.virtualbox.org/viewtopic.php?t=1878 litemotiv describes another way with HDClone (freeware 4mb) on this topic page 2: http://forums.virtualbox.org/viewtopic.php?t=585 Aaron_Mason describes an interesting way to convert from vmware to VirtualBox with rsync: http://forums.virtualbox.org/viewtopic.php?t=3808 This howto http://www.virtualbox.org/wiki/Migrate_Windows assumes that we already have an image.vdi but don't declare how to get it. Many thanks to QBikal for his excellent work to the internals of a virtual disk image! http://forums.virtualbox.org/viewtopic.php?t=52 I've tried to use with documentation at http://www.virtualbox.org/ticket/696. I do this: Code: Select all
Code: Select all
2. Abstract Independent of the current used operating systems you should be able to adapt my examples below to your needs if you understand the general procedure. 1. Do everything with the target operating system, e.g. partition and format virtual disks, copy data etc. 2. attach the source disks and the target disks as second and third passive devices to your managing virtual machine. So it is ensured that there are no files in access. 3. Modify a Virtual Disk Image This is the basic procedure. You copy all data from the old VDI to a new one and use that instead of the old one. Dependent on how you create the new one (bigger, smaler, new type) you can increase, decrease or modify the type of the VDI. 1. have a managing WinXP virtual machine 2. create a new VDI of the size and type you want 3. detach your working VDI from your working VM 4. attach your working VDI to the managing VM as primary slave 5. attach the new (modified) VDI to the managing VM as secondary slave 6. start the managing VM 7. partition and format the target drive F: (the new modified one!) 8. don't forget to set it active (set boot flag) in the disk manager if you want to boot from it later 9. to really copy all flags and whistles I use Code: Select all
10. shut down the managing VM 11. detach the new (modified) VDI from the managing VM 12. attach the new (modified) VDI to your working VM as primary master 13. start your working VM with the modified virtual disk that's it and only some clicks except the boring wait for xcopy. 4. Import a native installation from a physical disk partition The trick is to access the physical disk partition in the managing VM through raw hard disk access and copy that data into a virtual disk image. 1. have a managing WinXP virtual machine 2. create a writethrough virtual disk for the physical partition. You must be a member of the group disk (there are NO line breaks!) Code: Select all
3. create a target disk image that can hold all stored files from the physical partition 4. attach the physical disk as primary slave 5. attach the target disk image as secondary slave follow step 6. to 11. from section 3. 12. create a new VM with the coppied virtual drive as primary master 13. mount the Windows Setup CD 14. repair your copy, see http://www.virtualbox.org/wiki/Migrate_Windows that's it and should always work as long as repair does it. 5. Import a native installation from a raw disk image This is a little bit sophisticated because we can't access the raw image directly in a virtual machine to copy its data into a VDI. A raw disk image is something like made with dd, e.g. Code: Select all
1. have a managing WinXP virtual machine 2. Have the raw image 3. Create a fixed-size virtual disk image a little bit greater than your raw image (e.g. raw image = 10 GB, vdi = 11 GB). For further use it is important to use fixed-size! 4. Attach this new empty VDI to the managing machine as primary slave 5. start the managing VM 6. partition and format the fixed-size drive D: (the empty one!) 7. don't forget to set it active (set boot flag) in the disk manager if you want to boot from it later 8. shut down the managing VM 9. Grep the magic string "eb 52 90 4e 54 46 53" (= ".R.NTFS") with hexdump from the first MB of the VDI to get the offset the raw data starts at. The cryptic options for hexdump are only to get the offset in decimal and not in default hex (there are NO line breaks!). Code: Select all
Code: Select all
10. Copy your raw image into the VDI at the found offset. This only works with a fixed-size virtual disk image! (there are NO line breaks!) Code: Select all
12. Attach this working VDI to the managing machine as Secondary Slave. 13. Boot into the managing machine and check if the fixed VDI shows the copied data. You should do any check/repair actions on it. For this example I do: Code: Select all
follow step 12. to 14. from section 4. That's it. I have tried to repair the fixed-size VDI in the VM after step 10. above and boot it but with no success. Code: Select all
Hope I haven't made a mistake in my description. For me it works. |