In this blogpost I shall describe how you add an extra data disk to your Linux VM running on Azure.
Step 1 Add a new disk to your Linux VM using the Azure Portal
Choose Add data disk to add an extra data disk and choose create data disk.
For demo purposes I quickly entered a default 20 GiB HD, nothing fancy ๐
Don’t forget to save your changes!
Step 2 Connect to your VM using SSH or use the Serial console on your VM Pane in the Azure Portal
Use the following command to find all your data drives :
dmesg | grep SCSI
You see all your drives and the newly created drive
Here,ย sdcย is the newly added disk. Let’s continue.
Now we have to partition the added disk using the following command :
sudo fdisk /dev/sdc
Use theย n
ย command to add a new partition.ย In this example, we also chooseย p
ย for a primary partition and accept the rest of the default values.ย The output will be similar to the following example:
Now we are going to write a partition (format) the newly added disk using the following command :
sudo mkfs -t ext4 /dev/sdc1
Now we are going to mount the formatted drive using the following commands :
sudo mkdir /MyDataDrive
sudo mount /dev/sdc1 /MyDataDrive
You see your newly created disk :
To ensure that the drive is remounted automatically after a reboot, it must be added to theย /etc/fstabย file.ย Herefore I’m going toย use the blkid utility:
sudo blkid
Now copy the UUID :
Now we are going to add the UUID to the /etc/fstab. You can use VI or (like I prefer to use) nano.
sudo nano /etc/fstab
The format is als follows :
UUID=<YourUUID> /<YourMountPoint> ext4 defaults,nofail 1 2
In my case it looks as follows :
Ok, let’s reboot the VM and check if the drive still exists..
sudo reboot
Use the following command to check
df -h
As you can see the /MyDataDrive is still available after reboot.
Please Note: At the following step in above step-by-step procedure there is one correction-
To ensure that the drive is remounted automatically after a reboot, it must be added to the /etc/fstab file. Herefore Iโm going to use the blkid utility:
sudo blikid
The above command is: sudo blkid [and not sudo blikid]
Hope that saved some time for newbies troubleshooting the issue command not found while copy and pasting the command ๐
Thank you very much! I’ve updated the post.
What does 1 2 mean at the end of the line in the /etc/fstab ??
I want to add more disks
The 1 is for error correction and the 2 for back-up purposes!