If your Azure VM's data disk is unmounting by itself, switch from using the device name (like /dev/sda1) to using the disk's UUID in your /etc/fstab. Find the UUID with sudo blkid, and then update /etc/fstab like this: UUID=your-uuid /mnt/data ext4 defaults 0 2. This prevents the issue where device names change, which is likely causing your mounts to disappear.
Data disk on Azure VM (Ubuntu 20) is automatically unmounted time to time
I have created a virtual machine with Ubuntu 20 OS. It has one OS disk and 128GB secondary data disk (seperately purchased) to store all the application data.
I have mounted it on /mnt/data directory. But time to time that mount is dissapearing.
after restart the drive mame is sda -> sda1 and another time it will become sdc -> sdc1.
Already updated the FSTAB as below.
/dev/sda1 /mnt/data ext4 defaults 0 2
how to solve this.
Thanks in advance.
2 answers
Sort by: Most helpful
-
-
Sumarigo-MSFT 46,441 Reputation points Microsoft Employee
2024-03-25T10:27:44.86+00:00 @Jayashan Welcome to Microsoft Q&A forum, Thank you for posting your query here!
To ensure persistent disk mounting for secondary data disks on an Azure VM with Ubuntu, you should use UUIDs instead of device names in your
/etc/fstab
file, as device names can change across reboots. Here's how you can set it up:- Find the UUID of the disk you want to mount by running the following command:
This will output a list of all the available disks and their UUIDs.sudo blkid
- Once you have the UUID, add an entry to the
/etc/fstab
file using the following format:
UUID=<UUID> <mount_point> <file_system_type> <options> <dump> <pass>
For example, if the UUID of your disk is
33333333-3b3b-3c3c-3d3d-3e3e3e3e3e3e
and you want to mount it at/datadrive
with thexfs
filesystem type and default options, you can add the following line to the/etc/fstab
file:UUID=33333333-3b3b-3c3c-3d3d-3e3e3e3e3e3e /datadrive xfs defaults,nofail 1 2
After adding the entry, save and close the file using
Ctrl+O
to write the file andCtrl+X
to exit the editor.By using UUIDs, you ensure that the correct disk is mounted to the specified mount point regardless of the device name assigned at boot.
Option 2
Here's how you can do it using the UUID:
- Find out the UUID of your secondary data disk using the following command:
sudo blkid
This command will display information about all block devices. Look for the line corresponding to your secondary data disk (/dev/sdX1) and note down its UUID.
Update your
/etc/fstab
file to use the UUID instead of the device name. Open the file using a text editor:sudo nano /etc/fstab
Modify the line for your secondary data disk to use the UUID. The line should look something like this:
UUID=<your-uuid> /mnt/data ext4 defaults 0 2
Replace
<your-uuid>
with the UUID you obtained in step 1.Save the changes and exit the text editor.
You may need to remount the filesystem to apply the changes immediately:
sudo mount -a
Now, your secondary data disk should be mounted consistently across reboots, regardless of the device enumeration order. This approach ensures that your system always mounts the correct disk based on its unique identifier
References:
- Tutorial - Manage Azure disks with the Azure CLI
- Enable Azure Disk Encryption with Microsoft Entra ID on Linux VMs (previous release)
- Troubleshoot a Linux VM by attaching the OS disk to a recovery VM using the Azure portal
- Troubleshoot Linux VM device name changes
Please let us know if you have any further queries. I’m happy to assist you further.
Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.
- Find the UUID of the disk you want to mount by running the following command: