1. Check the partitions information of the target disk.

sudo fdisk -l
# OR
sudo parted -l

2. Partition a new disk

sudo parted /dev/sdc --script mklabel gpt mkpart xfspart xfs 0% 100%
sudo mkfs.xfs /dev/sdc1
sudo partprobe /dev/sdc1

Replace sdc with the correct option for the disk. Use the partprobe utility to make sure the kernel is aware of the new partition and filesystem. Failure to use partprobe can cause the blkid or lslbk commands to not return the UUID for the new filesystem immediately.

We can also use the following commands to make an ext4 partition.

sudo parted /dev/sdc --script mklabel msdos mkpart primary ext4 0% 100%
sudo mkfs.ext4 /dev/sdc1
sudo partprobe /dev/sdc1

To see more discussions about xfs vs ext here: How to Choose Your Red Hat Enterprise Linux File System

3. Mount the disk

sudo mkdir /data
sudo mount /dev/sdc1 /data

4. To remount the disk automatically

To ensure that the drive is remounted automatically after a reboot, it must be added to the /etc/fstab file. It is also highly recommended that the UUID (Universally Unique Identifier) is used in /etc/fstab to refer to the drive rather than just the device name (such as /dev/sdc1). If the OS detects a disk error during boot, using the UUID avoids the incorrect disk being mounted to a given location. Remaining data disks would then be assigned those same device IDs. To find the UUID of the new drive, use the blkid utility:

sudo blkid

Next, edit the /etc/fstab file and add the following line.

UUID=xxxxxxxx  /data  xfs/ext4  defaults,nofail  1  2


Azure Documentation - Virtual Machines / Linux / Disks


Add a new comment.