Azure – Linux OS Partition

Posted by robd on December 15, 2018
Server

Had an annoying issue where the OS disk on a linux server (hosted on Azure) was partitioned too small:

This disk is 30GB but has loads of free space::

Disk /dev/sda: 136.4 GB, 136365211648 bytes, 266338304 sectors

Then partition /dev/sda2 on the disk: 

Device Boot      Start         End      Blocks   Id  System

/dev/sda2         1026048    62914559    30944256   83  Linux

Feespace:

Number  Start   End     Size    Type     File system  Flags

        16.4kB  1049kB  1032kB           Free Space

1      1049kB  525MB   524MB   primary  xfs          boot

2      525MB   32.2GB  31.7GB  primary  btrfs

        32.2GB  136GB   104GB            Free Space

Here’s how I managed to grow the disk without loosing any data etc:

1) Login to the VM using SSH, we can check the size of the disk by using:

sudo dmesg | grep -i sda

2) To proceed with the partition resize, we will use:

sudo fdisk /dev/sda

type: p
this will show both partitions /dev/sda1 and /dev/sda2 which are basically partitions 1 and 2

type: d then 2 (to delete partition 2)
type: n then p2 (to recreate partition 2) you can accept the default values
type: w (to save the new partition)
type: q (to exit fdisk)
sudo reboot (to reboot the VM so the partition is updated)

3) To finalize the resize, after the reboot, execute the command:

For Red Hat 7.3 and CentOS 7.3:

sudo xfs_growfs /dev/sda2

For Oracle 7.3:

sudo btrfs filesystem resize max /

 

Tags: ,

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.