LVM: Logical Volume Manager 可以允許對卷進行方便操作的抽象層,,包括重新設(shè)定文件系統(tǒng)的大小,,允許在多個物理設(shè)備間重新組織文件系統(tǒng),,可增大可縮減(縮減必須取消掛載會導(dǎo)致數(shù)據(jù)丟失)彈性更改 邏輯分區(qū)與邏輯卷的區(qū)別 邏輯卷與邏輯分區(qū)不是同一概念,,邏輯分區(qū)容量大小不能改變,;邏輯卷容量大小可以改變(基于物理卷和卷組之上的邏輯卷),;邏輯卷管理器(LVM)可以更輕松的管理磁盤空間(整合的磁盤池) 以下是原理圖,,可以更好的理解 #創(chuàng)建物理卷 pvcreate /dev/sda3 \#為卷組分配物理卷 vgcreate vg0 /dev/sda3 \#從卷組創(chuàng)建邏輯卷 lvcreate -L 256M -n data vg0 \#mkfs.xfs /dev/vg0/data 創(chuàng)建文件系統(tǒng) \#掛載 mount /dev/vg0/data /mnt/data#擴展 lvextend -L [ ]#[mMgGtT] /dev/VG_NAME/LV_NAME \#針對ext resize2fs /dev/VG_NAME/LV_NAME \#針對xfs xfs_growfs MOUNTPOINT lvresize -r -l 100%FREE /dev/VG_NAME/LV_NAME縮減 只支持ext4 umount /dev/VG_NAME/LV_NAME e2fsck -f /dev/VG_NAME/LV_NAME resize2fs /dev/VG_NAME/LV_NAME #[mMgGtT] lvreduce -L [-]#[mMgGtT] /dev/VG_NAME/LV_NAME mount 可以是硬盤 可以是分區(qū) 分區(qū)需要改類型 范例 :針對ext4 創(chuàng)建邏輯分區(qū)以及擴展分區(qū)[root@27 ~]#fdisk -l /dev/sdb Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 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: 0x2d890684 Device Boot Start End Blocks Id System /dev/sdb1 2048 4196351 2097152 82 Linux swap / Solaris /dev/sdb2 4196352 8390655 2097152 83 Linux #修改文件類型 [root@27 ~]#fdisk /dev/sdb2 Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table Building a new DOS disklabel with disk identifier 0x59eb2927. Command (m for help): t No partition is defined yet! Command (m for help): q [root@27 ~]#fdisk /dev/sdb Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): t Partition number (1,2, default 2): 2 Hex code (type L to list all codes): L 0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris 1 FAT12 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT- 2 XENIX root 39 Plan 9 83 Linux c4 DRDOS/sec (FAT- 3 XENIX usr 3c PartitionMagic 84 OS/2 hidden C: c6 DRDOS/sec (FAT- 4 FAT16 <32M 40 Venix 80286 85 Linux extended c7 Syrinx 5 Extended 41 PPC PReP Boot 86 NTFS volume set da Non-FS data 6 FAT16 42 SFS 87 NTFS volume set db CP/M / CTOS / . 7 HPFS/NTFS/exFAT 4d QNX4.x 88 Linux plaintext de Dell Utility 8 AIX 4e QNX4.x 2nd part 8e Linux LVM df BootIt 9 AIX bootable 4f QNX4.x 3rd part 93 Amoeba e1 DOS access a OS/2 Boot Manag 50 OnTrack DM 94 Amoeba BBT e3 DOS R/O b W95 FAT32 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor c W95 FAT32 (LBA) 52 CP/M a0 IBM Thinkpad hi eb BeOS fs e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD ee GPT f W95 Ext d (LBA) 54 OnTrackDM6 a6 OpenBSD ef EFI (FAT-12/16/ 10 OPUS 55 EZ-Drive a7 NeXTSTEP f0 Linux/PA-RISC b 11 Hidden FAT12 56 Golden Bow a8 Darwin UFS f1 SpeedStor 12 Compaq diagnost 5c Priam Edisk a9 NetBSD f4 SpeedStor 14 Hidden FAT16 <3 61 SpeedStor ab Darwin boot f2 DOS secondary 16 Hidden FAT16 63 GNU HURD or Sys af HFS / HFS fb VMware VMFS 17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fc VMware VMKCORE 18 AST SmartSleep 65 Novell Netware b8 BSDI swap fd Linux raid auto 1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fe LANstep 1c Hidden W95 FAT3 75 PC/IX be Solaris boot ff BBT 1e Hidden W95 FAT1 80 Old Minix Hex code (type L to list all codes): 8e (改成Linux LVM) Changed type of partition 'Linux' to 'Linux LVM' Command (m for help): p Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 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: 0x2d890684 Device Boot Start End Blocks Id System /dev/sdb1 2048 4196351 2097152 82 Linux swap / Solaris /dev/sdb2 4196352 8390655 2097152 8e Linux LVM #發(fā)現(xiàn)已經(jīng)修改 Command (m for help): w #保存 The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks. 添加一塊硬盤掃描 [root@27 ~]#for i in {0..32};do echo '- - -' >/sys/class/scsi_host/host$i/scan;done [root@27 ~]#lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 200G 0 disk ├─sda1 8:1 0 1G 0 part /boot ├─sda2 8:2 0 100G 0 part / ├─sda3 8:3 0 2G 0 part [SWAP] ├─sda4 8:4 0 1K 0 part └─sda5 8:5 0 50G 0 part /data sdb 8:16 0 20G 0 disk ├─sdb1 8:17 0 2G 0 part [SWAP] └─sdb2 8:18 0 2G 0 part sdc 8:32 0 5G 0 disk #是這塊 sr0 11:0 1 1024M 0 rom [root@27 ~]#pvcreate /dev/sd{b2,c} 創(chuàng)建物理卷 Physical volume "/dev/sdb2" successfully created. Physical volume "/dev/sdc" successfully created. [root@27 ~]#pvs 查看物理卷 PV VG Fmt Attr PSize PFree /dev/sdb2 lvm2 --- 2.00g 2.00g /dev/sdc lvm2 --- 5.00g 5.00g [root@27 ~]#pvdisplay 查看詳細信息 "/dev/sdb2" is a new physical volume of "2.00 GiB" --- NEW Physical volume --- PV Name /dev/sdb2 VG Name PV Size 2.00 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID jmJ13J-XHgq-ou2J-QVvB-CXy1-FTYX-8mnC5r "/dev/sdc" is a new physical volume of "5.00 GiB" --- NEW Physical volume --- PV Name /dev/sdc VG Name 為空 PV Size 5.00 GiB Allocatable NO PE Size 0 PE大小沒有指定 由卷組指定 Total PE 0 Free PE 0 Allocated PE 0 PV UUID IQ0xHD-btaL-XmmT-cE9Q-BQMU-kYA2-ZDUZxQ [root@27 ~]#vgcreate vg1 /dev/sd{b2,c} #######vgcreate -s 16M vg1 /dev/sd{b2,c} -s可以指定PE大小 Volume group "vg1" successfully created [root@27 ~]#vgs VG #PV #LV #SN Attr VSize VFree vg1 2 0 0 wz--n- 6.99g 6.99g [root@27 ~]#pvs PV VG Fmt Attr PSize PFree /dev/sdb2 vg1 lvm2 a-- <2.00g <2.00g /dev/sdc vg1 lvm2 a-- <5.00g <5.00g [root@27 ~]#vgdisplay --- Volume group --- VG Name vg1 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 6.99 GiB PE Size 4.00 MiB Total PE 1790 Alloc PE / Size 0 / 0 Free PE / Size 1790 / 6.99 GiB VG UUID OBZcYO-20eN-m2E6-bDn8-ZUCg-Pfro-7caBik [root@27 ~]#lvcreate -n shuju -l 100%free vg1 分配所有空間 選擇性分配 Logical volume "shuju" created. [root@27 ~]#lvdisplay --- Logical volume --- LV Path /dev/vg1/shuju #邏輯卷的名稱 LV Name shuju VG Name vg1 LV UUID zKB4qu-XMnJ-U4Qx-2IlZ-XRT6-f7km-m6mB9q LV Write Access read/write LV Creation host, time 27, 2020-01-04 14:47:28 0800 LV Status available # open 0 LV Size 6.99 GiB Current LE 1790 Segments 2 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:,、 [root@27 ~]#mkfs.ext4 /dev/vg1/shuju 創(chuàng)建文件系統(tǒng) mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 458752 inodes, 1832960 blocks 91648 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=1876951040 56 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done [root@27 ~]#blkid /dev/sda1: UUID="b09c53db-dbe8-4932-ad6e-2b0890ea8844" TYPE="xfs" /dev/sda2: UUID="703b7b55-0dc1-40fc-bfc5-e9a581c48a05" TYPE="xfs" /dev/sda3: UUID="16ba9174-387a-4725-8cdf-e67c7a52d3bc" TYPE="swap" /dev/sda5: UUID="b944d856-d1ac-4694-8c59-04399a8b4786" TYPE="xfs" /dev/sdb1: UUID="95565861-5268-4482-bf6d-349a97322559" TYPE="swap" /dev/sdb2: UUID="jmJ13J-XHgq-ou2J-QVvB-CXy1-FTYX-8mnC5r" TYPE="LVM2_member" /dev/sdc: UUID="IQ0xHD-btaL-XmmT-cE9Q-BQMU-kYA2-ZDUZxQ" TYPE="LVM2_member" /[root@27 ~]#mount /dev/vg1/shuju /mnt/shuju [root@27 ~]#mkdir /mnt/shuju [root@27 ~]#df Filesystem 1K-blocks Used Available Use% Mounted on devtmpfs 1919944 0 1919944 0% /dev tmpfs 1930684 0 1930684 0% /dev/shm tmpfs 1930684 11908 1918776 1% /run tmpfs 1930684 0 1930684 0% /sys/fs/cgroup /dev/sda2 104806400 1500324 103306076 2% / /dev/sda5 52403200 32992 52370208 1% /data /dev/sda1 1038336 144220 894116 14% /boot tmpfs 386140 0 386140 0% /run/user/0 /dev/mapper/vg1-shuju 7085560 32208 6670376 1% /mnt/shuju /mapper/vg1-shuju: UUID="4e49d747-9616-418f-b66a-c07f41a0de98" TYPE="ext4" #寫到 /etc/fstab 永久掛載 [root@27 ~]#vgextend vg1 /dev/sdb3 擴展邏輯卷 Physical volume "/dev/sdb3" successfully created. Volume group "vg1" successfully extended [root@27 ~]#pvs PV VG Fmt Attr PSize PFree /dev/sdb2 vg1 lvm2 a-- <2.00g 0 /dev/sdb3 vg1 lvm2 a-- 1020.00m 1020.00m /dev/sdc vg1 lvm2 a-- <5.00g 0 [root@27 ~]#df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 1.9G 0 1.9G 0% /dev tmpfs 1.9G 0 1.9G 0% /dev/shm tmpfs 1.9G 12M 1.9G 1% /run tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup /dev/sda2 100G 1.5G 99G 2% / /dev/sda5 50G 33M 50G 1% /data /dev/sda1 1014M 141M 874M 14% /boot tmpfs 378M 0 378M 0% /run/user/0 /dev/mapper/vg1-shuju 6.8G 32M 6.4G 1% /mnt/shuju 查看 [root@27 ~]#lvextend -r -L 500M /dev/vg1/shuju 加500M Size of logical volume vg1/shuju changed from 6.99 GiB (1790 extents) to 7.48 GiB (1915 extents). Logical volume vg1/shuju successfully resized. resize2fs 1.42.9 (28-Dec-2013) Filesystem at /dev/mapper/vg1-shuju is mounted on /mnt/shuju; on-line resizing required old_desc_blocks = 1, new_desc_blocks = 1 The filesystem on /dev/mapper/vg1-shuju is now 1960960 blocks long. [root@27 ~]#df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 1.9G 0 1.9G 0% /dev tmpfs 1.9G 0 1.9G 0% /dev/shm tmpfs 1.9G 12M 1.9G 1% /run tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup /dev/sda2 100G 1.5G 99G 2% / /dev/sda5 50G 33M 50G 1% /data /dev/sda1 1014M 141M 874M 14% /boot tmpfs 378M 0 378M 0% /run/user/0 /dev/mapper/vg1-shuju 7.3G 32M 6.9G 1% /mnt/shuju 與上面對比空間增大 #######刪除lvm邏輯卷 [root@27 ~]#lvremove /dev/vg1/shuju Do you really want to remove active logical volume vg1/shuju? [y/n]: y 提示是否刪除 Logical volume "shuju" successfully removed [root@27 ~]#vgdisplay --- Volume group --- VG Name vg1 System ID Format lvm2 Metadata Areas 3 Metadata Sequence No 10 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 <7.99 GiB PE Size 4.00 MiB Total PE 2045 Alloc PE / Size 0 / 0 Free PE / Size 2045 / <7.99 GiB VG UUID OBZcYO-20eN-m2E6-bDn8-ZUCg-Pfro-7caBik [root@27 ~]#vgremove vg1 刪除卷組 Volume group "vg1" successfully removed [root@27 ~]#pvs PV VG Fmt Attr PSize PFree /dev/sdb2 lvm2 --- 2.00g 2.00g /dev/sdb3 lvm2 --- 1.00g 1.00g /dev/sdc lvm2 --- 5.00g 5.00g [root@27 ~]#pvremove /dev/sd{b2,b3,c} 刪除邏輯卷 Labels on physical volume "/dev/sdb2" successfully wiped. Labels on physical volume "/dev/sdb3" successfully wiped. Labels on physical volume "/dev/sdc" successfully wiped. [root@27 ~]#fdisk -l /dev/sdb Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 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: 0x2d890684 Device Boot Start End Blocks Id System /dev/sdb1 2048 4196351 2097152 82 Linux swap / Solaris /dev/sdb2 4196352 8390655 2097152 8e Linux LVM #也可以刪除 /dev/sdb3 8390656 10487807 1048576 83 Linux /dev/sdb4 10487808 12584959 1048576 83 Linux 邏輯卷快照 快照是特殊的邏輯卷,,它是在生成快照時存在的邏輯卷的準(zhǔn)確拷貝,對于需要備份或者復(fù)制的現(xiàn)有數(shù)據(jù)臨時拷貝以及其它操作來說,快照是最合適的選擇,快照只有在它們和原來的邏輯卷不同時才會消耗空間,,建立快照的卷大小小于等于原始邏輯卷,也可以使用lvextend擴展快照 邏輯卷管理器快照 快照就是將當(dāng)時的系統(tǒng)信息記錄下來,,就好像照相一般,若將來有任何數(shù)據(jù)改動了,,則原始數(shù)據(jù)會被移動到快照區(qū),,沒有改動的區(qū)域則由快照區(qū)和文件系統(tǒng)共享 邏輯卷快照工作原理 在生成快照時會分配給它一定的空間,但只有在原來的邏輯卷或者快照有所改變才會使用這些空間,,當(dāng)原來的邏輯卷中有所改變時,,會將舊的數(shù)據(jù)復(fù)制到快照中,快照中只含有原來的邏輯卷中更改的數(shù)據(jù)或者自生成快照后的快照中更改的數(shù)據(jù),,由于快照區(qū)與原本的LV共用很多PE的區(qū)塊,,因此快照與被快照的LV必須在同一個VG中.系統(tǒng)恢復(fù)的時候的文件數(shù)量不能高于快照區(qū)的實際容量#為現(xiàn)有邏輯卷創(chuàng)建快照 快照大小小于等于邏輯卷大小 快照包括屬性備份 lvcreate -l 64 -s -n data-snapshot -p r /dev/vg0/data \#掛載快照 mkdir -p /mnt/snap mount -o ro /dev/vg0/data-snapshot /mnt/snap \#恢復(fù)快照 umount /dev/vg0/data-snapshot umount /dev/vg0/data lvconvert --merge /dev/vg0/data-snapshot \#刪除快照 umount /mnt/databackup lvremove /dev/vg0/databackup快照范例 [root@27 ~]#df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 1.9G 0 1.9G 0% /dev tmpfs 1.9G 0 1.9G 0% /dev/shm tmpfs 1.9G 12M 1.9G 1% /run tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup /dev/sda2 100G 1.5G 99G 2% / /dev/sda5 50G 33M 50G 1% /data /dev/sda1 1014M 141M 874M 14% /boot tmpfs 378M 0 378M 0% /run/user/0 /dev/mapper/vg1-shuju 7.3G 32M 6.9G 1% /mnt/shuju [root@27 ~]#cp /etc/fstab /mnt/shuju/f1 [root@27 ~]#cp /etc/fstab /mnt/shuju/f2 [root@27 ~]#cp /etc/fstab /mnt/shuju/f3 [root@27 ~]#ls /mnt/shuju f1 f2 f3 lost found [root@27 ~]#lvcreate -n shuju_snapshot -s -p r -L 300M /dev/vg1/shuju ##### -n 指定名字 -s快照 r只讀 Logical volume "shuju_snapshot" created. [root@27 ~]#lvdisplay --- Logical volume --- LV Path /dev/vg1/shuju LV Name shuju VG Name vg1 LV UUID zKB4qu-XMnJ-U4Qx-2IlZ-XRT6-f7km-m6mB9q LV Write Access read/write LV Creation host, time 27, 2020-01-04 14:47:28 0800 LV snapshot status source of shuju_snapshot [active] 顯示有快照 LV Status available # open 1 LV Size 7.48 GiB Current LE 1915 Segments 3 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:0 --- Logical volume --- LV Path /dev/vg1/shuju_snapshot LV Name shuju_snapshot 快照 VG Name vg1 LV UUID G8n4yi-FOkw-RlbZ-GtEf-8IHh-4fRw-hYnoma LV Write Access read only 只讀屬性 LV Creation host, time 27, 2020-01-04 15:39:49 0800 LV snapshot status active destination for shuju 對數(shù)據(jù)的備份 LV Status available # open 0 LV Size 7.48 GiB Current LE 1915 COW-table size 300.00 MiB COW-table LE 75 Allocated to snapshot 0.01% Snapshot chunk size 4.00 KiB Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:3 [root@27 ~]#mkdir /mnt/snap root@27 ~]#mount /dev/vg1/shuju_snapshot /mnt/snap mount: /dev/mapper/vg1-shuju_snapshot is write-protected, mounting read-only [root@27 ~]#ls /mnt/snap/ f1 f2 f3 lost found 視覺欺騙 你看到的數(shù)據(jù)并不在這里 [root@27 ~]#df Filesystem 1K-blocks Used Available Use% Mounted on devtmpfs 1919940 0 1919940 0% /dev tmpfs 1930680 0 1930680 0% /dev/shm tmpfs 1930680 11904 1918776 1% /run tmpfs 1930680 0 1930680 0% /sys/fs/cgroup /dev/sda2 104806400 1499084 103307316 2% / /dev/sda5 52403200 32992 52370208 1% /data /dev/sda1 1038336 144348 893988 14% /boot tmpfs 386140 0 386140 0% /run/user/0 /dev/mapper/vg1-shuju 7589336 32220 7153988 1% /mnt/shuju /dev/mapper/vg1-shuju_snapshot 7589336 32220 7153988 1% /mnt/snap [root@27 ~]#echo > /mnt/shuju/f1 [root@27 ~]#ll /mnt/shuju total 28 -rw-r--r--. 1 root root 1 Jan 4 15:57 f1 數(shù)據(jù)清空 -rw-r--r--. 1 root root 689 Jan 4 15:30 f2 -rw-r--r--. 1 root root 689 Jan 4 15:30 f3 drwx------. 2 root root 16384 Jan 4 14:54 lost found [root@27 ~]#ll /mnt/snap/f1 -rw-r--r--. 1 root root 689 Jan 4 15:30 /mnt/snap/f1 查看數(shù)據(jù)在快照中 [root@27 ~]#rm -f /mnt/shuju/f2 刪除f2 [root@27 ~]#ll /mnt/shuju/ total 24 -rw-r--r--. 1 root root 1 Jan 4 15:57 f1 -rw-r--r--. 1 root root 689 Jan 4 15:30 f3 drwx------. 2 root root 16384 Jan 4 14:54 lost found [root@27 ~]#ll /mnt/snap 快照依舊存在 total 28 -rw-r--r--. 1 root root 689 Jan 4 15:30 f1 -rw-r--r--. 1 root root 689 Jan 4 15:30 f2 -rw-r--r--. 1 root root 689 Jan 4 15:30 f3 drwx------. 2 root root 16384 Jan 4 14:54 lost found [root@27 ~]#umount /mnt/shuju [root@27 ~]#umount /mnt/snap [root@27 ~]#lvconvert --merge /dev/vg1/shuju_snapshot 恢復(fù)快照 Merging of volume vg1/shuju_snapshot started. vg1/shuju: Merged: 100.00% [root@27 ~]#mount /dev/vg1/shuju /mnt/shuju [root@27 ~]#ls /mnt/shuju f1 f2 f3 lost found 注意:快照是一次性的 用完就沒有了假如sdb2快將要壞掉 [root@27 ~]#pvs PV VG Fmt Attr PSize PFree /dev/sdb2 vg1 lvm2 a-- <2.00g 0 /dev/sdb3 vg1 lvm2 a-- 1020.00m 520.00m /dev/sdc vg1 lvm2 a-- <5.00g 0 [root@27 ~]#pvdisplay --- Physical volume --- PV Name /dev/sdb2 VG Name vg1 PV Size 2.00 GiB / not usable 4.00 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 511 Free PE 0 Allocated PE 511 PV UUID jmJ13J-XHgq-ou2J-QVvB-CXy1-FTYX-8mnC5r --- Physical volume --- PV Name /dev/sdc VG Name vg1 PV Size 2.00 GiB / not usable 4.00 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 511 Free PE 0 Allocated PE 511 PV UUID IQ0xHD-btaL-XmmT-cE9Q-BQMU-kYA2-ZDUZxQ --- Physical volume --- PV Name /dev/sdb3 VG Name vg1 PV Size 5.00 GiB / not usable 4.00 MiB Allocatable yes PE Size 4.00 MiB Total PE 1279 Free PE 1154 我們發(fā)現(xiàn)這個還有1154 PE Allocated PE 125 PV UUID RGQEM5-1beD-BzaI-I1Pq-gng4-aUJZ-lEKlrP [root@27 ~]#pvmove /dev/sdc 將sdb2的PE移動到其他上 (有空間就行隨便哪個) Removed "/dev/sdb2" from volume group "vg1" [root@27 ~]#pvdisplay /dev/sdbc --- Physical volume --- PV Name /dev/sdc VG Name 可以看到不屬于任何vg 空間也會相應(yīng)的變少 PV Size 2.00 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID jmJ13J-XHgq-ou2J-QVvB-CXy1-FTYX-8mnC5r [root@27 ~]#pvs PV VG Fmt Attr PSize PFree /dev/sdb2 vg1 lvm2 a-- <2.00g 0 /dev/sdb3 vg1 lvm2 a-- 1020.00m 520.00m /dev/sdc lvm2 a-- <5.00g 0 [root@27 ~]#pvremove /dev/sdc 移除就可以直接拔掉 分區(qū)可以刪除 volume --- PV Name /dev/sdc VG Name 可以看到不屬于任何vg 空間也會相應(yīng)的變少 PV Size 2.00 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID jmJ13J-XHgq-ou2J-QVvB-CXy1-FTYX-8mnC5r [root@27 ~]#pvs PV VG Fmt Attr PSize PFree /dev/sdb2 vg1 lvm2 a-- <2.00g 0 /dev/sdb3 vg1 lvm2 a-- 1020.00m 520.00m /dev/sdc lvm2 a-- <5.00g 0 [root@27 ~]#pvremove /dev/sdc 移除就可以直接拔掉 分區(qū)可以刪除 |
|