Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu

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

October 5, 2023 LinuxUbuntu

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
1
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

How to Use Ansible to Manage Windows Machines

September 25, 2023

Fixing ‘The Network Path Was Not Found’ 0x80070035...

August 30, 2023

How to Install and Configure Ansible on Linux

August 27, 2023

Monitoring Domain Name Expiration Date with Zabbix

August 14, 2023

Configure Remote SSH Connections in Visual Studio Code

July 12, 2023

Leave a Comment Cancel Reply

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

  • Zabbix: How to Get Data from PowerShell Scripts

    October 27, 2023
  • Tracking Printer Usage with Windows Event Viewer Logs

    October 19, 2023
  • PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

    October 15, 2023
  • Reset Root Password in VMware ESXi

    October 12, 2023
  • How to Query and Change Teams User Presence Status with PowerShell

    October 8, 2023
  • How to Increase Size of Disk Partition in Ubuntu

    October 5, 2023
  • How to Use Ansible to Manage Windows Machines

    September 25, 2023
  • Installing Language Pack in Windows 10/11 with PowerShell

    September 15, 2023
  • Configure Email Forwarding for Mailbox on Exchange Server/Microsoft 365

    September 14, 2023
  • How to View and Change BIOS (UEFI) Settings with PowerShell

    September 13, 2023

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
  • How to Access VMFS Datastore from Linux, Windows, or ESXi
  • Using iPerf to Test Network Speed and Bandwidth
  • Installing an Open Source KMS Server (Vlmcsd) on Linux
  • How to Enable Two-Factor Authentication (2FA) for SSH on Linux
  • How to Use Ansible to Manage Windows Machines
Footer Logo

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


Back To Top