This is the first article in a series about using large vDisks on OnApp KVM compute resources. vDisks are normally restricted to a two terabyte maximum size, because of the well-known msdos partition table limitation. That’s a fairly large disk capacity for a virtual server, but you may still have the need to use larger vDisks.
In this article, you can find a little hack to add a new virtual drive that’s less than 2TB, and subsequently resize it to more than 2TB.
* Note. The following procedure is applicable only to Linux-based Virtual Servers running on KVM compute nodes.
How to create a new vDisk larger than 2TB
To create a vDisk with capacity bigger than 2TB, follow these steps:
1. Add a new virtual disk that is less than 2TB to the existing target Virtual Server (VS), via the OnApp GUI:
2. Connect to the VS via SSH or VNC console and locate the vDisk you have just created.
root@onappgpttest:~# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT fd0 2:0 1 1.4M 0 disk vda 253:0 0 5G 0 disk └─vda1 253:1 0 5G 0 part / vdb 253:16 0 1G 0 disk [SWAP] vdc 253:32 0 1000G 0 disk └─vdc1 253:33 0 1000G 0 part
In the example, it’s a 1TB vdc disk. It has an msdos partition table and no data, because it’s a new vDisk.
root@onappgpttest:~# parted -s /dev/vdc unit s print Model: Virtio Block Device (virtblk) Disk /dev/vdc: 2097152000s Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 1024s 2097151999s 2097150976s primary ext3 boot
3. Next we’re going to convert the vDisk from msdos to GPT – but before you do that, install the gdisk utility. It allows you to convert without data loss.
apt install gdisk
yum install gdisk
4. Delete the existing partition and convert the vDisk from msdos to GPT.
root@onappgpttest:~# parted -s /dev/vdc rm 1 root@onappgpttest:~# sgdisk -g /dev/vdc
When the operation has been completed successfully, the vDisk will have been converted to GPT.
5. Increase the vDisk capacity via the OnApp GUI, as you require.
* Note. There should be no partition on the vDisk before resizing in GUI, otherwise, the transaction will fail.
It doesn’t matter whether you use OnApp’s Integrated Storage or an LVM-based datastore, since the procedure involves only the resize of a logical volume.
The transaction will run successfully if there is no msdos partition. The transaction also requires a reboot of the VS.
6. Connect to the VS via SSH or VNC console again to check if the vDisk size is the one you need.
root@onappgpttest:~# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT fd0 2:0 1 4K 0 disk vda 253:0 0 5G 0 disk └─vda1 253:1 0 5G 0 part / vdb 253:16 0 1G 0 disk [SWAP] vdc 253:32 0 2.5T 0 disk
7. Next, move the second header to the end of the extended virtual disk. This allows you to use the whole increased space for a partition.
* Note. GPT writes its partition table to both ends of the disk, unlike MBR, which only uses the beginning.
root@onappgpttest:~# sgdisk -e /dev/vdc
8. Create a new partition to the end of the vDisk.
root@onappgpttest:~# sgdisk -N 1 /dev/vdc
9. Finally, you need to format the vDisk’s partition to the file-system you want.
root@onappgpttest:~# mkfs.ext3 /dev/vdc1
This vdisk has been resized and is ready to use.
* Remember! This guide is applicable only when adding new virtual disks for Linux virtual servers running on KVM compute resources.
* Also note. You won’t be able to decrease the size of the virtual disk with the increased capacity. Information about increasing the size of GPT vDisks without data loss will be provided in the next article of this series.
I hope you find this information useful! In my next post, I’ll explain how to resize an existing vDisk beyond 2TB. If you need any help, contact OnApp support. Thanks!