鸟哥学习之LVM

   

一、前言

     以前对LVM、PV、PE、VG、LV真的不晓得是个什么东西。经过学习,恍然大悟,特做一下记录。

二、基本概览

lvm的目的主要是为了弹性的调整文件系统的容量,而不是性能与数据安全上面。

LVM (Logical Volume Manager),逻辑卷轴管理员

PV(Physical Volume)物理卷

PE(Physical Extend)物理扩展块

VG(volume group)卷组

LV(logical volme)逻辑卷

具体关系图如下:

 

 

 

三、操作

主要参考鸟哥的linux私房菜,扩容LV

step1:

lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdb 8:16 0 1.8T 0 disk 
sda 8:0 0 6.6T 0 disk 
├─sda2 8:2 0 7G 0 part 
│ └─h3linux_centos-root 253:0 0 7G 0 lvm /
├─sda3 8:3 0 60.8M 0 part 
└─sda1 8:1 0 1G 0 part /boot

fdisk /dev/sda

WARNING: The size of this disk is 7.2 TB (7201327243264 bytes).
DOS partition table format can not be used on drives for volumes
larger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUID 
partition table format (GPT).


The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted.
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): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
g create a new empty GPT partition table
G create an IRIX (SGI) partition table
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

Command (m for help): n
Partition type:
p primary (3 primary, 0 extended, 1 free)
e extended
Select (default e): p
Selected partition 4
First sector (16777216-4294967295, default 16777216): 
Using default value 16777216
Last sector, +sectors or +size{K,M,G} (16777216-4095873023, default 4095873023): 
Using default value 4095873023
Partition 4 of type Linux and of size 1.9 TiB is set

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.

 

step2: partprobe

step3:

lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdb 8:16 0 1.8T 0 disk 
sda 8:0 0 6.6T 0 disk 
├─sda4 8:4 0 1.9T 0 part 
├─sda2 8:2 0 7G 0 part 
│ └─h3linux_centos-root 253:0 0 7G 0 lvm /
├─sda3 8:3 0 60.8M 0 part 
└─sda1 8:1 0 1G 0 part /boot

 

pvcreate /dev/sda4

 

step4:

vgextend h3linux_centos /dev/sda4

step5:

lvextend -L +400G /dev/h3linux_centos/root

lvextend -l +100%FREE /dev/vg00/lv_root

step6:

xfs_growfs /dev/h3linux_centos/root

 

lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdb 8:16 0 1.8T 0 disk 
sda 8:0 0 6.6T 0 disk 
├─sda4 8:4 0 1.9T 0 part 
│ └─h3linux_centos-root 253:0 0 407G 0 lvm /
├─sda2 8:2 0 7G 0 part 
│ └─h3linux_centos-root 253:0 0 407G 0 lvm /
├─sda3 8:3 0 60.8M 0 part 
└─sda1 8:1 0 1G 0 part /boot

success!!!

 =====================================================

记录给虚拟机扩容磁盘

1、vgdisplay lvdisplay

2、lvextend -l +<number_of_free_pe> /dev/your_vg_name/your_lv_name

3、lvextend -L +<size>G /dev/your_vg_name/your_lv_name

4、resize2fs /dev/your_vg_name/your_lv_name

 

posted on 2020-06-16 19:52  星星眨着眼  阅读(176)  评论(0编辑  收藏  举报

导航