1、Centos7.9 扩展逻辑卷
1.1、查看
df -h
fdisk -l
pvdisplay
vgdisplay
cat /etc/fstab
[root@tcentos79 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 7.8G 0 7.8G 0% /dev
tmpfs 7.8G 0 7.8G 0% /dev/shm
tmpfs 7.8G 9.5M 7.8G 1% /run
tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup
/dev/mapper/centos-root 32G 6.1G 26G 20% /
/dev/sda1 497M 179M 318M 37% /boot
/dev/mapper/centos-u01 2.0G 33M 2.0G 2% /u01
[root@tcentos79 ~]#
[root@tcentos79 ~]# cat /etc/fstab | grep centos-u01
/dev/mapper/centos-u01 /u01 xfs defaults 0 0
[root@tcentos79 ~]#
[root@tcentos79 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 100G 0 disk
├─sda1 8:1 0 500M 0 part /boot
└─sda2 8:2 0 49.5G 0 part
├─centos-root 253:0 0 31.5G 0 lvm /
├─centos-swap 253:1 0 16G 0 lvm [SWAP]
└─centos-u01 253:2 0 2G 0 lvm /u01
sr0 11:0 1 1024M 0 rom
[root@tcentos79 ~]#
1.2、 fdisk 格式化新增分区 /dev/sda3 后重启虚拟机(若后继操作遇到问题重启虚拟机再操作)
--## 1.2.1 fdisk 格式化新增分区 /dev/sda3
[root@tprocessproj ~]# fdisk /dev/sda
........
--## 1.2.2 fdisk 更改分区/dev/sda3 Linux类型为Linux LVM类型
[root@tprocessproj ~]# fdisk /dev/sda
Welcome to fdisk (util-linux 2.23.2).
........
Command (m for help): t
Partition number (1-3, default 3): 3
Hex code (type L to list all codes): L <<<<<<<----
...................
Hex code (type L to list all codes): 8e <<<<<<<----
Changed type of partition 'Linux' to 'Linux LVM' <<<<<<<----
Command (m for help): w
[root@tprocessproj ~]#
[root@tcentos79 ~]# 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: 0x000a9b74
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 104857599 51915776 8e Linux LVM
/dev/sda3 104857600 209715199 52428800 8e Linux LVM <<<<<<----New partition ##重启虚拟机识别新增分区
[root@tcentos79 ~]# vgdisplay
--- Volume group ---
VG Name centos
System ID
Format lvm2
...
----######备注:
[root@tcentos79 ~]#
给 /dev/mapper/centos-u01 扩展容量
pvcreate /dev/sda3
vgextend centos /dev/sda3 (扩展卷组)
lvextend -l +100%FREE /dev/mapper/centos-u01 /dev/sda3
xfs_growfs /dev/mapper/centos-u01 (同步到文件系统,xfs_growfs针对xfs文件系统;resize2fs 针对文件系统ext2 ext3 ext4:resize2fs /dev/mapper/centos-u01)
1.3、重启虚拟机识别新增分区 后 再执行如下操作
----###### ##重启虚拟机识别新增分区 后 再执行如下操作
[root@tcentos79 ~]# pvcreate /dev/sda3
Physical volume "/dev/sda3" successfully created.
[root@tprocessproj ~]# vgextend centos /dev/sda3
Volume group "centos" successfully extended
[root@tcentos79 ~]# lvextend -l +100%FREE /dev/mapper/centos-u01 /dev/sda3
Size of logical volume centos/u01 changed from 2.00 GiB (512 extents) to <52.00 GiB (13311 extents).
Logical volume centos/u01 successfully resized.
[root@tcentos79 ~]# xfs_growfs /dev/mapper/centos-u01
meta-data=/dev/mapper/centos-u01 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 13630464
[root@tcentos79 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 7.8G 0 7.8G 0% /dev
tmpfs 7.8G 0 7.8G 0% /dev/shm
tmpfs 7.8G 9.5M 7.8G 1% /run
tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup
/dev/mapper/centos-root 32G 6.1G 26G 20% /
/dev/sda1 497M 179M 318M 37% /boot
/dev/mapper/centos-u01 52G 37M 52G 1% /u01
tmpfs 1.6G 8.0K 1.6G 1% /run/user/42
tmpfs 1.6G 0 1.6G 0% /run/user/0
[root@tcentos79 ~]#
2、新建卷组新建逻辑卷
fdisk /dev/sdd
pvcreate /dev/sdd1
vgcreate vg_databak /dev/sdd1
lvcreate -n data -L 9G vg_databak (创建逻辑卷)
mkfs -t xfs -f /dev/mapper/vg_databak-data (分区上建立文件系统)
mount /dev/mapper/vg_databak-data /data
vim /etc/fstab
/dev/mapper/vg_databak-data /data xfs defaults 0 0
标签:mapper,逻辑,centos,扩展,dev,Centos7.9,7.8,root,u01 From: https://www.cnblogs.com/lipeng20004/p/17846562.html