How to expand the ubuntu LVM partition of a VirtualBox virtual machine

I encountered an error message when I installed Cloud Foundry in ubuntu installed with VirtualBox, and the disk space is insufficient:

After cleaning up with these three commands, the result is still not ideal:

(1) sudo apt-get autoclean (installation package of uninstalled software)

(2) sudo apt-get clean (the installation package of the software is not uninstalled)

(3) Clean up orphaned packages that are no longer needed by the system. sudo apt-get autoremove

So I decided to adjust the size of the ubuntu virtual machine disk to 30G.

The current disk space can be viewed through the command line VBoxManage.exe list hdds.

Use the command VBoxManage.exe modifyhd -resize to change the size. After I changed to 30G,

I have seen the size take effect in VirtualBox.

The ubuntu command sudo fdisk -l can see that the new disk size has taken effect.

But the size of the file system viewed by df -H has not changed.

Use the command sudo fdisk /dev/sda, and then select n to create a new partition, the type is p, and the number is 3. Note here that the start position of the new partition should be close to the end position of the existing Linux LVM partition, as shown in the figure below. As for the end position, I simply specified it to increase by 15G, so the end position is calculated dynamically.

The following information shows that the partition has been successfully created.

Change the type of the newly created partition to 8e: Linux LVM

The next step is to create a new Physical volume: sudo pvcreate /dev/sda3

sudo pvscan shows that the physical volume has not been assigned to the volume group ubuntu-vg

Use the command sudo vgextend ubuntu-vg /dev/sda3 to allocate:

The allocation is complete.

Then modify the size of the volume group: sudo lvextend -l +100%FREE /dev/mapper/ubuntu--vg-root

last step:

sudo resize2fs /dev/mapper/ubuntu–vg-root

Now the size of / directory has been successfully expanded:

Recommended Posts

How to expand the ubuntu LVM partition of a VirtualBox virtual machine
How to extend the root directory of LVM under Ubuntu system
How to make the ubuntu virtual machine in vmware display in full screen
Solution to the virtual machine ubuntu16.04 cannot connect to the Internet
How to create a CentOS virtual machine in VMware
How to turn the language of Ubuntu into Chinese? ?
How to create a CentOS virtual machine in VMware
How to create a Python virtual environment in Ubuntu 14.04
Virtual machine VirtualBox-5.1 install ubuntu16.0.1
How to find the area of a circle in python
Xshell and Xftp fail to connect to the virtual machine Ubuntu
Encountered in the process of building a virtual environment in ubuntu
How to install VirtualBox on Ubuntu 20.04
How to fix the problem of missing system settings on Ubuntu 14.04
How to add swap partition in Ubuntu
Install Ubuntu 18.04 in the virtual machine VMware
How to modify the hostname on Ubuntu 20.04
Solution to the problem that ubuntu cannot connect to the Internet in the virtual machine
Expand the disk size of Ubuntu under VMware
How to open the ubuntu system in win10
The road to reinstallation of ubuntu 18.04 from scratch
Explain how to add swap partition on Ubuntu 16.04
Introduction to the use of Hanlp in ubuntu
How to run the parsing server on Ubuntu 14.04
Analysis on the method of CentOS8 virtual machine to access Windows10 host folder
How to check the installed JDK on Ubuntu
How to install the latest MySQL on Ubuntu 18.04
How to use LVM to manage storage devices on Ubuntu 18.04
How to set up a DNS server on Ubuntu 18.04
The same solution for cloning ubuntu18 virtual machine ip
How to add the gzip module to Nginx on Ubuntu 14.04
How does python call the key of a dictionary
How to start a blog with Hexo on Ubuntu 14.04
Example of how to replace domestic sources on Ubuntu 18.04
How to configure a fixed IP based on Ubuntu 18.04
How to understand the introduction of packages in Python
How to use Putty to log in to ubuntu installed in VirtualBox
How to understand a list of numbers in python
How to install two versions of OpenCV under ubuntu?
Example of how to modify ip address in Ubuntu20.04
Solution to the slow speed of ubuntu18.04 wireless network
How to repair a damaged Ubuntu system without reinstalling
How to set a fixed IP based on Ubuntu 16.04
How to upgrade to Ubuntu 20.04
How to upgrade to Ubuntu 20.04
How to control the ubuntu system in win10 through ssh
How to create LVM for XFS file system under Ubuntu
How to install Centos operating system on VMware virtual machine
How to set up a Masterless Puppet environment on Ubuntu 14.04
Teach you how to build a Git server on Ubuntu
How to set or modify the time zone on Ubuntu 20.04
How to set up a firewall with UFW on Ubuntu 14.04
Ubuntu adds the Chrome icon to the correct posture of the launcher
How to set or modify the time zone on Ubuntu 20.04
How to set up a production Elasticsearch cluster on Ubuntu 14.04
How to set up an Apache virtual host on Ubuntu 16.04
How to set up an Apache virtual host on Ubuntu 20.04
How to install Dropbox Client as a service on Ubuntu 14.04
How to create a Sudo user on Ubuntu [Quick Start]
Linux overview of Python automated operation and maintenance and the ultimate guide to virtual machine installation and use
Ubuntu14.04 creates Genymotion virtual machine