Attaching volumes greater than 2TB to an Azure Linux VM

These days it is fairly common that I need to store and process large volumes of data. This isn’t possible with fdisk; you’ll need to turn to something like parted if you want to create a volume larger than 2 terabytes. Here’s how…

This does not have to be an Azure Linux VM of course…

Create the disk in Azure and attach it to your VM.

Log in to your VM, confirm the disk is recognized:

sladeedmonds@debian:~$ sudo dmesg|grep sdc
[sudo] password for sladeedmonds:
[    2.972816] sd 5:0:0:0: [sdc] 4294967296 512-byte logical blocks: (2.20 TB/2.00 TiB)
[    2.980731] sd 5:0:0:0: [sdc] 4096-byte physical blocks
[    2.994619] sd 5:0:0:0: [sdc] Write Protect is off
[    2.998700] sd 5:0:0:0: [sdc] Mode Sense: 0f 00 10 00
[    3.000330] sd 5:0:0:0: [sdc] Write cache: disabled, read cache: enabled, supports DPO and FUA
[    3.019446] sd 5:0:0:0: [sdc] Attached SCSI disk
[ 1794.756493]  sdc: sdc1    

Good, the VM has detected the disk at /dev/sdc. Now you just need to partition the disk, create a filesystem on it, and then mount it.

First, partition the disk with parted by creating a label and then the primary partition.

sladeedmonds@debian:~$ sudo parted /dev/sdc
GNU Parted 3.2
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Error: /dev/sdc: unrecognised disk label
Model: Msft Virtual Disk (scsi)
Disk /dev/sdc: 2199GB
Sector size (logical/physical): 512B/4096B
Partition Table: unknown
Disk Flags:
(parted) mklabel
New disk label type? GPT
(parted) mkpart primary 0GB 2199GB
(parted) p
Model: Msft Virtual Disk (scsi)
Disk /dev/sdc: 2199GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name     Flags
 1      1049kB  2199GB  2199GB               primary

Now, create the filesystem:

sladeedmonds@debian:~$ sudo mkfs /dev/sdc1
mke2fs 1.43.4 (31-Jan-2017)
Found a gpt partition table in /dev/sdc1
Proceed anyway? (y,N) y
Discarding device blocks: done
Creating filesystem with 536870400 4k blocks and 134217728 inodes
Filesystem UUID: 6178c34e-6763-42dc-a2d3-638958efaf61
Superblock backups stored on blocks:
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
	4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
	102400000, 214990848, 512000000

Allocating group tables: done
Writing inode tables: done
Writing superblocks and filesystem accounting information: done

Finally, mount the drive:

sladeedmonds@debian:~$ sudo mount /dev/sdc1 /home/testdata
sladeedmonds@debian:~$ df -h | grep sdc
/dev/sdc1       2.0T   71M  1.9T   1% /home/testdata

Yay, done.

Leave a comment

Close Bitnami banner
Bitnami