How to expand the default LVM space of Linux
1. Introduction to Linux LVM
Linux Logical Volume Manager (LVM) is a tool for managing disks and storage space, providing flexible storage management through volume groups and logical volumes. The core concepts of LVM include physical volumes, volume groups and logical volumes.
- Physical Volume (PV): A physical volume is a physical hard disk or partition, which is used by LVM to store data. LVM combines one or more physical volumes into volume groups.
- Volume Group (VG): A volume group is a logical storage unit composed of one or more physical volumes. Logical volumes are created on volume groups, and they can dynamically allocate and reclaim storage space. A system can contain multiple volume groups.
- Logical Volume (LV): A logical volume is a logical storage unit created on a volume group. They can be formatted as a file system and mounted on the file system tree like ordinary hard disk partitions. The size and location of logical volumes can be dynamically adjusted at runtime without shutting down or restarting the system.
The following is a visual diagram of the working principle of LVM. Assume there are 5 different disks, each with a partition mapped to a physical volume (PV), and these disks are combined into a volume group (VG), which is split into two different logical volumes (LV), Each LV is used for one file system.
picture
Assume that a disk with 100GB space is divided on the ubuntu system. According to the LVM principle, the division level is as follows:
2.Linux system installation program default settings
When installing the Ubuntu system, a screen prompt will appear requiring approval of the storage layout. By default, the storage layout will include several small boot partitions and a third partition that LVM will use to create the root file system.
picture
picture
3. Use the default available space
By default in Ubuntu, the root file system uses less than half of the total disk space. You can use the df -h command to check the free space of the root file system.
As shown in the figure, only about 14% of the 49GB storage space is currently used. In actual use, this part of the space may be filled up quickly. So now the task is to expand this 49GB volume.
To check the existing free space on the volume group (the space left by the installation program's default settings), you can run: vgdisplay command to check the available space, as shown in the figure:
As you can see from the picture above, there is approximately 49.25GB of space available. Of course, the available space here may not be enough, as will be discussed below.
To use the available space on the volume group (VG) of the root logical volume (LV), you can first run: lvdisplay command to check the logical volume size, and then run:
lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
Expand the LV to the maximum available size, and then run lvdisplay again to ensure that the change is successful, as shown in the figure:
At this time, the size of the block volume where the root file system is located has been increased, but the file system still needs to be expanded on top of it. Run df -h to check the root file system, and then run the command:
resize2fs /dev/mapper/ubuntu — vg-ubuntu — lv
Expand the file system, and run df -h again to confirm, as shown in the figure:
picture
You can see that the space left by the system by default has been allocated successfully. If the space is still not enough, you need to expand the basic disk to allocate more space.
4.Expand physical disk space
Assume that the expansion space plan is to expand the current 100GB to 200GB. In actual applications, the expanded space may be a virtual machine or a RAID controller or other storage system. First, execute the: cfdisk command to check and see whether the available space is listed. space, use q to exit after completion, as shown in the figure:
If you don’t see the available space listed, you can use:
echo 1>/sys/class/block/sda/device/rescan
Start the rescan of /dev/sda. After completion, re-run cfdisk. You should be able to see the new available space, as shown in the figure:
Select the /dev/sda3 partition from the list and select "Resize" from the bottom menu. Press the Enter key and it will prompt to confirm the new size. Press the Enter key again and you will see that the /dev/sda3 partition has the new space size.
Select "Write" from the bottom menu, enter yes to confirm, then press Enter, enter q to exit the program.
Now that the LVM partition of the /dev/sda3 physical volume (PV) has been extended, you need to extend the PV and run the command:
pvresize /dev/sda3
Perform this operation, and then use pvdisplay to check the new size, as shown in the figure:
picture
Now you can see that the PV has increased from 98.5GB to 198.5GB. Use vgdisplay again to check the available space of the volume group (VG), as shown in the figure:
picture
You can see that VG has 100GB of available space, continue to enter the command:
lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
Expand LV to use up all available space of VG, and then execute the lvdisplay command to ensure the change is successful, as shown in the figure:
picture
At this time, the block volume of the root file system has been expanded, but the file system itself has not yet been resized to adapt to the new volume. First, check the current size of the file system with df -h, and then run the command:
resize2fs /dev/mapper/ubuntu — vg-ubuntu — lv
Adjust the size, and run df -h again to check the available space of the new file system, as shown in the figure:
picture
You can see that the physical disk has been successfully expanded and the available space has been extended up to the LVM abstraction layer. The root file system already has enough space.
The above is the detailed content of How to expand the default LVM space of Linux. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

First download the latest Win11 system ISO image, and then in Win10 system, you can directly right-click on the downloaded ISO image file and select [Load]; if it is under WinPE, WinXP, or Win7 system, you need to use the virtual optical drive tool to load the ISO Image; or you can directly decompress the ISO image file without using a virtual optical drive. Then run WinNTSetup. The software interface is as shown in the figure: First locate the location of the install.wim file. You can find the install.wim file in the sources directory of the Win11 ISO image loaded or decompressed by the virtual optical drive. Then set the location of the boot disk and installation disk. Generally, you are going to put W

Tutorial on assembling a computer and installing a system? Nowadays, the system installation for assembling computers is very simple and convenient, and only requires a CD. First enter the bios settings, set the computer to boot first with the CD-ROM drive, then restart the computer and load the system CD into the CD-ROM drive. The CD will automatically enter the installation state. At this time, you only need to manually repartition the partitions, and the rest will be completed automatically. How to install win11 system when assembling a computer? 1. First, we need to download a win11 image file from this site before installing it. 2. The win11 image file has undergone a large number of professional tests to ensure stable installation and smooth operation. 3. After the download is completed, load the folder in the download path and run the "windowssetup" process in it.

How to enter bios after assembling a computer? Before entering the BIOS, you need to make sure that the computer is completely shut down and powered off. Here are several common ways to enter the BIOS: 1. Use shortcut keys: Most computer manufacturers will display a prompt message at startup telling you which key to press to enter the BIOS settings. Usually the F2, F10, F12 or Delete key. After pressing the appropriate keys, you should be able to see a screen with information about your computer's hardware and BIOS settings. 2. Use the button on the motherboard: Some computer motherboards have a dedicated button for entering BIOS settings. This button is usually labeled "BIOS" or "UEFI". After pressing the button you should be able to see

Baidu Netdisk download failed 125201 Error reason: Network problems: unstable/slow connection, router failure, busy server File problems: damaged/incomplete files, invalid links Baidu Netdisk restrictions: download limit exceeded, membership expiration/account restricted Browser/application issues: out-of-date version/poor compatibility, download manager failure System issues: viruses/malware, missing components/drivers

How to flash the Windows system on BBK tablet? The first way is to install the system on the hard disk. As long as the computer system does not crash, you can enter the system and download things, you can use the computer hard drive to install the system. The method is as follows: Depending on your computer configuration, you can install the WIN7 operating system. We choose to download Xiaobai's one-click reinstallation system in vivopad to install it. First, select the system version suitable for your computer, and click "Install this system" to next step. Then we wait patiently for the installation resources to be downloaded, and then wait for the environment to be deployed and restarted. The steps to install win11 on vivopad are: first use the software to check whether win11 can be installed. After passing the system detection, enter the system settings. Select the Update & Security option there. Click

3D drawing computer configuration and assembly recommendations? If used for 3D renderings, the laptop configuration requirements are as follows: 1. Operating system: Windows 7 (64-bit is recommended) 2. Memory: at least 2GB (4GB and above are recommended) 3. Graphics card: 1G of video memory and above, bit width 256bit or above, the video memory type is DDR3 or above, it is recommended to use NVIDIA brand graphics card (it is recommended to use professional graphics cards certified by solidworks: such as: NVIDIA Quadro series, ATI FireGL series or Firepro series) 4. CPU: Intel dual-core high frequency 64bit, it is recommended to use i5 series or i7 series, it is recommended that the CPU frequency is higher than 2.8GHz, in the center

1. First we need to download the win11 image file. 2. Put the downloaded win11 image into another disk. 3. Then we find the win11 image file among the searched image files. 4. Then when we come to this interface, we select install.wim to proceed to the next step. 5. Then select the Windows 11 system and click OK to restore the image file. 6. Then we wait for pe to download and install. Wait patiently. After the download is completed, click restart according to the prompts. 7. Then come to this interface, we select the second xiaobaiPE. After selecting, the win11 system will be automatically installed for us. After the installation is completed, click to restart the computer immediately according to the prompts. 8. Finally, the system installation is completed, and we come to

Reinstalling the system is a problem that many computer users often encounter. Whether it is due to system crash, poisoning or wanting to upgrade the system, reinstalling the system is a good choice. However, many people encounter various problems when reinstalling the system, such as not knowing how to set up the BIOS, not knowing how to choose a suitable installation disk, etc. Today, we will talk about some things you must know when reinstalling the system from a USB flash drive, and teach you how to set up the BIOS correctly and successfully complete the system reinstallation. Tool materials: System version: Windows1020H2 Brand model: Lenovo Xiaoxin Air14 Software version: Pocket machine One-click reinstallation of system software v1.0 1. Preparation 1. Prepare a U disk with a capacity of no less than 8GB, preferably USB3. 0, so the speed will be faster
