


Demonstration of the production process of lvm software under linux
The previous article introduced lvm, and today I will demonstrate the process of making lvm. The production process of lvm has the following steps:
Disk partition
Use partition to make pv
Create vg with pv
Split lv from vg
Format lv and mount it to the directory using
Next, let’s complete the above process.
Partition
First, let’s take a look at the partitioning of the disk.
# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 40G 0 disk ├─sda1 8:1 0 2M 0 part ├─sda2 8:2 0 1G 0 part /boot ├─sda3 8:3 0 1G 0 part [SWAP] ├─sda4 8:4 0 10G 0 part / └─sda5 8:5 0 100M 0 part sdb 8:16 0 1G 0 disk sdc 8:32 0 1G 0 disk sdd 8:48 0 1G 0 disk sde 8:64 0 1G 0 disk
As you can see, there are 5 disks on my host. Except for the sda disk, the other disks have not been partitioned. In addition, the sda disk also has remaining space. Now, partition the other 4 disks as well. Use the fdisk or gdisk tool to partition, and the specific process is omitted here. After partitioning, the information is as follows:
# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 40G 0 disk ├─sda1 8:1 0 2M 0 part ├─sda2 8:2 0 1G 0 part /boot ├─sda3 8:3 0 1G 0 part [SWAP] ├─sda4 8:4 0 10G 0 part / └─sda5 8:5 0 100M 0 part sdb 8:16 0 1G 0 disk └─sdb1 8:17 0 1023M 0 part sdc 8:32 0 1G 0 disk └─sdc1 8:33 0 1023M 0 part sdd 8:48 0 1G 0 disk └─sdd1 8:49 0 1023M 0 part sde 8:64 0 1G 0 disk └─sde1 8:65 0 1023M 0 part
Making pv
First, we need to install the lvm2 software.
yum install lvm2
There are several related commands about pv:
pvscan View pv on the system
pvdisplay List pv Usage
pvcreate Make pv
pvremove Delete the pv, even if a partition does not have the pv attribute
Now we use partitions to make pv.
Usage: pvcreate partition...
# pvcreate /dev/sdb1 /dev/sdc1 Physical volume "/dev/sdb1" successfully created. Physical volume "/dev/sdc1" successfully created. # 这样就制作好了两个pv
The following uses pvscan to view all pvs on the system
# pvscan PV /dev/sdc1 lvm2 [1023.00 MiB] PV /dev/sdb1 lvm2 [1023.00 MiB] Total: 2 [<2.00 GiB] / in use: 0 [0 ] / in no VG: 2 [<2.00 GiB] # 共有2个pv,总大小2G左右,0个pv被使用
View the usage of a certain pv: pvdispaly [partition name]
# pvdisplay /dev/sdb1 "/dev/sdb1" is a new physical volume of "1023.00 MiB" --- NEW Physical volume --- PV Name /dev/sdb1 VG Name PV Size 1023.00 MiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID 6sl1Eg-S6BJ-1QYX-NAFs-9dIB-zEKN-jz7lYM
Then, we will delete these two PVs
# pvremove /dev/sd{b,c}1 Labels on physical volume "/dev/sdb1" successfully wiped. Labels on physical volume "/dev/sdc1" successfully wiped.
Finally, let’s make 3 PVs
# pvcreate /dev/sd{b,c,d}1 Physical volume "/dev/sdb1" successfully created. Physical volume "/dev/sdc1" successfully created. Physical volume "/dev/sdd1" successfully created.
Make vg
vg also has several related commands, as follows:
vgcreate makes vg. This command is the most complex of these commands.
vgscan Browse vg on the system
vgremove Delete a vg
vgdisplay View vg Usage
vgextend Expand vg, that is, add pv
vgreduce Remove pv from vg
First look at the command to make vg:
vgcreate [-s N[m|g|t]] vg name pv name
Options and parameters:
-s is followed by size, m, g, t can be in upper or lower case, and is used to set the pe size. If you omit this parameter, the default size will be used, which is generally 4M
vg name: Unlike the pv process, you need to customize the name of the vg here,
-
PV name, which PVs made vg.
Let’s make vg
# vgcreate vgwww /dev/sd{b,c,d}1 Volume group "vgwww" successfully created
Browse what vg has
# vgscan Reading volume groups from cache. Found volume group "vgwww" using metadata type lvm2
Check the relevant information of vg
# vgdisplay --- Volume group --- VG Name vgwww System ID Format lvm2 Metadata Areas 3 Metadata Sequence No 1 VG Access read/write VG Status resizable MAX LV 0 Cur LV 0 Open LV 0 Max PV 0 Cur PV 3 Act PV 3 VG Size <2.99 GiB PE Size 4.00 MiB Total PE 765 Alloc PE / Size 0 / 0 Free PE / Size 765 / <2.99 GiB VG UUID pd3HIi-NnES-DsdO-d35L-qoJB-OrwI-vkhfqV
Now we have vgwww Perform expansion operations
# vgextend vgwww /dev/sde1 Volume group "vgwww" successfully extended
Create lv
There are also some related commands for lv, as follows:
lvcreate: Make lv
lvscan: Query the lv on the system
lvdisplay: Display the status of lv
lvextend: Increase lv capacity
lvreduce: Reduce lv capacity
- ##lvremove: Delete a lv
- lvresize: Adjust the lv capacity size
- lvcreate [-L N [m/g/t]] [-n lv name] vg name
- lvcreate [-l N] [-n lv name] vg name
- -L followed by capacity, set the size of lv
- -l followed by how many PEs to use Quantity
- You don’t need to set the lv name, then the system will automatically set the lv name
# lvcreate -L 1G -n lvwww vgwww Logical volume "lvwww" created. # lvscan ACTIVE '/dev/vgwww/lvwww' [1.00 GiB] inherit
# vgdisplay vgwww --- Volume group --- VG Name vgwww System ID Format lvm2 Metadata Areas 4 Metadata Sequence No 5 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 0 Max PV 0 Cur PV 4 Act PV 4 VG Size 3.98 GiB PE Size 4.00 MiB Total PE 1020 Alloc PE / Size 256 / 1.00 GiB Free PE / Size 764 / 2.98 GiB <=== 还有剩余3G的空间 VG UUID pd3HIi-NnES-DsdO-d35L-qoJB-OrwI-vkhfqV # lvresize -L +1G /dev/vgwww/lvwww Size of logical volume vgwww/lvwww changed from 1.00 GiB (256 extents) to 2.00 GiB (512 extents). Logical volume vgwww/lvwww successfully resized.
Format and mount
/dev/vgwww/lvwww It is equivalent to a partition. If you want to use the partition, you need to format it first, and then mount it using# mkfs.xfs /dev/vgwww/lvwww # blkid …… /dev/mapper/vgwww-lvwww: UUID="fcbff612-a169-4542-ad92-6d53abe7b982" TYPE="xfs" # mount /dev/vgwww/lvwww /www [root@localhost ~]# df -h …… /dev/mapper/vgwww-lvwww 2.0G 33M 2.0G 2% /www
The above is the detailed content of Demonstration of the production process of lvm software under 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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

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

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

VS Code system requirements: Operating system: Windows 10 and above, macOS 10.12 and above, Linux distribution processor: minimum 1.6 GHz, recommended 2.0 GHz and above memory: minimum 512 MB, recommended 4 GB and above storage space: minimum 250 MB, recommended 1 GB and above other requirements: stable network connection, Xorg/Wayland (Linux)

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

vscode built-in terminal is a development tool that allows running commands and scripts within the editor to simplify the development process. How to use vscode terminal: Open the terminal with the shortcut key (Ctrl/Cmd). Enter a command or run the script. Use hotkeys (such as Ctrl L to clear the terminal). Change the working directory (such as the cd command). Advanced features include debug mode, automatic code snippet completion, and interactive command history.

To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.

Writing code in Visual Studio Code (VSCode) is simple and easy to use. Just install VSCode, create a project, select a language, create a file, write code, save and run it. The advantages of VSCode include cross-platform, free and open source, powerful features, rich extensions, and lightweight and fast.

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

Causes and solutions for the VS Code terminal commands not available: The necessary tools are not installed (Windows: WSL; macOS: Xcode command line tools) Path configuration is wrong (add executable files to PATH environment variables) Permission issues (run VS Code as administrator) Firewall or proxy restrictions (check settings, unrestrictions) Terminal settings are incorrect (enable use of external terminals) VS Code installation is corrupt (reinstall or update) Terminal configuration is incompatible (try different terminal types or commands) Specific environment variables are missing (set necessary environment variables)
