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
1
| lsblk -o NAME,HCTL,SIZE,MOUNTPOINT | grep -i "sd"
|
Examples… sdc is my target.
1
2
3
4
5
6
7
8
9
10
| 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 /boot
sdb 0:0:0:1 16G
└─sdb1 16G /mnt
sdc 1:0:0:0 128G
|
Options
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| 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): g
Created a new GPT disklabel (GUID: 8379B0DB-990C-452E-8764-46DDC2593BEE).
Command (m for help): n
Partition 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): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
|
1
| sudo mkfs.ext4 -F /dev/sdc1
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| kevin@cloud9:~$ sudo mkfs.ext4 -F /dev/sdc1
mke2fs 1.47.0 (5-Feb-2023)
Discarding device blocks: done
Creating filesystem with 67108352 4k blocks and 16777216 inodes
Filesystem UUID: 4ebca0b7-fb7e-45f8-8197-bf2b7a3e34f9
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
Allocating group tables: done
Writing inode tables: done
Creating journal (262144 blocks):
done
Writing superblocks and filesystem accounting information: done
|
Mount drives
1
| sudo mount /dev/sdc1 /data
|
Mount 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.
Warning:
Do not use /mnt for your mount point. This is a temp disk in Azure and will be erased.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| kevin@cloud9:~$ cat /mnt/
DATALOSS_WARNING_README.txt data/ lost+found/
kevin@cloud9:~$ cat /mnt/DATALOSS_WARNING_README.txt
WARNING: THIS IS A TEMPORARY DISK.
Any data stored on this drive is SUBJECT TO LOSS and THERE IS NO WAY TO
RECOVER 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.service
|
Create a mount point.
1
| kevin@cloud9:~$ sudo mkdir -p /data
|
Mount the disk as a test.
1
| kevin@cloud9:~$ sudo mount /dev/sdc1 /data
|
Verify everything is happy. You can see on the last line I have mounted sdc1 to /data
1
2
3
4
5
6
7
8
9
10
11
12
13
| kevin@cloud9:~$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 29G 1.7G 27G 6% /
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 773M 984K 772M 1% /run
tmpfs 5.0M 0 5.0M 0% /run/lock
efivarfs 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% /mnt
tmpfs 387M 12K 387M 1% /run/user/1000
/dev/sdc1 124G 28K 123G 1% /data
|
Add drive to fstab
Next, we will make it so the drive auto mounts at the system start.
Find UUID
1
2
3
4
5
6
7
| kevin@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
Add a line similar to the following, adjusting for your system.
1
2
| UUID=4ebca0b7-fb7e-45f8-8197-bf2b7a3e34f9 /data ext4 rw,relatime 0 0
|
1
2
3
4
5
6
7
8
| kevin@cloud9:~$ sudo vi /etc/fstab
# CLOUD_IMG: This file was created/modified by the Cloud Image build process
UUID=80e1e682-7307-4dc9-8dc4-a6af6afa284a / ext4 discard,commit=30,errors=remount-ro 0 1
LABEL=BOOT /boot ext4 defaults,discard 0 2
UUID=3D29-CB2F /boot/efi vfat umask=0077 0 1
UUID=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 2
|
Unmount the drive so we can verify fstab is configured correctly.
1
2
3
4
5
6
7
8
9
10
11
12
| kevin@cloud9:~$ sudo umount /dev/sdc1
kevin@cloud9:~$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 29G 1.7G 27G 6% /
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 773M 984K 772M 1% /run
tmpfs 5.0M 0 5.0M 0% /run/lock
efivarfs 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% /mnt
tmpfs 387M 12K 387M 1% /run/user/1000
|
Reload fstab and verify the drive mounted correctly.
1
2
3
4
5
6
| kevin@cloud9:~$ sudo mount -av
/ : ignored
/boot : already mounted
/boot/efi : already mounted
/data : successfully mounted
/mnt : already mounted
|
If 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.
1
| sudo systemctl daemon-reload
|
1
2
3
4
5
6
7
8
9
10
11
12
13
| kevin@cloud9:~$ sudo systemctl daemon-reload
kevin@cloud9:~$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 61G 2.0G 60G 4% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 1.6G 1012K 1.6G 1% /run
tmpfs 5.0M 0 5.0M 0% /run/lock
efivarfs 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% /mnt
tmpfs 789M 12K 789M 1% /run/user/1000
/dev/sdc1 126G 24K 120G 1% /data
|
If 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.
1
2
3
| kevin@cloud9:~$ sudo mount -av
mount: /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
-
[Attach a data disk to a Linux VM - Azure Virtual Machines |
Microsoft Learn](https://learn.microsoft.com/en-us/azure/virtual-machines/linux/attach-disk-portal?tabs=ubuntu){:target=”_blank”} |
Comments powered by Disqus.