Resizable disk partition inside Linux VM

Posted on

Resizable disk partition inside Linux VM – A server stack is the collection of software that forms the operational infrastructure on a given machine. In a computing context, a stack is an ordered pile. A server stack is one type of solution stack — an ordered selection of software that makes it possible to complete a particular task. Like in this post about Resizable disk partition inside Linux VM was one problem in server stack that need for a solution. Below are some tips in manage your linux server when you find problem about linux, ubuntu, hyper-v, , .

I’m trying to increase the size of the disk inside my virtual machine Ubuntu.
I used the following sequence of commands:

echo 1 > /sys/block/sda/device/rescan
fdisk /dev/sda
Command (m for help): d
Partition number (1,2, default 2): 2
Command (m for help): n
Select (default p): p

Now I see the following:

root@proj:~# parted
GNU Parted 3.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Model: Msft Virtual Disk (scsi)
Disk /dev/sda: 85,9GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name  Flags
 1      1049kB  2097kB  1049kB                     bios_grub
 2      2097kB  85,9GB  85,9GB  ext4



root@proj:~# fdisk /dev/sda

Welcome to fdisk (util-linux 2.31.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): p
Disk /dev/sda: 80 GiB, 85899345920 bytes, 167772160 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 615AE39E-D8BF-41FC-823C-99CDF4CBAEDF

Device     Start       End   Sectors Size Type
/dev/sda1   2048      4095      2048   1M BIOS boot
/dev/sda2   4096 167772126 167768031  80G Linux filesystem

Command (m for help):

I use Webmin to manage my server, and after rebooting it continues to say that:

Mounted As     Type     Free            Total       Device ID
 /              ext4    41% (15.70 GB)  38.37 GB    UUID=1f76306d-c5e9-45d8-ae14-923bb1114c16

Local disk space 22.67 GB used / 15.70 GB free / 38.37 GB total

I am new to these issues, help me understand, please, what is my mistake?

Making the partition larger is a necessary, but not sufficient, step in making the space available to the operating system. You also need to modify the metadata in the filesystem, which is the algorithm by which the raw space in the partition is made available to store files, directories, permissions, and so on.

Given the details provided, the most likely command you need to run is

resize2fs /dev/sda2

Leave a Reply

Your email address will not be published. Required fields are marked *