How to attach a volume that is larger than 2TB to a VM in Linux?
If the volume does not exist yet, it must be created. Go to Horizon “Volumes” and click “Create Volume”. Give it an appropriate name, select size and disk type (either HDD-default or SSD).
Now, from the “Volume” menu, select “Manage Attachments” and attach the volume to the desired instance. It becomes visible as a block device, like /dev/sdb.
If the volume had not been used before, it has to be partitioned and formatted first, e.g.:
sudo fdisk /dev/sdb
Change the partition type to GPT. This allows you to create partitions bigger than 2TB.
Command (m for help): g
Created a new GPT disklabel (GUID: C84B1D6A-B3B6-1A40-9682-CA462AB62555).
Enter “n” for the new partition and leave the rest at default values:
Command (m for help): n
Partition number (1-128, default 1):
First sector (2048-6442450910, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-6442450910, default 6442450910):
Created a new partition 1 of type 'Linux filesystem' and of size 3 TiB.
Enter “w” to save the new partition:
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
Previously used volume (moved from other VM) is usually already partitioned and formatted.
Now mount the volume in the system. Edit /etc/fstab using your favorite editor (nano, vim) to add the line:
/dev/sdb1 /my_volume ext4 defaults 0 1
Create a mounting point, then mount the volume:
sudo mkfs.ext4 /dev/sdb1
sudo mkdir /my_volume
sudo mount /my_volume
On the next reboot, the volume will be mounted automatically. Volumes may be attached to a live system, without the need to reboot it.