I have a Ubuntu VM which has an unmanaged OS disk associated with it.

When we increased the size of the unmanaged OS disk from 30 GB to 50 GB(after deallocating the VM and increasing its size from the platform), the changes are not reflected in the filesystem /dev/sda1 and it is continuing to show the size of the partition to be 30 GB.

The increased 20 GB is shown as a free space when I RDP my VM.

Could anyone please help me with increasing the size of /dev/sda1 filesystem to 50 GB?

Attached is the screenshot for the same. Current partition of OS disk

  • did you try sudo resize2fs /dev/sda1 ?
    Feb 7 '20 at 17:36

First you will have to enlarge the existing partition to use the full disk space. I don't know if you can do it with the GUI you show. From the command line you can use fdisk. ~This seems to be old-style MBR partitioning, so that should not be a problem~. No I was wrong about that, the simple disktool in the screenshot mistook a MBR compatible GPT partitioning for MBR partitioning.

To check if a disk uses GPT, you can use gdisk -l /dev/sda If it uses MBR it will warn: Found invalid GPT and valid MBR. If the disk uses GPT with MBR compatibility, it will say Found valid GPT with hybrid MBR; using GPT. Otherwise it is plain GPT with no MBR compatibility.

For partitioning GPT disks, you have to use gdisk. Also you have to use its expert mode and relocate backup tables to end of disk, otherwise you can't enlarge a partition.

This should be the starting partition table you had.

Number  Start (sector)    End (sector)  Size       Code  Name
   1          227328        62916574   29.9 GiB    8300  
  14            2048           10239   4.0 MiB     EF02  
  15           10240          227327   106.0 MiB   EF00

You can use gdisk then to edit number 1:

gdisk /dev/sda
e(x)pert mode>
e (relocate backup)
n(ew) start sector as original, set end to end of disk
w(rite) and exit

Maybe you have to reread the partition. Usually this will autoupdate. Otherwise echo 1 > /sys/block/sda/device/rescan. Executing lsblk should show the right sizes.

Secondly you have to expand the filesystem itself. You show here ext4, so this can be done online with resize2fs /dev/sda1

  • I followed the commands listed on the link lnx.azurewebsites.net/…. I am able to create a remove the existing filesystem and create a new one. But when i try to reboot the system i am not able to connect to it. Could you please help me with it? Here are the details of my existing system before deleting /dev/sda1: Device Start End Sectors Size Type /dev/sda1 227328 62916574 62689247 29.9G Linux filesystem /dev/sda14 2048 10239 8192 4M BIOS boot /dev/sda15 10240 227327 217088 106M EFI System Feb 12 '20 at 15:32
  • Can you attach a rescue cd iso to this machine? system-rescue-cd.org. The instructions on that site you mention doesn't really detail which partition to delete and reenter with larger size, maybe you deleted the wrong partition or partitions. The data can still be there. So, if you can boot from a rescue cd, then you can fix the partition table.
    – Gerrit
    Feb 12 '20 at 20:46
  • I really should have asked you for that partition table earlier. Even though the screenshot said partitioning "master boot record", the partition numbers indicate GPT partitioning. The tool you used was too old to recognize that. I looked around. This site mention exactly the partitioning you had. docs.hytrust.com/DataControl/4.3/Online/Content/Books/Azure/…
    – Gerrit
    Feb 12 '20 at 20:58

In order to repair the first attempt, if you can boot from a recovery ISO and see the disk as /dev/sda.

If you have sfdisk available, you can restore the original table in a Bash shell with

sfdisk /dev/sda << ENDOFTEXT
label: gpt
label-id: 040CDE21-820F-4D45-BAAD-55179836906D
device: /dev/sda
unit: sectors
first-lba: 34
last-lba: 62916574

/dev/sda1 : start=      227328, size=    62689247, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=EAA46D6B-3DF1-47A5-ADE4-7CDFCD3E6660, name="Linux filesystem"
/dev/sda14 : start=        2048, size=        8192, type=21686148-6449-6E6F-744E-656564454649, uuid=A5D04890-AA4D-479B-A053-B25AF2DE98FD, name="BIOS boot partition"
/dev/sda15 : start=       10240, size=      217088, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, uuid=16250F9E-6B15-480E-8376-EB9377658F0A, name="EFI System"

If you have only gdisk, the following sequence gives you the original table, after you start with gdisk /dev/sda


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.