1024programmer Linux Demonstration of the production process of lvm software under linux-linux operation and maintenance

Demonstration of the production process of lvm software under linux-linux operation and maintenance

The previous article introduced lvm, and today I will demonstrate the process of making lvm here. The production process of lvm has the following steps:

  1. Disk partition

  2. Use partitions to make pv

  3. Create vg with pv

  4. Split lv from vg

  5. Format lv and mount it to the directory for use

Next, let’s complete the above process.

Partition

First, let’s look at the partition 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 yet, and the sda ​​disk still has remaining space. Now, partition the other 4 disks as well. Use fdisk or gdisk tools for partitioning, and the specific process is omitted here. The information after partitioning 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 the pv on the system

  • pvdisplay lists the usage of pv

  • pvcreate makes pv

  • pvremove deletes the pv, even if a partition has no pv attribute

Now we come 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.
 # In this way, two pvs have been made

Let’s check all pvs on the system through pvscan

# 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]
 # There are 2 pvs in total, the total size is about 2G, and 0 pvs are used

Check 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 pv

# 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 Create vg, this command is the most complicated among these commands.

  • vgscan browse vg on the system

  • vgremove delete a vg

  • vgdisplay to view the usage of vg

  • vgextend expands vg, that is, increases pv

  • vgreduce removes 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 followed by size, m, g, t can be upper or lower case, use to set the pe size. If this parameter is omitted, the default size will be used, generally 4M >

  • pv name, which pvs make 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 vg related information

# 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 will expand vgwww

# vgextend vgwww  /dev/sde1
   Volume group "vgwww" successfully extended

making lv

There is also about lv Some related commands are as follows:

  • lvcreate: make lv

  • lvscan: query 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 size of the lv capacity

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 parameter:

  • -L followed by capacity , set the size of lv

  • -l followed by the number of pes used

  • you can not 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

Next, we will demonstrate how to expand the capacity of lv by 1G, and use the lvresize command for capacity expansion. 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 <=== There is still 3G space left
   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, mount

This /dev/vgwww/lvwww is equivalent to a partition. If you want to use this partition, you need to format it first, and then mount it for use

# 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 whole 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 the demonstration of the lvm software production process under linux. For more information, please pay attention to other related articles on 1024programmer.com!

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/demonstration-of-the-production-process-of-lvm-software-under-linux-linux-operation-and-maintenance/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索