Mounting Azure LUN Drives or Data Disks in Ubuntu 24.04
Posted December 18, 2024
By Kevin Schwickrath2 min read
I play in the “cloud,” and sometimes my cloud needs additional storage. Azure data disk or LUN storage is inexpensive and easy. Here is how I mounted my extra 128G disk in Ubuntu 24.04.
Find the disk
lsblk -o NAME,HCTL,SIZE,MOUNTPOINT | grep -i "sd"Examples… sdc is my target.
kevin@cloud9:~$ lsblk -o NAME,HCTL,SIZE,MOUNTPOINT | grep -i "sd"sda 0:0:0:0 64G├─sda1 63G /├─sda14 4M├─sda15 106M /boot/efi└─sda16 913M /bootsdb 0:0:0:1 16G└─sdb1 16G /mntsdc 1:0:0:0 128GFormat the disk and create the partitions
sudo fdisk /dev/sdcOptions
- g
- n
- enter
- enter
- enter
- w
kevin@cloud9:~$ sudo fdisk /dev/sdc
Welcome to fdisk (util-linux 2.39.3).Changes will remain in memory only, until you decide to write them.Be careful before using the write command.
Device does not contain a recognized partition table.Created a new DOS (MBR) disklabel with disk identifier 0x0d8af232.
Command (m for help): gCreated a new GPT disklabel (GUID: 8379B0DB-990C-452E-8764-46DDC2593BEE).
Command (m for help): nPartition number (1-128, default 1):First sector (2048-536870878, default 2048):Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-536870878, default 536868863):
Created a new partition 1 of type 'Linux filesystem' and of size 256 GiB.
Command (m for help): wThe partition table has been altered.Calling ioctl() to re-read partition table.Syncing disks.sudo mkfs.ext4 -F /dev/sdc1kevin@cloud9:~$ sudo mkfs.ext4 -F /dev/sdc1mke2fs 1.47.0 (5-Feb-2023)Discarding device blocks: doneCreating filesystem with 67108352 4k blocks and 16777216 inodesFilesystem UUID: 4ebca0b7-fb7e-45f8-8197-bf2b7a3e34f9Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872
Allocating group tables: doneWriting inode tables: doneCreating journal (262144 blocks):doneWriting superblocks and filesystem accounting information: doneMount drives
sudo mkdir -p /datasudo mount /dev/sdc1 /dataMount drive
I mount the drive and test fstab BEFORE I reboot. While recovering isn’t overly complicated, it is much easier to fix typos at this stage.
Do not use /mnt for your mount point. This is a temp disk in Azure and will be erased.
kevin@cloud9:~$ cat /mnt/DATALOSS_WARNING_README.txt data/ lost+found/kevin@cloud9:~$ cat /mnt/DATALOSS_WARNING_README.txtWARNING: THIS IS A TEMPORARY DISK.
Any data stored on this drive is SUBJECT TO LOSS and THERE IS NO WAY TORECOVER IT.
Please do not use this disk for storing any personal or application data.
For additional details to please refer to the MSDN documentation at:<http://msdn.microsoft.com/en-us/library/windowsazure/jj672979.aspx>
To remove this warning run: sudo chattr -i /mnt/DATALOSS_WARNING_README.txt sudo rm /mnt/DATALOSS_WARNING_README.txt
This warning is written each boot; to disable it: echo "manual" | sudo tee /etc/init/ephemeral-disk-warning.override sudo systemctl disable ephemeral-disk-warning.serviceCreate a mount point.
kevin@cloud9:~$ sudo mkdir -p /dataMount the disk as a test.
kevin@cloud9:~$ sudo mount /dev/sdc1 /dataVerify everything is happy. You can see on the last line I have mounted sdc1 to /data
kevin@cloud9:~$ df -hFilesystem Size Used Avail Use% Mounted on/dev/root 29G 1.7G 27G 6% /tmpfs 1.9G 0 1.9G 0% /dev/shmtmpfs 773M 984K 772M 1% /runtmpfs 5.0M 0 5.0M 0% /run/lockefivarfs 128K 30K 94K 25% /sys/firmware/efi/efivars/dev/sda16 881M 59M 761M 8% /boot/dev/sda15 105M 6.1M 99M 6% /boot/efi/dev/sdb1 7.8G 32K 7.4G 1% /mnttmpfs 387M 12K 387M 1% /run/user/1000/dev/sdc1 124G 28K 123G 1% /dataAdd drive to fstab
Next, we will make it so the drive auto mounts at the system start.
Find UUID
sudo blkidkevin@cloud9:~$ sudo blkid/dev/sdb1: UUID="dac9f2b8-e652-4c0c-8a3a-e89e72f99aab" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="e964e9fa-01"/dev/sda16: LABEL="BOOT" UUID="a3459579-d08d-47d3-ba37-73b8f93832ea" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="db3c9060-8ad5-4d96-bce5-2ee8670b6b32"/dev/sda15: LABEL_FATBOOT="UEFI" LABEL="UEFI" UUID="3D29-CB2F" BLOCK_SIZE="512" TYPE="vfat" PARTUUID="985e5b58-e1f3-4182-be08-8c79f0cbf260"/dev/sda1: LABEL="cloudimg-rootfs" UUID="80e1e682-7307-4dc9-8dc4-a6af6afa284a" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="7766a12d-b53b-453f-a51f-d354e4fa13b1"/dev/sdc1: UUID="4ebca0b7-fb7e-45f8-8197-bf2b7a3e34f9" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="82181696-640c-450f-83b7-9d9be3cc2401"/dev/sda14: PARTUUID="e38bac6b-117c-4f40-b378-468801a61397"Edit fstab
sudo vi /etc/fstabAdd a line similar to the following, adjusting for your system.
UUID=4ebca0b7-fb7e-45f8-8197-bf2b7a3e34f9 /data ext4 rw,relatime 0 0kevin@cloud9:~$ sudo vi /etc/fstab# CLOUD_IMG: This file was created/modified by the Cloud Image build processUUID=80e1e682-7307-4dc9-8dc4-a6af6afa284a / ext4 discard,commit=30,errors=remount-ro 0 1LABEL=BOOT /boot ext4 defaults,discard 0 2UUID=3D29-CB2F /boot/efi vfat umask=0077 0 1UUID=4ebca0b7-fb7e-45f8-8197-bf2b7a3e34f9 /data ext4 rw,relatime 0 0/dev/disk/cloud/azure_resource-part1 /mnt auto defaults,nofail,x-systemd.requires=cloud-init.service,_netdev,comment=cloudconfig 0 2Unmount the drive so we can verify fstab is configured correctly.
sudo umount /dev/sdc1kevin@cloud9:~$ sudo umount /dev/sdc1kevin@cloud9:~$ df -hFilesystem Size Used Avail Use% Mounted on/dev/root 29G 1.7G 27G 6% /tmpfs 1.9G 0 1.9G 0% /dev/shmtmpfs 773M 984K 772M 1% /runtmpfs 5.0M 0 5.0M 0% /run/lockefivarfs 128K 30K 94K 25% /sys/firmware/efi/efivars/dev/sda16 881M 59M 761M 8% /boot/dev/sda15 105M 6.1M 99M 6% /boot/efi/dev/sdb1 7.8G 32K 7.4G 1% /mnttmpfs 387M 12K 387M 1% /run/user/1000Reload fstab and verify the drive mounted correctly.
sudo mount -avkevin@cloud9:~$ sudo mount -av/ : ignored/boot : already mounted/boot/efi : already mounted/data : successfully mounted/mnt : already mountedIf the system complains your fstab has been modified, run daemon-reload. daemon-reload will reload systemd files. You might need to run the mount command after the daemon-reload.
sudo systemctl daemon-reloadkevin@cloud9:~$ sudo systemctl daemon-reloadkevin@cloud9:~$ df -hFilesystem Size Used Avail Use% Mounted on/dev/root 61G 2.0G 60G 4% /tmpfs 3.9G 0 3.9G 0% /dev/shmtmpfs 1.6G 1012K 1.6G 1% /runtmpfs 5.0M 0 5.0M 0% /run/lockefivarfs 128K 35K 89K 29% /sys/firmware/efi/efivars/dev/sda16 881M 107M 713M 13% /boot/dev/sda15 105M 6.1M 99M 6% /boot/efi/dev/sdb1 16G 28K 15G 1% /mnttmpfs 789M 12K 789M 1% /run/user/1000/dev/sdc1 126G 24K 120G 1% /dataIf you see your drive loaded, you should reboot the system to ensure fstab is working correctly. Nothing like rebooting a server 3 months later and having it not come up for a reason you forgot about.
Errors
The following error is due to data in your fstab not being correct. This is why we test before we reboot.
kevin@cloud9:~$ sudo mount -avmount: /data: mount point does not exist. dmesg(1) may have more information after failed mount system call.Thanks for stopping by!
ack quote: “You can throw a horse in water, but that is not how you get it to drink, either.”
Sources / Linkage
This post is licensed under CC BY 4.0 by the author.
Related Posts
Windows Subsystem for Linux (WSL) Tips
WSL lets you install a Linux distribution (such as Ubuntu) to use Linux command-line tools directly on Windows. You get Linux with a real Linux kernel…
Manually Update VMWare ESXi
VMWare is in the news again. I feel the next 24 months will be rough for security teams across the board. Many have spent the last year or more in…