VirtPanel Hypervisor Installation (Debian 8)

The following commands need to be executed on your physical server. We recommend a fresh install of Debian 8 Minimal with partitioning below.

1. Recommended Partitioning

When installing your server, we request the following custom partition layout.

Partition 1: 200 MB ext4 for /boot
Partition 2: 5 GB ext4 for / (root filesystem)
Partition 3: Empty space (for creating an LVM Physical Volume later)

 

2. Install VirtPanel Repo

Our software repository provides some custom pages which are unavailable from the official Debian repo. wget -O - http://repo.virtpanel.com/apt/debian/virtpanel.gpg.key | apt-key add -;echo 'deb http://repo.virtpanel.com/apt/debian jessie main' > /etc/apt/sources.list.d/virtpanel.list


 

3. Update the server

apt-get update;apt-get upgrade


 

4. Install required packages

apt-get install qemu-kvm qemu socat dosfstools uml-utilities rsync htop psmisc isc-dhcp-server ntfs-3g pv lvm2 thin-provisioning-tools kpartx parted dmidecode sudo smartmontools lzop lsof virtpanel-npd6 isc-dhcp-server lshw bwm-ng dmidecode util-linux drbd8-utils netcat lrzsz lsb-release net-tools


 

5. Post-install Partitioning (Optional but recommended)

After following step one, you should have a fresh installation of Debian 8 with our recommended partitions.
Execute the command parted /dev/sda p
You should see a partition layout similar to below. These numbers don't need to be exact, the figures we provide are just a recommendation.
Number  Start   End     Size    Type     File system     Flags
 1      2097kB  211MB   209MB   primary  ext4            boot
 2      211MB   5578MB  5368MB  primary  ext4
 3      5578MB  6114MB  536MB   primary  linux-swap(v1)

Our first partition is the boot partition. This dedicated partition allows the Linux Kernel to boot quicker and more reliably.
Our second partition is the root filesystem. This is where Debian stores all the Operating System files.
Our third partition is swap. Most data centres will create a swap partition. We recommend you delete this partition (we'll do this in the next step).
Notice how we didn't have a fourth empty partition with the empty space? That's fine, we'll cover how to create that partition manually below.

 

6. Prepare for the removal of the SWAP partition.

If you don't have a swap partition you can skip this step.
While this can be frowned upon, a SWAP partition is generally a bad idea when it comes to a dedicated machine for Virtual Machines. Once all available RAM is used, the swap file can be used by mistake and your server can come to a stand-still. We prefer to have the Virtual Machine fail to start so that memory allocations can be fixed before running VMs are effected.
Execute the command swapoff -a This will deactivate the active swap partition.
Execute the command nano /etc/fstab and remove the line containing "swap" by pressing Ctrl + K. Then press Ctrl + X to exit. Save changes and overwrite the file.
Reboot your server. Sometimes the kernel can hang onto the swap partition, so rebooting is generally a good idea before proceeding with deletion.

 

7. Removing the swap partition (Optional but recommended)

Execute the command parted /dev/sda 
The command p will show the list of partitions again.

...
 3      5578MB  6114MB  536MB   primary  linux-swap(v1)
Make note of the partition number for the swap volume for the next command. Here it is 3.
The command rm 3 will delete the partition.
The command p will show the list of partitions again. The swap partition should now be deleted.
The command q will exit parted.

 

8. Creating the empty partition if it was not created during installation

Execute the command parted /dev/sda 
The command p will show the list of partitions again.
If you already have an empty partition for an LVM Physical Volume, skip to step 6.
The command mkpart primary 5578MB 100% (replace 5578MB with the End value of the last partition) This will create a partition using all of the remaining space on the disk.
The command p will show the list of partitions again. Your disk should look full now, with the partition you just created having most of the space.
Number  Start   End     Size    Type     File system  Flags
 1      2097kB  211MB   209MB   primary  ext4         boot
 2      211MB   5578MB  5368MB  primary  ext4
 3      5578MB  120GB   114GB   primary               lba
The command q will exit parted.

 

9. Unmounting the "empty partition" if it was formatted during installation.

If you just created a partition in the step 5 above, you can skip this step.
Usually a data centre will format an "empty partition" you specified. This means Linux will mount it during boot which will prevent us from creating the Physical Volume for LVM on that partition.
So, check if the partition is mounted.
The command mount | grep /dev/sda will get a list of mounted file systems.
If your empty partition is mounted, you need to unmount with the command umount /mnt/example
Execute the command nano /etc/fstab and remove the line containing the empty partition by pressing Ctrl + K. Then press Ctrl + X to exit. Save changes and overwrite the file.

 

10. Creating the LVM Physical Volume

If your empty partition number is 3 like above then the path would be /dev/sda3
If the number is different, it should be replaced in the commands below.
The command pvcreate /dev/sda3 will create the physical volume on the empty partition. If you get an error about the partition being busy the partition is probably mounted... make sure you followed step 6 correctly. If you have, make sure you are using the correct partition number.
The command vgcreate vg1 /dev/sda3 will create the Volume Group.
The command lvcreate -l 100%FREE --thinpool thin_vg1 vg1 will create the Thin Volume.

 

11. Setup template storage

If you have multiple servers in the same data centre, we recommend setting up an NFS server to serve the templates to the other servers.
To host the templates on this server, you will need to create a Logical Volume to store the templates inside.
The command lvcreate -n templates -V 50G --thinpool vg1/thin_vg1 will create a Thin Logical Volume for template storage.
The command mkfs.ext4 /dev/vg1/templates will format the Logical Volume as ext4.
The command mkdir -p /virt/templates/qemu will create the template folder.
Execute the command nano /etc/fstab and add a line like below.
/dev/vg1/templates /virt/templates/qemu ext4 defaults,noatime 0 0
Then press Ctrl + X to exit. Save changes and overwrite the file.
The command mount /virt/templates/qemu will mount the template Logical Volume.
You should now see template capacity when you execute the command df -h
...
/dev/mapper/vg1-templates   50G   52M   47G   1% /virt/templates/qemu
 

12. Configure DNS (Optional)

Some providers DNS can be unreliable which can cause intermittent issues. We recommend you set your DNS to Google or OpenDNS.

Warning: If your data centre offers DDOS protection, when your server is under attack you may not be able to use external name servers. In this case we recommend you use their default name servers.

The command below is for Google.
echo -e "nameserver 8.8.8.8\nnameserver 8.8.4.4" > /etc/resolv.conf


 

13. Enable LVM Discards

sed -i -e '/issue_discards =/ s/= .*/= 1/' /etc/lvm/lvm.conf


 

14. Avoid SWAP file unless completely necessary

sed -i '/vm.swappiness/d' /etc/sysctl.conf;echo 'vm.swappiness=1' >> /etc/sysctl.conf;sysctl -p


 

15. Configure DHCPD for the first time

echo -e 'authoritative;\nddns-update-style none;\ndefault-lease-time 2592000;\npreferred-lifetime 604800;\noption dhcp-renewal-time 3600;\noption dhcp-rebinding-time 7200;\nsubnet 0.0.0.0 netmask 0.0.0.0 { }' > /etc/dhcp/dhcpd.conf;systemctl restart isc-dhcp-server.service


Next: Getting Started » Use cp.yourdomain.com instead of you.virtpanel.com
Previous: Getting Started » VirtPanel Installation

Testimonials