Windows OS Hub
  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
  • PowerShell
  • Linux
  • Home
  • About

Windows OS Hub

  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
  • PowerShell
  • Linux

 Windows OS Hub / Linux / How to Increase Size of Disk Partition in Ubuntu

March 11, 2024 Linux

How to Increase Size of Disk Partition in Ubuntu

If you have Ubuntu Linux virtual machines, it is highly likely that you will need to expand your virtual hard disk and increase the partition in the guest OS. By default, the Ubuntu installer offers to use logical volumes (LVMs) for the operating system, so we will study how to extend the LVM partition.


First, you need to increase the size of the virtual hard disk on your hypervisor.

Here is how you can increase virtual disk size in different hypervisors:

  • How to increase VMware virtual machine disk size
  • How to extend or shrink VM disks on Hyper-V
  • Extending KVM virtual machine disk size

Once you have increased the VM disk size, you must expand the Linux guest OS partition (Ubuntu 22.04 LTS in this example). Force a disk rescan, to make your Ubuntu see the added disk space:

$ echo 1>/sys/class/block/sda/device/rescan

Use the cfdisk to manage Ubuntu partitions:

$ sudo cfdisk

In this example, you can see that there is 1GB of free (unallocated) space on /dev/sda. Select the partition you want to extend (/dev/sda3) and select Resize from the menu.

Select Write from the menu to save the changes to the disk partition layout.

Extend disk partition in Ubuntu

Quit cfdisk.

Once you have increased the size of the physical partition, you will need to increase the size of the logical partition in Ubuntu. Check that you are using LVM volumes:

$ sudo lsblk

lsblk - check if LVM volumes are used on Ubuntu

Let’s review the key LVM’s concepts and terms:

  • Physical Volume (PV) – your physical disks (/dev/sda, /dev/sdb, etc.)
  • Volume Group (VG) – contains one or more physical volumes (disks). For example, ubuntu-vg = /dev/sda + /dev/sdb
  • Logical Volume (LV) – is a logical volume in a volume group. For example: ubuntu-vg/root, ubuntu-vg/home, etc.

Check the available free space in your LVM volume group:

$ sudo vgdisplay

In order to expand an LVM partition, you first need to increase the size of the PV (Physical Volume):

$ sudo pvresize /dev/sda3

Now you may extend the logical volume. In this case, we will resize the volume using all the free space available:

$ sudo lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv

Logical volume ubuntu-vg/ubuntu-lv successfully resized.

lvextend - increase logical volume size on ubuntu

Then you have to expand the file system. For ext2, ext3 and ext4, run the command below:

$ sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv

Check the available free space:

$ df -h

So we have successfully extended an LVM volume on Ubuntu.

If you are not using LVM volumes, you can use the parted utility to increase the size of partitions on Linux:

$ sudo parted
print free
resizepart n

Learn how to extend a hard disk partition on Windows.
0 comment
6
Facebook Twitter Google + Pinterest
previous post
How to Use Ansible to Manage Windows Machines
next post
How to Query and Change Teams User Presence Status with PowerShell

Related Reading

Send a WhatsApp Message from the CommandLine (Shell)

December 2, 2024

Graylog: Centralized Log Collection and Analysis

October 1, 2024

Get Started with Docker on Windows (WSL2) without...

September 4, 2024

Install Any OS from ISO Image over Network...

June 24, 2024

Printing from Linux to a Windows Shared Printer

May 29, 2024

Leave a Comment Cancel Reply

join us telegram channel https://t.me/woshub
Join WindowsHub Telegram channel to get the latest updates!

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMware
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • Cannot Install Network Adapter Drivers on Windows Server

    April 29, 2025
  • Change BIOS from Legacy to UEFI without Reinstalling Windows

    April 21, 2025
  • How to Prefer IPv4 over IPv6 in Windows Networks

    April 9, 2025
  • Load Drivers from WinPE or Recovery CMD

    March 26, 2025
  • How to Block Common (Weak) Passwords in Active Directory

    March 25, 2025
  • Fix: The referenced assembly could not be found error (0x80073701) on Windows

    March 17, 2025
  • Exclude a Specific User or Computer from Group Policy

    March 12, 2025
  • AD Domain Join: Computer Account Re-use Blocked

    March 11, 2025
  • How to Write Logs to the Windows Event Viewer from PowerShell/CMD

    March 3, 2025
  • How to Hide (Block) a Specific Windows Update

    February 25, 2025

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • Fixing ‘The Network Path Was Not Found’ 0x80070035 Error Code on Windows
  • Recovering Files from BitLocker Encrypted Drive
  • Installing an Open Source KMS Server (Vlmcsd) on Linux
  • How to Access VMFS Datastore from Linux, Windows, or ESXi
  • Install Any OS from ISO Image over Network with iVentoy
  • Using iPerf to Test Network Speed and Bandwidth
  • Moving WSL to Another Drive in Windows
Footer Logo

@2014 - 2024 - Windows OS Hub. All about operating systems for sysadmins


Back To Top