Get Virtualizor

Convert MBR partition to GPT partition of VPS OS template or VPS OS disk

Virtualizor (since 3.0.6) supports GPT based VPS disk partition, which allows VPS disk's partition size to be greater than 2TB. Below are the steps that you can follow to convert existing OS template or VPS OS disk MBR partition to GPT partition.

  1. Increase disk size by 16896 bytes (i.e 33 x 512 Bytes) to make space for GPT backup table which is always at end of disk (last 33 blocks)
    Eg, For Raw file centos-7.4-x86_64.gpt.img disk
    qemu-img resize centos-7.4-x86_64.gpt.img +16384
  2. Run gdisk on disk
    gdisk /disk/path
  3. Create new partition of following specification:
    Partition number: 128
    First sector: 34
    Last sector: 2047
    Hex code or GUID: ef02
  4. Save changes made, by typing w and then (if asked to overwrite) Y (this will convert MBR to GPT)
  5. Now mount disk and chroot to it (here we will mount disks first partition to /mnt and chroot to it)
    Note: This step is required because we need OS specific grub utility to install grub
    1. Map disk partitions and note first partition mapped name (eg loop0p1)
      kpartx -avs /disk/path
    2. Now mount disk's first partition whose name we obtained above to mount point (we will use /mnt)
      mount /dev/mappper/loop0p1 /mnt
    3. Mount system partitions to /mnt so that all commands work and all disks are visible when we chroot to mounted disk.
      mount --bind /proc /mnt/proc
      mount --bind /sys /mnt/sys
      mount --bind /dev /mnt/dev
    4. Now chroot into the mount point
      chroot /mnt
    5. After chroot, we will install grub specific to mounted disk's OS
      1. Install Grub in VPS disk
        1. If OS is CentOS 7 or above
          1. Install grub2 in VPS chrooted disk (here its loop0)
            grub2-install /dev/loop0
        2. If OS is Ubuntu 16 / Debian 10 or above
          1. Install grub in VPS chrooted disk (here its loop0)
            grub-install /dev/loop0
      2. Exit chroot
    6. Unmount system partitions and VPS disk in reverse order of steps followed while mounting
      umount /mnt/dev
      umount /mnt/sys
      umount /mnt/proc
      umount /mnt
  6. Remove disk mapping
    kpartx -d /disk/path
  7. Remove partition number 128 from VPS disk created in step 3 above
    gdisk /disk/path
  8. Done.

    Was this page helpful?
    Newsletter Subscription
    Subscribing you to the mailing list