search
HomeOperation and MaintenanceLinux Operation and MaintenanceDemonstration 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:

  1. Disk partition

  2. Use partition to make pv

  3. Create vg with pv

  4. Split lv from vg

  5. 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

Let’s look at the command to make lv

  • lvcreate [-L N [m/g/t]] [-n lv name] vg name

  • lvcreate [-l N] [-n lv name] vg name

Option parameters:

  • -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            &#39;/dev/vgwww/lvwww&#39; [1.00 GiB] inherit
The following will demonstrate how to expand the lv by 1G , to expand the capacity, use the lvresize command. First, make sure that the remaining space of vg is greater than 1G, and then expand it

# 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

. At this point, the entire process is over, and the new file system has been created.

For more related technical articles, please visit the

linux system tutorial column!

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!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Linux Maintenance Mode: Understanding the PurposeLinux Maintenance Mode: Understanding the PurposeApr 28, 2025 am 12:01 AM

Maintenance mode is used for system maintenance and repair, allowing administrators to work in a simplified environment. 1. System Repair: Repair corrupt file system and boot loader. 2. Password reset: reset the root user password. 3. Package management: Install, update or delete software packages. By modifying the GRUB configuration or entering maintenance mode with specific keys, you can safely exit after performing maintenance tasks.

Linux Operations: Networking and Network ConfigurationLinux Operations: Networking and Network ConfigurationApr 27, 2025 am 12:09 AM

Linux network configuration can be completed through the following steps: 1. Configure the network interface, use the ip command to temporarily set or edit the configuration file persistence settings. 2. Set up a static IP, suitable for devices that require a fixed IP. 3. Manage the firewall and use the iptables or firewalld tools to control network traffic.

Maintenance Mode in Linux: A System Administrator's GuideMaintenance Mode in Linux: A System Administrator's GuideApr 26, 2025 am 12:20 AM

Maintenance mode plays a key role in Linux system management, helping to repair, upgrade and configuration changes. 1. Enter maintenance mode. You can select it through the GRUB menu or use the command "sudosystemctlisolaterscue.target". 2. In maintenance mode, you can perform file system repair and system update operations. 3. Advanced usage includes tasks such as resetting the root password. 4. Common errors such as not being able to enter maintenance mode or mount the file system, can be fixed by checking the GRUB configuration and using the fsck command.

Maintenance Mode in Linux: When and Why to Use ItMaintenance Mode in Linux: When and Why to Use ItApr 25, 2025 am 12:15 AM

The timing and reasons for using Linux maintenance mode: 1) When the system starts up, 2) When performing major system updates or upgrades, 3) When performing file system maintenance. Maintenance mode provides a safe and controlled environment, ensuring operational safety and efficiency, reducing impact on users, and enhancing system security.

Linux: Essential Commands and OperationsLinux: Essential Commands and OperationsApr 24, 2025 am 12:20 AM

Indispensable commands in Linux include: 1.ls: list directory contents; 2.cd: change working directory; 3.mkdir: create a new directory; 4.rm: delete file or directory; 5.cp: copy file or directory; 6.mv: move or rename file or directory. These commands help users manage files and systems efficiently by interacting with the kernel.

Linux Operations: Managing Files, Directories, and PermissionsLinux Operations: Managing Files, Directories, and PermissionsApr 23, 2025 am 12:19 AM

In Linux, file and directory management uses ls, cd, mkdir, rm, cp, mv commands, and permission management uses chmod, chown, and chgrp commands. 1. File and directory management commands such as ls-l list detailed information, mkdir-p recursively create directories. 2. Permission management commands such as chmod755file set file permissions, chownuserfile changes file owner, and chgrpgroupfile changes file group. These commands are based on file system structure and user and group systems, and operate and control through system calls and metadata.

What is Maintenance Mode in Linux? ExplainedWhat is Maintenance Mode in Linux? ExplainedApr 22, 2025 am 12:06 AM

MaintenanceModeinLinuxisaspecialbootenvironmentforcriticalsystemmaintenancetasks.Itallowsadministratorstoperformtaskslikeresettingpasswords,repairingfilesystems,andrecoveringfrombootfailuresinaminimalenvironment.ToenterMaintenanceMode,interrupttheboo

Linux: A Deep Dive into Its Fundamental PartsLinux: A Deep Dive into Its Fundamental PartsApr 21, 2025 am 12:03 AM

The core components of Linux include kernel, file system, shell, user and kernel space, device drivers, and performance optimization and best practices. 1) The kernel is the core of the system, managing hardware, memory and processes. 2) The file system organizes data and supports multiple types such as ext4, Btrfs and XFS. 3) Shell is the command center for users to interact with the system and supports scripting. 4) Separate user space from kernel space to ensure system stability. 5) The device driver connects the hardware to the operating system. 6) Performance optimization includes tuning system configuration and following best practices.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.