How to mount Azure data drive

main steps from documentation

Jun 4, 2020 | - views

The standard Azure VM's volume is named as OS Volume and by default it is around 30GB. So you need to attach data volume and save this mount after restart.

0. Attach data volume in Azure Portal

1. Found new disks

Your new disk will be sd*: sdc, sdd, ...; In this case new data disk is sdc

# dmesg | grep SCSI

[    0.294784] SCSI subsystem initialized
[    0.573458] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 252)
[    7.110271] sd 2:0:0:0: [sda] Attached SCSI disk
[    8.079653] sd 3:0:1:0: [sdb] Attached SCSI disk
[ 1828.162306] sd 5:0:0:0: [sdc] Attached SCSI disk

2. Partition a new disk

# fdisk /dev/sdc

Enter n then p:

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x2a59b123.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-10485759, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-10485759, default 10485759):
Using default value 10485759

Enter p then w

Command (m for help): p

Disk /dev/sdc: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders, total 10485760 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x2a59b123

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1            2048    10485759     5241856   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Now, write a file system to the partition with the mkfs command. Specify your filesystem type and the device name. The following example creates an ext4 filesystem on the /dev/sdc1 partition that was created in the preceding steps:

# mkfs -t ext4 /dev/sdc1

3. Mount the disk

# mkdir /datadrive
# mount /dev/sdc1 /datadrive

4. Save mount after restart

Copy your UUID for data drive (in this case /dev/sdc1 = 33333333-3b3b-3c3c-3d3d-3e3e3e3e3e3e)

# blkid

/dev/sda1: UUID="11111111-1b1b-1c1c-1d1d-1e1e1e1e1e1e" TYPE="ext4"
/dev/sdb1: UUID="22222222-2b2b-2c2c-2d2d-2e2e2e2e2e2e" TYPE="ext4"
/dev/sdc1: UUID="33333333-3b3b-3c3c-3d3d-3e3e3e3e3e3e" TYPE="ext4"

Add new record in /etc/fstab file:

# vi /etc/fstab

Add new line with device UUID and mount point:

UUID=33333333-3b3b-3c3c-3d3d-3e3e3e3e3e3e   /datadrive   ext4   defaults,nofail   1   2

When done, save the /etc/fstab file and reboot the system.

5. Verify

Found your mounted disk:

# df -lh

Relative articles: