lundi 23 janvier 2006

un PC physique transformer en Virtuel.

Source et crédit:

http://macrolinz.com/macrolinz/index.php/2006/01/09/physcial-to-virtual/

VRAIMENT INTÉRESSANT...

===================================================================
Début du copy&paste:

How to convert a physcial computer to a virtual machine

Filed under: HowTo, Virtualization, Systems Engineering | Lindsay @ 10:04 pm

I recently got a new replacement laptop for work. I had a lot of stuff on the old laptop after 2+ years of use and so I didn’t want to have to rush myself in remembering everything in one or two passes before formatting it to send back to the office. There are always things I forget when I’m mostly focused on moving data files over: files in “hidden” places like IM logs and non-file based data such as product keys, configuration info, settings for programs and other stuff. So I decided the best thing to do was make it into a VM and take my time about reinstalling and configuring the new laptop to match.

After some Googling I found a forum conversation on ArsTechnica about how some people did it. I had been planning to use Symantech Ghost but the version my company supplied was old and I didn’t want to shell out another $70 of my own. Someone mentioned in the post that you could use NTBackup, a free, already-there backup application on Windows XP. He said it was actually a preferred method because NTBackup is actually there to provide recovery services from backups made on different hardware. There would be no tweaking of drivers necessary on the new VM.

So I tried the P2V using NTBackup and it worked well. My last attempt (out of 3) was relatively painless. The first two failed because of miscalculations on my part. Since I had trouble finding information on how to do it and I generally need more detailed steps than the hardware gurus give me, I thought I’d document the process here in case anyone else has the same challenges I did.

Disclaimer: Use these steps at your own risk. Theoretically the worst that could happen is you could waste some time and/or end up with a VM that doesn’t work correctly so you can just scrap it and try something else!

What you will need to get started

  • Your two laptops (obviously)
  • VMWare Workstation (version 5.5 recommended, what I used) - You may download and use a free 30-day trial of Workstation. After the trial ends, if you don’t want to purchase a license, get the free VMWare Player which allows you to use existing VMs but not create new ones.
  • An external drive or a networked drive that has enough room for your backup file that both laptops can access (I used a 100GB USB external harddrive)
  • Microsoft Windows installation discs or ISOs
  • Enough space on your new laptop to host a VM of the old one, or just use the external drive to host the VM
  • Some thing else to work on during the hours and hours it takes to do the backup and restore after you get them running

Make a backup of your old laptop (Windows XP)

  1. Go to Start->Run and type NTBackup.exe and click OK
  2. Choose to run the Wizard and select Backup Files and Settings , click Next>
  3. Choose All information on this computer, click Next>
    Update: A friend of mine did this and it attempted to back up the external harddrive that he was using to write the backup to (which caused it to run out of space and fail). If you’re using an external drive you may want to choose Let me choose what to back up instead and drill down to My Computer. If you do this remember to check System State as something to back up!
  4. Browse to or type the path to where you want your backup file created: somewhere you can get to from your new laptop. I used my external harddrive to store the image on for easy transfer.
  5. Type a name for your backup file. I chose something with the date in it just to make it easier to remember
  6. It says you need a floppy disk. If you have a floppy drive for both of your laptops, then you can use them and it will save you a step later. If you don’t, don’t sweat it. Click Next>
  7. Click Finish and find something else to do for the next 5-10 hours or so. Mine took about 9 hours to fully back up (it is a 40GB drive). At the end, if you don’t have a floppy drive, it will complain about it, but just click ok, all is well.

Create the Windows Virtual Machine on your new laptop

(These instructions are for VMWare 5.5, if you have another verison they may vary)

  1. Open VMWare and choose File->New->Virtual Machine…
  2. Choose Typical, click Next>
  3. Choose Microsoft Windows and your Version
  4. Give your VM a name and location, click Next>
  5. Choose Use bridged networking, click Next>
  6. Be careful when choosing your disk size. I screwed this up twice. Just go ahead and make it at least as big as the physical drive on your old laptop (this is where it helps to have an external drive to store these things on, like my 100GB one). Leave the box to allocate space now unchecked, and it will only take up as much room as it needs. Click Finish
  7. Start your new VM.
  8. Choose VM->Removable Devices->CD ROM (IDE:0)->Edit… and point it to where ever you have your Windows install disc (I had an ISO file)
  9. Choose VM->Settings, click the Options tab and then Shared Folders and set up a shared folder to the path where your backup file can be found.
  10. Stop your VM (it will be hung anyway) and restart it to get it to notice the installer cd.
  11. If you have the recovery floppy and you pay attention at the very beginning of the install, you can press F2 and have Windows create the install directly from your backup file. I haven’t done this so I can’t guide your steps, but you shouldn’t need to do the next steps if you can do that.
  12. Otherwise, follow the Windows install. Make sure that you set up your partitions to match your old laptop (this was another place I miscalculated and had to start over with).
  13. Choose as many of the defaults as possible when installing Windows. It won’t matter since all the settings will be overwritten when you restore your backup.
  14. After you’ve installed Windows, install the VMWare tools (VM->Install VMWare Tools…) on the virtual machine (this needs to be done before you restore). Select defaults in the install wizard and Windows will require a restart after the install.
  15. Update: If you created more than one partition during your install, make sure that you format the partitions other than C: before you perform your restore! Go to Start->Run, type compmgmt.msc, click on Disk Managment, right-click your drive and choose Format.

Restore your backup of the old laptop into the new VM

  1. After it’s restarted, in the VM, map a drive to the shared folder you set up. It should be under VMWare Shared Folders when you browse for it. The mapped drive path will start with something like \\.host
  2. Click Start->Run, type NTBackup.exe and click OK.
  3. Follow the wizard steps to restore your backup. There shouldn’t be any “gotchas” there. Find your backup file on the share you mapped to and it will load in the treeview under “File”. Check all the pieces you want to restore, which in my case was everything. Don’t forget to check the System State (probably the last thing in the list) as something you want to restore!
  4. Click Finish. You will be prompted about restoring system state; just click OK.
  5. Wait for a couple or 3 hours for the restore to finish!

And now you should have your old laptop on your new one. All your data files, installed software, security settings and even application state information (I was suprised to find that the ISO file I had loaded into Daemonware was still loaded!) right there and usable.

There could be other uses for P2V as well, of course… You could take your whole computer on the road in just an external harddrive (of course you’d need a PC with VMWare installed at your destination to use it). But for travel from office to office, that might be a good alternative to lugging a laptop around the airport!

Update: After restoring, the drive map I had set up was no longer there (to be expected). I noticed that I no longer could see the VMWare Shared Folders when browsing the network connections to re-establish the map. To fix this problem, reinstall the VMWare tools.

Update 2: For those of you who are into (or getting into) Virtualization, I’d appreciate any feedback you can give me on the issues I have found trying to go the virtual route. Please feel free to leave your advice comments on my second virtualization post!! I’d love to hear what other people are doing.

» » » » » » » » » » » » »

18 Responses to “How to convert a physcial computer to a virtual machine”

  1. Martin Mueller Says:

    Thx for sharing - just what i needed!

    Regards
    Martin Mueller
    Denmark

  2. Lindsay Says:

    Glad it is useful, Martin! Good luck with your virtualization.

  3. paintballer Says:

    Perfect!
    MUCH better than using other tools, it’s already included after all…

  4. Orhan Karsligil Says:

    If you have the software an easier process is:
    1.) Create an image of your laptop using Symantec Livestate.
    2.) Using VMPlayer convert this image to a Virtual Machine and you are all set.

    This way your hardware configuration is maintained in the Virtual Machine as well. I am not sure if NTBackup can bring over your installed software. It can copy the data and Windows/Office settings and some other Windows Application settings but other software is not coppied over (the files might be there but the most probably will not work) The livestate->VMPlayer definetely solves this problem. Taking a livestate image of a laptop should not take more than 2 hours (USB 2.0 harddrive or a 100MB Network connection), VMPlayer image conversion takes also around 2hr on a good machine. But then again nothing beats “free”. Of course licensing is not free. The laptop OSes normally are OEMs and can only be run on the laptop. Virtualization of that license is not normally allowed….

  5. John Bokma Says:

    “the free VMWare Player which allows you to use existing VMs but not create new ones.”

    But as
    http://johnbokma.com/mexit/2005/10/26/vmware-player-windows-xp.html
    explains one can create virtual machines with freeware. No need to download and install the trial of Workstation.

  6. John Bokma Says:

    Just a small note: nofollow links suck. Moderate your comments, but don’t punish genuine comments with using nofollow by default.

  7. Lindsay Says:

    Orhan -

    All the software I had installed on my old laptop is still installed in the backup as well… the System State restore takes care of it. Like I said, not only was the software still installed and usable, even the things that were loaded (like the ISO image on Daemonware) were still running! I am even doing .Net development on it until I get my new environments set up and everything works fine.

    The only problem I’ve encountered is that I lost one of my databases in SQL Server… it is now “suspect” and I can’t open it. I would make sure if you run SQL Server that you stop the service before you do your backup. I think I left mine running.

    So if you don’t have the Symantec Livestate tool, NTBackup is still a good option!

    As for the OEM licensing issue, I didn’t have that problem… I wiped and reinstalled my laptop when I first got it so the original OS installation was no longer there. But that might be a problem for others, yeah… Unfortunately I don’t know how to resolve that problem.

    John -
    Thanks for the link.. That’s pretty cool. I already bought a copy of VMWare because I need to be able to create VMs easily for my job, and can’t afford the time of hacking scripts for it, but that’s good information to know!

  8. Lindsay Says:

    John -

    I am still relatively new to Wordpress (I think it will be a month in a couple of days), and didn’t even know what nofollow was until I just Googled it from your comment. Certainly it isn’t my intention to punish anyone for commenting. I will look into it and find out my options are. Thanks for making me aware of it.

  9. Fabian Says:

    Typically SQL server will mark a db suspect as soon as it can’t open one of its files at startup. Once it is marked suspect, you can’t do anything. I believe there is a stores proc to reset the status (I’m on my mac now, so no access to help books online)

    I wonder if you could achive the same thing by brute force: copying your partitions straight to a file (or files) and use some free free tools like QEMU for virtualization (I like QEMU better because it is really free, opensource, and does not require any install on the host)

    I would create the image by using a simple live linux and using the command dd …

    Just a thought :)

  10. Antimail Says:

    Using NTBackup to achieve P2V

    I always thought about writing a post about physical-to-virtual migration strategies in combination…

  11. Mike G Says:

    Great article, I’ll be trying this out soon. It should work the same for a Server Edition install, yes?

  12. John Bokma Says:

    Lindsay - There is no scripting involved, just running a command line tool. On the other hand, as soon as I notice that I use the player more then casual I am going to buy Workstation :-)

    And thanks for looking into the nofollow issue.

  13. Dave D Says:

    Nothing wrong with Nofollow for comments…it’s not punishment. If Lindsay or another blog owner want to reward you for a good self-link they can and should do an update/edit or a new post including the link so it gets its search engine props.

  14. John Bokma Says:

    Dave -
    If you don’t moderate you get comment spam anyway
    If you do moderate, there is (IMNSHO) no reason for nofollow. If someone just posts to get a good link, the blog owner can reject the comment. That’s what I do.

  15. Federico Says:

    Did anyone get this error message when attempting this?

    —————————————
    Windows could not start because of a computer disk hardware configuration problem.

    Could not read from the selected boot disk. Check boot path and disk hardware.

    Please check the Windows documentation about hardware disk configuration and your hardware reference manuals for additional information.
    ————————————–

    I followed all the steps mentioned above, and this popped out at when I rebooted after restoring. I’m somewhat desperate to get my data back, and I’ve read a lot about chaning the boot.ini file to fix this problem, but I haven’t figured out how as I am running Ubuntu 5.1 as the host, and as a VM I can’t figure out how to get the “recovery console” (see http://support.microsoft.com/?kbid=314477#kb1). Any help would be wonderful. Thanks!

  16. Phil Schaffner Says:

    Have been getting similar errors when trying to follow the ArsTechnica Ghost procedure Lindsay referenced at the top. Failure to get multiple approaches to fixes for that to work for my backup/restore VMs led me here. (Have yet to get time to restore my Win2K NTBACKUP image to a VM). The Ghost-restored-image boot process always fails before one could get to the “F8″ options to boot to a console. Booting from a windows installation CD should give a recovery option, but this didn’t help for my Ghost image problems.

    The “captive” NTFS driver in older Knoppix distros was said to allow NTFS write access, but that was discontinued due to filesystem corruption problems in later releases.

    Another way to get write access to boot.ini would be to follow the procedures outlined at ArsTechnica to mount the “bad” VM disk as the second drive on a fresh installed Windows VM. Uet another would be to use a bootable Windows CD per the BartPE approach at http://www.nu2.nu/pebuilder/

  17. Bill W Says:

    Phil,

    Using Bart PE and REG.exe, you may be able to “fix” your ghost image within the vmsession. You will need to know the vm’s hardware types and storage type… most likely these are APCI/EPIC with IDE storage devices. I don’t have the exact reg keys, but you should be able to boot the vmsession with bart and use the reg.exe command to inject the correct vmhardware info into the reg of your restored ghost image. Oh… you may (probably) need the correct hal.dll, ntoskrnl.exe, and ntkrnlpa.exe files for a vm windows seesion as well. Since you have a ghost image you can safely experiment with this. Good luck.

  18. matthew k Says:

    I have been using vmware for years now for support, so I can walk folks through issues on different OS’s, but you hit on a really cool idea. I will have to try it. The use goes way beyond laptops.



===================================================================
/fin du copy&paste.

Aucun commentaire:

Enregistrer un commentaire

Votre commentaire constructif ( ou pas ! )

Archives du blog

Pages

Membres