I. Concept and Origin
LVM: Logical Volume Manager
Ordinary disk partition management can not change its size after logical partition is well divided. When a logical partition can not store a file, the file can not be stored across multiple partitions because of the limitation of the upper file system, so it can not be placed on multiple disks.
When a partition space is exhausted, the solution is usually to use symbolic links or tools to adjust the partition size (tools may cause our system to crash), but this has not fundamentally solved the problem.
With the emergence of LVM, the problem is solved. Users can easily adjust the size of partitions without downtime.
II. Working Principle
LVM works by abstractly encapsulating the underlying physical hard disk, and then presenting it to the upper application in the form of logical volumes.
In the traditional disk management mechanism, the upper application accesses the file system directly to read and write the underlying physical hard disk. In LVM, it encapsulates the underlying hard disk. When we operate the underlying physical disk through software, it no longer operates directly on partitions, but on the underlying physical hard disk through logical volumes.
The greatest feature of LVM is that it can dynamically manage disks, because the size of logical volumes can be dynamically adjusted, and data will not be lost. Logical volume technology greatly improves the logic of disk management.
3. Noun Interpretation
The physical media: This refers to the storage device of the system: hard disk, such as: / dev/hda, / dev/sda, etc., is the storage unit of the lowest layer of the storage system.
Physical Volume: Physical Volume refers to a hard disk partition or a device (such as RAID) that logically has the same function as a disk partition. It is the basic storage logic block of LVM, but compared with the basic physical storage media (such as partition, disk, etc.), it contains management parameters related to LVM.
Volume Group: A LVM volume group is similar to a physical hard disk in a non-LVM system and consists of physical volumes. You can create one or more LVM partitions (logical volumes) on a volume group, which consists of one or more physical volumes.
Logical Volume: Logical Volume of LVM is similar to hard disk partitioning in non-LVM systems, on which file systems (such as / home or / usr, etc.) can be built.
PE (Physical Extent): Each physical volume is divided into basic units called PE(Physical Extents). PE with a unique number is the smallest unit that can be addressed by LVM. The size of PE is configurable and defaults to 4MB.
LE (Logical Extent): Logical volumes are also divided into addressable basic units called LE(Logical Extents). In the same volume group, LE size and PE are the same and one to one.
IV. LVM Creates Logical Concepts
We use LVM to dynamically manage the disks, so that the hard disks are presented to the upper services in the form of logical volumes. So the purpose of our operation is to create LV, replace our previous partition with LV, we format the logical volume, and then mount it to use. The steps are as follows:
- After formatting the created LV file system and mounting it with mount, we can use logical volumes as usual as partitions.
- The working principle of LVM is summarized.
(a) Physical disks are formatted into PV s, and space is divided into PE's.
(b) Adding different PVs to the same VG, and putting all the PE of different PVs into the PE pool of the VG
LV is created based on PE, which is several times the size of PE. The PE that makes up LV may come from different disks.
(d) LV can be mounted after formatting the file system.
(e) Extension and reduction of LV is actually to increase or decrease the number of PE, and the process will not lose data.
So, if we want to expand LV, we first add a disk, then format it into PV, add the PV to VG, and then we can take out the free PE from VG to expand LV.
V. Order parsing
(a) PV management
pvcreate Create PV
pvscan Scan and list all PV s
pvdisplay Lists PV attribute information
pvremove Remove PV
Data in pvmove Mobile PV
(b) VG management
vgcreate Create VG
- s # Specifies the size of the PE ___________
- l) Maximum number of logical volumes allowed to be created on # volume groups
- p) Maximum number of physical volumes allowed to be added in volume groups
Scanning and listing all VG s
List VG attribute information in vgdisplay
vgremove Remove VG
vgreduce Remove PV from VG
vgextend # Add PV to VG
vgchange # Sets whether the VG is active
(c) LV management
lvcreate Create LV
- L + size # Specify LV size
- n # Specify the LV name
Example: vg0-lv1 will be created in lvcreate-L 5G-n LV vg0 and/dev/mapper
lvscan Scan and list all LV s
lvdisplay # lists LV attribute information
lvremove Remove lv
lvreduce(lvresize) Reduce lv capacity
lvextend(lvresize) Increase lv capacity
lvresize Cover lv Capacity
6. Creating Logical Volumes
1. Format the physical disk into PV using the pvcreate command, and use the pvcreate command.
Virtual two 2G physical hard disks, which can be viewed by fdisk-l command
(b) First format / dev/sdb, / dev/sdc as PV
(c) Use pvs to view simple information and pvdisplay to view detailed information
[root@centos7 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda3 98G 1.7G 97G 2% / devtmpfs 901M 0 901M 0% /dev tmpfs 911M 0 911M 0% /dev/shm tmpfs 911M 9.5M 902M 2% /run tmpfs 911M 0 911M 0% /sys/fs/cgroup /dev/sda1 1014M 135M 880M 14% /boot tmpfs 183M 0 183M 0% /run/user/0 [root@centos7 ~]# fdisk -l Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x000c1b7a Device Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 4196351 1048576 82 Linux swap / Solaris /dev/sda3 4196352 209715199 102759424 83 Linux Disk /dev/sdb: 2147 MB, 2147483648 bytes, 4194304 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/sdc: 2147 MB, 2147483648 bytes, 4194304 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes [root@centos7 ~]# yum install lvm2 -y # Install lvm2 software [root@centos7 ~]# rpm -qa|grep lvm # Filter lvm packet group lvm2-2.02.180-10.el7_6.3.x86_64 lvm2-libs-2.02.180-10.el7_6.3.x86_64 [root@centos7 ~]# pvcreate /dev/sdb /dev/sdc # Format the newly added two disks into PV Physical volume "/dev/sdb" successfully created. Physical volume "/dev/sdc" successfully created. [root@centos7 ~]# pvs # View PV Simple Information PV VG Fmt Attr PSize PFree /dev/sdb lvm2 --- 2.00g 2.00g /dev/sdc lvm2 --- 2.00g 2.00g [root@centos7 ~]# pvdisplay # Display PV status on current system"/dev/sdb" is a new physical volume of "2.00 GiB"--- NEW Physical volume --- PV Name /dev/sdb VG Name PV Size 2.00 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID dhEvh2-mOsu-Tyas-6wb8-6gfD-EpT7-0lb1ff "/dev/sdc" is a new physical volume of "2.00 GiB" --- NEW Physical volume --- PV Name /dev/sdc VG Name PV Size 2.00 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID bLrH3d-Ry0I-durj-3apN-q4kF-m0uy-DG8f5q
2. Create volume group VG and add PV to VG through vgcreate command
[root@centos7 ~]# vgcreate pool /dev/sdb /dev/sdc # Create VG pool Volume group "pool" successfully created [root@centos7 ~]# vgs # View simple information VG #PV #LV #SN Attr VSize VFree pool 2 0 0 wz--n- 3.99g 3.99g #The 3.99G shown here is the VG capacity of two disks formatted into PE. [root@centos7 ~]# vgdisplay # View Details --- Volume group --- VG Name pool System ID Format lvm2 Metadata Areas 2 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 2 Act PV 2 VG Size 3.99 GiB PE Size 4.00 MiB Total PE 1022 Alloc PE / Size 0 / 0 Free PE / Size 1022 / 3.99 GiB VG UUID e55Yks-0Phr-VarP-xAF8-8W4B-vBFg-VWqPm3
3. Create LV based on VG through lvcreate command
[root@centos7 ~]# lvcreate -n xiaoliziLV -L 2G pool # Create LV logical volume name xiaoliziLV size 2G Logical volume "xiaoliziLV" created. [root@centos7 ~]# lvs # Simple display of LV information LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert xiaoliziLV pool -wi-a----- 2.00g [root@centos7 ~]# lvdisplay # Detailed display of LV information --- Logical volume --- LV Path /dev/pool/xiaoliziLV LV Name xiaoliziLV VG Name pool LV UUID xhCdbm-JZvA-MIMW-4p0K-0V4O-Gl60-9X4mNr LV Write Access read/write LV Creation host, time centos7, 2019-04-19 17:40:39 +0800 LV Status available # open 0 LV Size 2.00 GiB Current LE 512 Segments 2 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:0[root@centos7 ~]# ls /dev/mapper/
control pool-xiaoliziLV
[root@centos7 ~]# mkfs.xfs /dev/mapper/pool-xiaoliziLV # Format file system
meta-data=/dev/mapper/pool-xiaoliziLV isize=512 agcount=4, agsize=131072 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=524288, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@centos7 ~]# mkdir /lvtest # Create mount points
[root@centos7 ~]# mount /dev/mapper/pool-xiaoliziLV /lvtest/
[root@centos7 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 98G 1.6G 97G 2% /
devtmpfs 901M 0 901M 0% /dev
tmpfs 911M 0 911M 0% /dev/shm
tmpfs 911M 9.6M 902M 2% /run
tmpfs 911M 0 911M 0% /sys/fs/cgroup
/dev/sda1 1014M 135M 880M 14% /boot
tmpfs 183M 0 183M 0% /run/user/0
/dev/mapper/pool-xiaoliziLV 2.0G 33M 2.0G 2% /lvtest
7. Expanding a Logical Volume
In the traditional hard disk management mode, if one partition size is not enough (when the hard disk still has space), we need to expand, then we can only transfer all the information of this partition to other places, re-partition after uninstalling, and finally upload the new partition.
If in the production environment, such operation is unimaginable, time-consuming and laborious. The use of LVM is much more convenient, as shown in the figure:
As can be seen from the figure above, the so-called expansion is to increase the number of PE in LV, the increase depends on the number of PE in your VG.
[Note] Logical volume expansion can be done online without uninstalling the logical volume. This kind of management is very necessary for companies that provide services to the outside world in 7*24 hours.
In the first case, there is enough space left in the VG (1.99G free can be seen), which increases the capacity of the LV by 1G. The steps are as follows:
[root@centos7 ~]# vgdisplay --- Volume group --- VG Name pool System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 2 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 1 Max PV 0 Cur PV 2 Act PV 2 VG Size 3.99 GiB PE Size 4.00 MiB Total PE 1022 Alloc PE / Size 512 / 2.00 GiB Free PE / Size 510 / 1.99 GiB VG UUID e55Yks-0Phr-VarP-xAF8-8W4B-vBFg-VWqPm3 [root@centos7 ~]# lvextend -L +1G /dev/pool/xiaoliziLV # Expanded Logic Volume 1 G,Use lvextend commandSize of logical volume pool/xiaoliziLV changed from 2.00 GiB (512 extents) to 3.00 GiB (768 extents). Logical volume pool/xiaoliziLV successfully resized. [root@centos7 ~]# lvdisplay # View Logical Volume Information (Discovery) LV It's 3. G )--- Logical volume --- LV Path /dev/pool/xiaoliziLV LV Name xiaoliziLV VG Name pool LV UUID xhCdbm-JZvA-MIMW-4p0K-0V4O-Gl60-9X4mNr LV Write Access read/write LV Creation host, time centos7, 2019-04-19 17:40:39 +0800 LV Status available # open 1 LV Size 3.00 GiB Current LE 768 Segments 2 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:0
[root@centos7 ~]# df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/sda3 xfs 98G 1.6G 97G 2% / devtmpfs devtmpfs 901M 0 901M 0% /dev tmpfs tmpfs 911M 0 911M 0% /dev/shm tmpfs tmpfs 911M 9.6M 902M 2% /run tmpfs tmpfs 911M 0 911M 0% /sys/fs/cgroup /dev/sda1 xfs 1014M 135M 880M 14% /boot tmpfs tmpfs 183M 0 183M 0% /run/user/0 /dev/mapper/pool-xiaoliziLV xfs 2.0G 33M 2.0G 2% /lvtest
# As we can see above, it's just LV The size of the real file system remains unchanged. That's because we're creating it. LV After that, it will be formatted into a file system immediately. After that, the modification of the logical volume will not directly affect the file system. An updated command will be used at this time. resize2fs/xfs_growfs[root@centos7 ~]# resize2fs /dev/mapper/pool-xiaoliziLV
resize2fs 1.42.9 (28-Dec-2013)
resize2fs: Bad magic number in super-block while trying to open /dev/mapper/pool-xiaoliziLV # This error is due to the previous filesystem. xfs Yes, so the extension command here is xfs_growfs
Couldn't find valid filesystem superblock.[root@centos7 ~]# xfs_growfs /dev/mapper/pool-xiaoliziLV # Update file system
meta-data=/dev/mapper/pool-xiaoliziLV isize=512 agcount=4, agsize=131072 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=524288, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 524288 to 786432[root@centos7 ~]# df -h # Capacity expansion
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 98G 1.6G 97G 2% /
devtmpfs 901M 0 901M 0% /dev
tmpfs 911M 0 911M 0% /dev/shm
tmpfs 911M 9.6M 902M 2% /run
tmpfs 911M 0 911M 0% /sys/fs/cgroup
/dev/sda1 1014M 135M 880M 14% /boot
tmpfs 183M 0 183M 0% /run/user/0
/dev/mapper/pool-xiaoliziLV 3.0G 33M 3.0G 2% /lvtest
In the second case, there is not enough space left in the VG (1 G can be seen idle), which increases the capacity of the LV by 16 G. The steps are as follows:
[root@centos7 ~]# vgdisplay --- Volume group --- VG Name pool System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 3 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 1 Max PV 0 Cur PV 2 Act PV 2 VG Size 3.99 GiB PE Size 4.00 MiB Total PE 1022 Alloc PE / Size 768 / 3.00 GiB Free PE / Size 254 / 1016.00 MiB VG UUID e55Yks-0Phr-VarP-xAF8-8W4B-vBFg-VWqPm3 [root@centos7 ~]# lvextend -L 16G /dev/pool/xiaoliziLV # Not enough capacity [root@centos7 ~]# ls /dev/sdd # Added a 20G new hard disk /dev/sdd [root@centos7 ~]# pvcreate /dev/sdd # Create pv Physical volume "/dev/sdd" successfully created. [root@centos7 ~]# pvs PV VG Fmt Attr PSize PFree /dev/sdb pool lvm2 a-- <2.00g 0 /dev/sdc pool lvm2 a-- <2.00g 1016.00m /dev/sdd lvm2 --- 20.00g 20.00g [root@centos7 ~]# vgextend pool /dev/sdd # Create VG pool Volume group "pool" successfully extended [root@centos7 ~]# vgdisplay # Freepe size is more than 20G --- Volume group --- VG Name pool System ID Format lvm2 Metadata Areas 3 Metadata Sequence No 4 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 0 Max PV 0 Cur PV 3 Act PV 3 VG Size <23.99 GiB PE Size 4.00 MiB Total PE 6141 Alloc PE / Size 768 / 3.00 GiB Free PE / Size 5373 / <20.99 GiB VG UUID e55Yks-0Phr-VarP-xAF8-8W4B-vBFg-VWqPm3 [root@centos7 ~]# lvextend -L +16G /dev/pool/xiaoliziLV # Capacity Expansion of 16G Size of logical volume pool/xiaoliziLV changed from 3.00 GiB (768 extents) to 19.00 B (4864 extents). Logical volume pool/xiaoliziLV successfully resized.
[root@centos7 ~]# xfs_growfs /dev/pool/xiaoliziLV # Format filesystem error, because the previous mount was not written to boot self-check, so it will report error. xfs_growfs: /dev/pool/xiaoliziLV is not a mounted XFS filesystem [root@centos7 ~]# mount /dev/mapper/pool-xiaoliziLV /lvtest # Remount [root@centos7 ~]# xfs_growfs /dev/pool/xiaoliziLV # Capacity expansion meta-data=/dev/mapper/pool-xiaoliziLV isize=512 agcount=6, agsize=131072 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0 spinodes=0 data = bsize=4096 blocks=786432, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 786432 to 4980736[root@centos7 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 98G 1.6G 97G 2% /
devtmpfs 901M 0 901M 0% /dev
tmpfs 911M 0 911M 0% /dev/shm
tmpfs 911M 9.5M 902M 2% /run
tmpfs 911M 0 911M 0% /sys/fs/cgroup
/dev/sda1 1014M 135M 880M 14% /boot
tmpfs 183M 0 183M 0% /run/user/0
/dev/mapper/pool-xiaoliziLV 19G 34M 19G 1% /lvtest
7. Reducing a Logic Volume
Reducing logical volumes is actually replacing a specified number of PE from LV back to VG.
[Note] The shrinking operation of logical volumes must first uninstall the logical volumes, otherwise the files in the logical volumes may be damaged. At this time, we will reduce the LV to 10G, the steps are as follows:
1.adopt umount Unload mounted logical volumes
[root@onion ~]# umount /mnt/ [root@onion ~]# df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/sda3 ext4 48G 1.5G 44G 4% / tmpfs tmpfs 491M 0 491M 0% /dev/shm /dev/sda1 ext4 190M 35M 146M 19% /boot 2.narrow LV Size: As we mentioned earlier, yes. LV After expansion, it needs to be implemented. resize2fs/xfs_growfs Update our file system, but on LV When performing scaling-down operations(xfs File system does not support scaling),Reduction must be performed first [root@onion ~]# resize2fs /dev/pool/mylv 10G # Check the file system or e2fsck-f/dev/pool/mylv resize2fs 1.41.12 (17-May-2010) Please run 'e2fsck -f /dev/pool/mylv' first. [root@onion ~]# e2fsck -f /dev/pool/mylv e2fsck 1.41.12 (17-May-2010) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information /dev/pool/mylv: 12/1245184 files (0.0% non-contiguous), 95937/4980736 blocks 3.After checking, use it again resize2fs To shrink the file system
[root@onion ~]# resize2fs /dev/pool/mylv 10G resize2fs 1.41.12 (17-May-2010) Resizing the filesystem on /dev/pool/mylv to 2621440 (4k) blocks. The filesystem on /dev/pool/mylv is now 2621440 blocks long. 4.Contrary to the order of expansion, we first narrowed down the file system, then narrowed down. LV,Use lvreduce command [root@onion ~]# lvreduce -L -9G /dev/pool/mylv WARNING: Reducing active logical volume to 10.00 GiB. THIS MAY DESTROY YOUR DATA (filesystem etc.) Do you really want to reduce pool/mylv? [y/n]: y
Note: Here's a warning that our files may be damaged. This will happen when we need to reduce the file size and actual operation.( resize2fs)When the size of the file is not the same, for example, if I shrink one more file here G The size of the logical volume, this time there will be file corruption Size of logical volume pool/mylv changed from 19.00 GiB (4864 extents) to 10.00 GiB (2560 extents). Logical volume mylv successfully resized. [root@onion ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert mylv pool -wi-a----- 10.00g [Note: Reducing logical volumes is a very dangerous operation. A little negligence may damage our logical volumes, causing the loss or damage of files, so we generally do not want to reduce logical volumes. 5.After shrinking, mount the logical volume on/mnt Next, see if the file inside exists.
VIII. Reducing Volume Group
When we have enough space in VG and a lot of spare space, we want to take down the hard disk which is not used in VG for its use. At this point, we need to perform the operation of reducing volume groups.
1.use first pvdisplay View each PV You can see the information/dev/sdd Space is unused [root@onion ~]# pvdisplay --- Physical volume --- PV Name /dev/sdb VG Name pool PV Size 8.00 GiB / not usable 4.00 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 2047 Free PE 0 Allocated PE 2047 PV UUID SfW2Wo-NeZM-KXSX-UqQj-VWHV-NAL6-UQb3lw --- Physical volume --- PV Name /dev/sdc VG Name pool PV Size 8.00 GiB / not usable 4.00 MiB Allocatable yes PE Size 4.00 MiB Total PE 2047 Free PE 1534 Allocated PE 513 PV UUID F8Gq56-M9ff-i9e9-TEvF-1BOL-qsiJ-PTuApu --- Physical volume --- PV Name /dev/sdd VG Name pool PV Size 8.00 GiB / not usable 4.00 MiB Allocatable yes PE Size 4.00 MiB Total PE 2047 Free PE 2047 Allocated PE 0 PV UUID IT2wzW-bVBQ-NU7C-9EbU-3uie-W1LF-Vx3clj 2.Whether to uninstall the logical volume after determining the disk
[root@onion ~]# umount /mnt/ [root@onion ~]# df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/sda3 ext4 48G 1.5G 44G 4% / tmpfs tmpfs 491M 0 491M 0% /dev/shm /dev/sda1 ext4 190M 35M 146M 19% /boot 3.Take this PV Remove and view from the specified volume.
[root@onion ~]# vgreduce pool /dev/sdd Removed "/dev/sdd" from volume group "pool" [root@onion ~]# vgdisplay --- Volume group --- VG Name pool System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 9 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 0 Max PV 0 Cur PV 2 Act PV 2 VG Size 15.99 GiB PE Size 4.00 MiB Total PE 4094 Alloc PE / Size 2560 / 10.00 GiB Free PE / Size 1534 / 5.99 GiB VG UUID YUlucV-5pVP-W73A-DAsR-EIlw-jnVf-l5Y9M1 4.See PV The situation (found or found)/dev/sdd)
[root@onion ~]# pvs PV VG Fmt Attr PSize PFree /dev/sdb pool lvm2 a--u 8.00g 0 /dev/sdc pool lvm2 a--u 8.00g 5.99g /dev/sdd lvm2 ---- 8.00g 8.00g 5.remove/dev/sdd this PV
[root@onion ~]# pvremove /dev/sdd Labels on physical volume "/dev/sdd" successfully wiped [root@onion ~]# pvs PV VG Fmt Attr PSize PFree /dev/sdb pool lvm2 a--u 8.00g 0 /dev/sdc pool lvm2 a--u 8.00g 5.99g 6.Remount to see if the file has changed
[root@onion ~]# mount /dev/pool/mylv /mnt [root@onion ~]# ll /mnt/ total 16 -rw-r--r--. 1 root root 0 Jul 15 10:56 koala drwx------. 2 root root 16384 Jul 15 10:46 lost+found
9. Delete Logical Volume
For unwanted logical volumes, you can delete them.
[Note] The creation of LV s is sequential and the deletion is strictly sequential.
Uninstall - > Delete Logical Volumes - > Delete Volume Groups - > Delete Physical Volumes
- Unload the logical volume using the umount command
- Delete logical volumes using the lvremove command
- Delete volume groups, using the vgremove command
- Delete the physical volume, using the pvremove command
[root@onion ~]# umount /dev/pool/mylv [root@onion ~]# lvremove /dev/pool/mylv Do you really want to remove active logical volume mylv? [y/n]: y Logical volume "mylv" successfully removed [root@onion ~]# vgremove pool Volume group "pool" successfully removed [root@onion ~]# pvremove /dev/sdb Labels on physical volume "/dev/sdb" successfully wiped
# View the unload status [root@onion ~]# lvs [root@onion ~]# vgs [root@onion ~]# pvs PV VG Fmt Attr PSize PFree /dev/sdc lvm2 ---- 8.00g 8.00g