0

I am relatively new to running virtual machines / OpenVZ containers so if I have miss understood something please let me know.

I currently have Ubuntu 14.04.1 installed straight to a partition on my server. My intention is to completely rebuild and restructure my server (which could take some time) without removing the installation I currently have. The limitation is I only have one server.

To complete this I thought it would make sense to install something like Proxmox VE (https://www.proxmox.com/proxmox-ve) and move my current installation of Ubuntu to a VM / OpenVZ container running on Proxmox. This way I can have a small downtime (which is completely fine) as I set this up rather than the long down time as described above. The second advantage is I can create my new server installation on a separate VM / OpenVZ container.

My question is, how do I go about moving the installation of Ubuntu I currently have in to a VM / OpenVZ Container with Proxmox? To my understanding an OpenVZ container would be more preferable as it has a lower overhead than a full VM.

Falcon Momot
  • 24,975
  • 13
  • 61
  • 92
JamesStewy
  • 227
  • 2
  • 3
  • 8

1 Answers1

1

So, after a while I have stumbled upon some search terms that helped me find my way this completing this task myself. In the end I found that it is near impossible to go straight to an OpenVZ container but I did manage to transfer over to a KVM Virtual Machine on Proxmox. Here are the steps I took (make sure to read everything before starting it yourself):

Create Image of Physical machines partition

  1. Back up your partition. In the next section the entire hard drive will be wiped.
  2. Create a Clonezilla Live USB/CD. Instructions and downloads can be found here. Keep a copy of the ISO for step 11.
  3. Use GParted or equivalent software to shrink the partition you want to move to into a virtual machine. I left about 5GB extra. If your partition contains important information, make sure you have backed up.
  4. Shutdown main system and reboot into the Clonezilla Live USB/CD
  5. Follow the instructions under the Save Image heading on this page to create an image of your partition using the saveparts options in the Select mode menu. Make sure you save your partition image to an external drive. Enable all the pre and post image checks to make sure the process was successful.

Install Proxmox VE

  1. Make sure you have a copy of everything on the hard drive. The installation of Proxmox will remove everything on the hard drive you install it to.
  2. Download the Proxmox VE iso from here and burn it to a CD/USB.
  3. Remove all external drives.
  4. Boot into the Proxmox VE installation and follow the prompts. Note which drives will be wiped after accepting the EULA.
  5. Once completed navigate the the address presented at the log on screen (should be a HTTPS link). This is the Proxmox web UI.

Creating the Virtual Machine

  1. On the left hand side: open all lists, click on local; click Content on the upper-central tabs; click upload; click select file and navigate to the Clonezilla Live ISO you downloaded in step 2; click upload and wait for it to finish.
  2. Click Create VM in the top left of the screen. Keep all the setting the same except:
    • Give it a name
    • Select an OS which matches the OS in your saved partition (mine was Linux 3.X/2.6 Kernel (I26))
    • Click the ISO Image drop down box and select the Clonezilla Live ISO you just uploaded
    • Change the disk size to be greater than the size of your saved partition
    • You may want to change CPU and Memory setting but it is not mandatory and they can be changed later.
  3. Confirm the creation of the VM by clicking finish on the final page.
  4. Follow the steps here to assign a USB port to this Virtual Machine so it can access your external storage. You can run the commands featured on the linked page by either logging in on the physical machine or by clicking the node then clicking console.

Recovering your partition into the Virtual Machine

  1. Re-attach your external storage to the USB port you mapped in step 14.
  2. Boot the Virtual Machine by clicking start in the top right corner.
  3. Attach to the Virtual Machine by clicking console in the top right corner.
  4. Follow the steps under the Restoring the Image heading on this page to restore the partition. Make sure to use the restoreparts option under the Select mode menu. Note: at step 13 in the linked tutorial Clonezilla will fail as there is no partition on /dev/sda. When this happens:
    • Hit enter to start a new terminal session
    • Run fdisk /dev/sda
    • Type n and hit enter to create a new partition
    • Accept all the defaults by hitting enter
    • Once completed type w and hit enter to write the changes to the disk
    • Finally run exit to exit the terminal session and hand back to Clonezilla
    • A new partition (sda1) should appear in the menu now
  5. Once Clonezilla has completed select the option to Power off.

Make the partition bootable

  1. Navigate back to /etc/pve/qemu-server/<VM_ID>.conf and remove the usb0 entry.
  2. In the Proxmox web UI: click on the Virtual Machine; click Options; click on Boot Order; click edit; change the order to CD-ROM then Disk 'ide0'.
  3. Download the Super Grub2 ISO from here and you the same process as in step 11 to upload it to Proxmox.
  4. Now click on the Virtual Machine; click on Hardware; click on the CD\DVD Drive entry; click Remove; click add then CD/DVD Drive; under the Storage option click on local; under the ISO Image option click the Super Grub2 ISO; finally click create.
  5. Now start the Virtual Machine again and open an attached console. You should now see a screen that looks like this.
  6. Select Everything then select the OS you want to boot (in my case it was Ubuntu). If your OS is not there, find out more advanced features of Super Grub2 here.
  7. Once booted you need to install a boot loader to /dev/sda. In my case I installed Grub2 by running sudo grub-install /dev/sda.
  8. Now shutdown the Virtual Machine and go back to the Proxmox web UI.
  9. Now click on the Virtual Machine; click on Hardware; click on the CD\DVD Drive entry; click Remove.
  10. You can now start your Virtual Machine and your partition will automatically boot

If you encountered an issue along the way leave you can leave a comment but I would probably recommend you create a post here on ServerFault instead and link this question in. That way someone more qualified than I am can help you out. If there is anything unclear in my steps just leave a comment and I will try and clear it up. I hope this tutorial helps :)

JamesStewy

JamesStewy
  • 227
  • 2
  • 3
  • 8