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.
- 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 diskqemu-img resize centos-7.4-x86_64.gpt.img +16384
- Run gdisk on disk
gdisk /disk/path
- Create new partition of following specification:
Partition number:128
First sector:34
Last sector:2047
Hex code or GUID:ef02
- Save changes made, by typing w and then (if asked to overwrite) Y (this will convert MBR to GPT)
- 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- Map disk partitions and note first partition mapped name (eg loop0p1)
kpartx -avs /disk/path
- Now mount disk's first partition whose name we obtained above to mount point (we will use /mnt)
mount /dev/mappper/loop0p1 /mnt
- 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 - Now chroot into the mount point
chroot /mnt
- After chroot, we will install grub specific to mounted disk's OS
- Install Grub in VPS disk
- If OS is CentOS 7 or above
- Install grub2 in VPS chrooted disk (here its loop0)
grub2-install /dev/loop0
- Install grub2 in VPS chrooted disk (here its loop0)
- If OS is Ubuntu 16 / Debian 10 or above
- Install grub in VPS chrooted disk (here its loop0)
grub-install /dev/loop0
- Install grub in VPS chrooted disk (here its loop0)
- If OS is CentOS 7 or above
- Exit chroot
exit
- Install Grub in VPS disk
- 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
- Map disk partitions and note first partition mapped name (eg loop0p1)
- Remove disk mapping
kpartx -d /disk/path
- Remove partition number 128 from VPS disk created in step 3 above
gdisk /disk/path
Type:
d
128
w
Y - Done.