Resizing an Azure disk on an Ubuntu VM

David M 236 Reputation points
2025-01-22T09:52:43.06+00:00

Good morning,

I have an Ubuntu VM on Azure with a disk attached.

It was 128 GB, I mounted a /datadrive partition and added to the fstab following this procedure:

Everything is OK. This is the point /dev/sdc1
I wanted to increase the size of this disk to 256GB

  1. I did this in Azure: Ok
    1. In SSH, I used several tools to resize and check:
    2. sudo gdisk /dev/sdc
    3. parted
    4. sudo cfdisk /dev/sdc
    5. resize2fs /dev/sdc1
  2. Each of them tells me that it is good and the “lsblk” tells me that my disk is 256 GB But the “df -h” tells me that my /datadrive directory is still 100% full and that it is only 128 GB Everything seems correct to me in “sudo cat /etc/fstab“ and other “sudo blkid“, I don’t

How do I adapt the size of my directory mounted to 100% of the disk?

df -h

  • Filesystem Size Used Avail Use% Mounted on
  • /dev/root 62G 15G 48G 23% /
  • tmpfs 7.9G 0 7.9G 0% /dev/shm
  • tmpfs 3.2G 1.2M 3.2G 1% /run
  • tmpfs 5.0M 0 5.0M 0% /run/lock
  • /dev/sda15 105M 6.1M 99M 6% /boot/efi
  • /dev/sdc1 128G 128G 184K 100% /datadrive
  • /dev/sdb1 32G 28K 30G 1% /mnt
  • tmpfs 1.6G 4.0K 1.6G 1% /run/user/1000

lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS

loop0 7:0 0 138.9M 1 loop /snap/azcli/8

...

loop9 7:9 0 44.3M 1 loop /snap/snapd/23258

sda 8:0 0 64G 0 disk

├─sda1 8:1 0 63.9G 0 part /

├─sda14 8:14 0 4M 0 part

└─sda15 8:15 0 106M 0 part /boot/efi

sdb 8:16 0 32G 0 disk

└─sdb1 8:17 0 32G 0 part /mnt

sdc 8:32 0 256G 0 disk

└─sdc1 8:33 0 256G 0 part /datadrive

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
Azure Disk Storage
Azure Disk Storage
A high-performance, durable block storage designed to be used with Azure Virtual Machines and Azure VMware Solution.
{count} votes

Answer accepted by question author
  1. Sudheer Reddy 2,075 Reputation points Moderator
    2025-01-24T15:47:10.6233333+00:00

    Hi David M ,

    We have noticed that you rated an answer as not helpful. We appreciate your feedback and are committed to improving your experience with the Q&A. I have worked on finding an alternative solution to address your issue.

    • First verify by executing these commands; df -h and lsblk
    • Afterwards execute below command to manage partition sudo fdisk /dev/sdc and after this you will get a pop up then enter "p" , afterwards enter "d" , then later enter "n" and default partition(1) and press "enter" two times and finally enter "w". Now the partitions has been altered. User's image
    • Now verify using "lsblk" command.
    • Now, execute df -h , it still shows /dev/sdc1 as 128G. So, first we need to check the file system of /dev/sdc1 by using a command "df -hT" as a result it shows as xfs file system. User's image
    • Now, to resize the xfs file system, you need to execute below command sudo xfs_growfs /dev/sdc1
    • Finally, the /dev/sdc1 is resized to 256G. You can verify by executing "df -h" and "lsblk" commands. User's image

    If the information is helpful, please click on "Upvote".

    If you have any further queries, please let us know.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. David M 236 Reputation points
    2025-01-24T16:46:00.41+00:00

    I found

    sudo xfs_growfs /dev/sdc1

    work for me.

    Thanks

    1 person found this answer helpful.

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.