How to create a virtual machine server image from a physical CentOS server

How to create a virtual machine server image from a physical CentOS server

I run a couple of servers over at a server farm. All of those machines run VMWare ESX, so today I wanted to move my last physical server to a VMWare image. If you want to convert a physical Windows machine then your task is quite easy. Start up the freely available VMWare Converter and start converting your physical machine to a virtual one. But what about when you need to convert a Linux server?

Since I really did not want to setup a new CentOS machine with all the packages I need and copying stuff from the physical to the virtual I did the following steps successfully. Keep in mind that this is on CentOS 5.2. I am sure this works for other Linux distributions as well.

  1. Create a new virtual machine and install the bare minimum CentOS. I used the CentOS NetInstall Option. This takes about 20 minutes or so.
  2. Now, create a “backup” directory on the root level (“/”) of your disk and copy the following directories into this backup directory;
    1. boot
    2. etc/fstab
    3. lib/modules
  3. Then on your physical server create tarball with the following directories included;
    1. boot
    2. bin
    3. etc
    4. home
    5. lib
    6. sbin
    7. usr
    8. root
    9. var
    10. opt

    Include any other directories that you need or have created. You should not need to include the “tmp” or the “lost & found” one. It is important to keep the permissions settings and this use the following command to create the tar;
    tar czvfp physicalserver.tgz <directoriesabove>
    (be prepared to make yourself some coffee in the meantime)

  4. Copy the file physicalserver.tgz to your new virtual machine.
  5. On the virtual machine move the physicalserver.tgz to the root (“/”) folder and extract it. This will probably take some time and you should get to your second cup of coffee.
  6. Once it has finished extracting do not attempt to reboot the server. Doing so will most probably render your image unbootable!
  7. Copy all of the directories within the backup directory to their original position (the ones from step 2) and confirm to overwrite existing files.
  8. Once done, issue the command “grub”. You will then be in the grub editor. Type the following commands to create a new MBR;
    1. root (hd0,0) (this is hd<zero>,<zero>)
    2. setup (hd0) (this is hd>zero)
      You should see some confirmation messages. Type “quit” to exit the editor.
  9. Now reboot the server and pray 🙂

I have done the above steps with 3 servers and it has always worked without problems. But there are some post-reboot steps that you should do as well. They are;

  1. Network Adapter. During the move above you will loose your network adapter. Thought CentOS still got everything setup and all working, you wont be able to reach outside of the virtual machine. Funny thing is that the Network Adapter in the Virtual Machines Configuration Settings also shows no problem. To make it work again you have to remove the Network Adapter in the Virtual Machine Settings and add one again.
  2. Install VMWare Tools. Since your physical server has no VMWare Tools installed this is a obvious step.
  3. Run security configuration. In my case, after step 1 and 2 above were done, I still could not get outside of my network. This was due to a mess up with the security settings of CentOS and most probably SELinux is running and prohibiting any network traffic. Simply run “system-config-security” in the shell and adjust your settings.
  4. Reboot your server.

With the above steps you should have a full copy of your physical server on your virtual machine environment. Let me know how it goes for you in the comments.

Helpmonks All-in-one Customer Service Platform
Deployment Models for Razuna Digital Asset Management

I often get the question about how Razuna can be deployed, so I decided to do a short blog post to outline the options. Some of our enterprise customers, prefer to to have Razuna deployed on their own servers, sometimes even behind firewalls. Other customers prefer to have us handle…

Google Pixelbook Go
Review of the Pixelbook Go

I like to get my hands on the latest hardware and also check out as many alternatives to the established Windows and macOS "way of working." Naturally, I was very interested in ChromeOS and what it has to offer. However, previous "low-cost" Chromebook offerings had little allure for me as…

Helpmonks All-in-one Customer Service Platform
Exchange, Kerio, Zimbra and Google or the Quest for the perfect Collaboration tool

One of my main goals in my everyday work flow is to keep all my informations at one central location and have access to them from everywhere. Meaning I want all my emails, contacts and calendar entries in sync, whether I use my mobile phone, my own laptop or I…

Helpmonks All-in-one Customer Service Platform
Setting the correct Java version under MacOS X

My favorite scripting language is CFML, or as some know it as ColdFusion. I like it because it is very very powerful, easy to use and can do just about everything your xyz language can do. For many years, ColdFusion was a closed sourced system, where the former Macromedia and…

Helpmonks All-in-one Customer Service Platform
CFML and Cannot run program "chmod": java.io.IOException: error=24, Too many open files

Migrating one of my customers the other day, bought up an ugly error when I had to create 2000 directories on one go. The error was: [code]Cannot run program "chmod": java.io.IOException: error=24, Too many open files[/code] While, "too many open files" usually means one can raise the limit of open…

Helpmonks All-in-one Customer Service Platform
Looking for a Chromebook? Get this instead

The following is my personal opinion. I'm not affiliated with any of the companies mentioned below, nor did anyone pay me for this post. Are you currently looking for a Chromebook? Maybe the new Samsung Chromebook or the latest Pixelbook Go? Is the device you are looking at coming with…

Trusted by over 2,000 organizations with millions of emails

Helpmonks helps us answer customer emails at lighting speed
We couldn't do our job without Helpmonks!
Helpmonks, the best thing since sliced bread
Excellent option for collaborating email amongst your team
A good platform that is here to grow and help you grow
Helpmonks is a great tool that our company utilizes and depends on
Great shared inbox for the team
Fantastic email support service for any business
Easy to navigate and catalog data for specific users
Solid Helpdesk software w/ responsive customer support
A really good solution to manage customer support mailbox
Good support, useful features

One more thing...

Helpmonks gives you the ability tocollaborate as a groupin your shared mailbox, features aTeam To-Do App, powerfulCustomer Relationship Management (CRM)capabilities, a completeLive-Chat tool, a mighty Email Marketing Platform that includes sending ofemail campaignsandemail automation, collision detection, email tracking, reminders, mentions, custom fields, custom applications, customer satisfaction ratings, Single-Sign-On (SSO) & SAML authentication, Trello, Zapier, Slack, an API, and much more.

Check outthe complete feature listor sign up for afree 30-day shared inbox trial now