CentOS 7.6在线扩容xfs文件系统(创建大于2T的磁盘分区并使用LVM管理)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS 7.6在线扩容xfs文件系统(创建大于2T的磁盘分区并使用LVM管理)相关的知识,希望对你有一定的参考价值。
1. 使用parted方式格式化磁盘
1.1 查看磁盘情况
[root@jylhlog2 ~]# fdisk -l
Disk /dev/sdd: 2199.0 GB, 2199023255552 bytes, 4294967296 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/sdb: 42.9 GB, 42949672960 bytes, 83886080 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: 2199.0 GB, 2199023255552 bytes, 4294967296 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/sde: 2199.0 GB, 2199023255552 bytes, 4294967296 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/sdf: 2199.0 GB, 2199023255552 bytes, 4294967296 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/sda: 536.9 GB, 536870912000 bytes, 1048576000 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: 0x0008ce60
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 1048567807 523234304 8e Linux LVM
Disk /dev/mapper/vg_root-lv_root: 64.4 GB, 64424509440 bytes, 125829120 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/mapper/vg_root-lv_swap: 68.7 GB, 68719476736 bytes, 134217728 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/mapper/vg_root-lv_data: 209.4 GB, 209371267072 bytes, 408928256 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/mapper/vg_root-lv_home: 64.4 GB, 64424509440 bytes, 125829120 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/mapper/vg_root-oracle: 64.4 GB, 64424509440 bytes, 125829120 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/mapper/vg_root-lv_grid: 64.4 GB, 64424509440 bytes, 125829120 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/sdg: 2199.0 GB, 2199023255552 bytes, 4294967296 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@jylhlog2 ~]#
1.2 使用parted格式化/dev/sdg分区
[root@jylhlog2 ~]# parted /dev/sdg
GNU Parted 3.1
Using /dev/sdg
Welcome to GNU Parted! Type ‘help‘ to view a list of commands.
(parted) mklabel gpt ------将MBR分区形式转为GPT分区形式
(parted) mkpart primary xfs 0 -1 ------设置分区的开始位置和结束位置
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? Ignore
(parted) print ------查看分区
Model: VMware Virtual disk (scsi)
Disk /dev/sdg: 2199GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 17.4kB 2199GB 2199GB primary
(parted) toggle 1 lvm ------使用toggle 更改硬盘类型
(parted) print ------查看分区
Model: VMware Virtual disk (scsi)
Disk /dev/sdg: 2199GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 17.4kB 2199GB 2199GB primary lvm
(parted) quit
Information: You may need to update /etc/fstab.
[root@jylhlog2 ~]#
1.3 查看格式化后的分区情况
[root@jylhlog2 ~]# fdisk -l
Disk /dev/sdd: 2199.0 GB, 2199023255552 bytes, 4294967296 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/sdb: 42.9 GB, 42949672960 bytes, 83886080 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: 2199.0 GB, 2199023255552 bytes, 4294967296 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/sde: 2199.0 GB, 2199023255552 bytes, 4294967296 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/sdf: 2199.0 GB, 2199023255552 bytes, 4294967296 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/sda: 536.9 GB, 536870912000 bytes, 1048576000 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: 0x0008ce60
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 1048567807 523234304 8e Linux LVM
Disk /dev/mapper/vg_root-lv_root: 64.4 GB, 64424509440 bytes, 125829120 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/mapper/vg_root-lv_swap: 68.7 GB, 68719476736 bytes, 134217728 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/mapper/vg_root-lv_data: 209.4 GB, 209371267072 bytes, 408928256 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/mapper/vg_root-lv_home: 64.4 GB, 64424509440 bytes, 125829120 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/mapper/vg_root-oracle: 64.4 GB, 64424509440 bytes, 125829120 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/mapper/vg_root-lv_grid: 64.4 GB, 64424509440 bytes, 125829120 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
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Disk /dev/sdg: 2199.0 GB, 2199023255552 bytes, 4294967296 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: gpt
Disk identifier: 9C5E039C-2C6C-4585-8EAB-7B2DBA949516
# Start End Size Type Name
1 34 4294965343 2T Linux LVM primary
[root@jylhlog2 ~]#
1.4 使系统重读分区表
[root@jylhlog2 ~]# partprobe
Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only.
[root@jylhlog2 ~]#
[root@jylhlog2 ~]# fdisk -l
Disk /dev/sdd: 2199.0 GB, 2199023255552 bytes, 4294967296 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/sdb: 42.9 GB, 42949672960 bytes, 83886080 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: 2199.0 GB, 2199023255552 bytes, 4294967296 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/sde: 2199.0 GB, 2199023255552 bytes, 4294967296 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/sdf: 2199.0 GB, 2199023255552 bytes, 4294967296 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/sda: 536.9 GB, 536870912000 bytes, 1048576000 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: 0x0008ce60
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 1048567807 523234304 8e Linux LVM
Disk /dev/mapper/vg_root-lv_root: 64.4 GB, 64424509440 bytes, 125829120 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/mapper/vg_root-lv_swap: 68.7 GB, 68719476736 bytes, 134217728 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/mapper/vg_root-lv_data: 209.4 GB, 209371267072 bytes, 408928256 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/mapper/vg_root-lv_home: 64.4 GB, 64424509440 bytes, 125829120 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/mapper/vg_root-oracle: 64.4 GB, 64424509440 bytes, 125829120 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/mapper/vg_root-lv_grid: 64.4 GB, 64424509440 bytes, 125829120 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
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Disk /dev/sdg: 2199.0 GB, 2199023255552 bytes, 4294967296 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: gpt
Disk identifier: 9C5E039C-2C6C-4585-8EAB-7B2DBA949516
# Start End Size Type Name
1 34 4294965343 2T Linux LVM primary
[root@jylhlog2 ~]#
2 创建pv、扩容vg、扩容lv、扩容xfs分区
2.1 查看目前分区情况
[root@jylhlog2 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_root-lv_root 60G 6.2G 54G 11% /
devtmpfs 63G 0 63G 0% /dev
tmpfs 63G 640M 63G 1% /dev/shm
tmpfs 63G 32M 63G 1% /run
tmpfs 63G 0 63G 0% /sys/fs/cgroup
/dev/sda1 1014M 179M 836M 18% /boot
/dev/mapper/vg_root-lv_grid 60G 40G 21G 66% /grid
/dev/mapper/vg_root-lv_data 195G 595M 195G 1% /data
/dev/mapper/vg_root-oracle 60G 22G 38G 37% /oracle
/dev/mapper/vg_root-lv_home 60G 16G 45G 27% /home
tmpfs 13G 12K 13G 1% /run/user/42
tmpfs 13G 0 13G 0% /run/user/1000
[root@jylhlog2 ~]#
2.2 查看目前lv情况
[root@jylhlog2 ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
lv_data vg_root -wi-ao---- 194.99g
lv_grid vg_root -wi-ao---- 60.00g
lv_home vg_root -wi-ao---- 60.00g
lv_root vg_root -wi-ao---- 60.00g
lv_swap vg_root -wi-ao---- 64.00g
oracle vg_root -wi-ao---- 60.00g
[root@jylhlog2 ~]#
2.3 查看目前vg情况
[root@jylhlog2 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg_root 1 6 0 wz--n- 498.99g 0
[root@jylhlog2 ~]#
2.4 创建pv
[root@jylhlog2 ~]# pvcreate /dev/sdg1
Physical volume "/dev/sdg1" successfully created.
[root@jylhlog2 ~]#
2.5 扩容vg
[root@jylhlog2 ~]# vgextend vg_root /dev/sdg1
Volume group "vg_root" successfully extended
[root@jylhlog2 ~]#
2.6 查看vg扩容情况
[root@jylhlog2 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg_root 2 6 0 wz--n- <2.49t <2.00t
[root@jylhlog2 ~]#
2.7 查看扩容后vg大小情况
[root@jylhlog2 ~]# vgdisplay
--- Volume group ---
VG Name vg_root
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 8
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 6
Open LV 6
Max PV 0
Cur PV 2
Act PV 2
VG Size <2.49 TiB
PE Size 4.00 MiB
Total PE 652029
Alloc PE / Size 127742 / 498.99 GiB
Free PE / Size 524287 / <2.00 TiB
VG UUID bV0qQR-Vhfg-ynTF-dbza-qJD1-ao3k-l02WiP
[root@jylhlog2 ~]#
2.8 扩容lv
[root@jylhlog2 ~]# lvextend -L +2097148M /dev/mapper/vg_root-lv_data
Size of logical volume vg_root/lv_data changed from 194.99 GiB (49918 extents) to 2.19 TiB (574205 extents).
Logical volume vg_root/lv_data successfully resized.
[root@jylhlog2 ~]#
2.9 查看容量变化,发现文件系统大小没有变化
[root@jylhlog2 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_root-lv_root 60G 6.2G 54G 11% /
devtmpfs 63G 0 63G 0% /dev
tmpfs 63G 640M 63G 1% /dev/shm
tmpfs 63G 32M 63G 1% /run
tmpfs 63G 0 63G 0% /sys/fs/cgroup
/dev/sda1 1014M 179M 836M 18% /boot
/dev/mapper/vg_root-lv_grid 60G 40G 21G 66% /grid
/dev/mapper/vg_root-lv_data 195G 595M 195G 1% /data
/dev/mapper/vg_root-oracle 60G 22G 38G 37% /oracle
/dev/mapper/vg_root-lv_home 60G 16G 45G 27% /home
tmpfs 13G 12K 13G 1% /run/user/42
tmpfs 13G 0 13G 0% /run/user/1000
[root@jylhlog2 ~]#
2.10 使用xfs_growfs同步磁盘信息
[root@jylhlog2 ~]# xfs_growfs /dev/mapper/vg_root-lv_data
meta-data=/dev/mapper/vg_root-lv_data isize=512 agcount=4, agsize=12779008 blks
? = sectsz=512 attr=2, projid32bit=1
? = crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=51116032, imaxpct=25
? = sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=24959, version=2
? = sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 51116032 to 587985920
[root@jylhlog2 ~]#
2.11 查看容量变化,发现文件系统已扩容成功
[root@jylhlog2 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_root-lv_root 60G 6.2G 54G 11% /
devtmpfs 63G 0 63G 0% /dev
tmpfs 63G 640M 63G 1% /dev/shm
tmpfs 63G 32M 63G 1% /run
tmpfs 63G 0 63G 0% /sys/fs/cgroup
/dev/sda1 1014M 179M 836M 18% /boot
/dev/mapper/vg_root-lv_grid 60G 40G 21G 66% /grid
/dev/mapper/vg_root-lv_data 2.2T 597M 2.2T 1% /data
/dev/mapper/vg_root-oracle 60G 22G 38G 37% /oracle
/dev/mapper/vg_root-lv_home 60G 16G 45G 27% /home
tmpfs 13G 12K 13G 1% /run/user/42
tmpfs 13G 0 13G 0% /run/user/1000
[root@jylhlog2 ~]#
以上是关于CentOS 7.6在线扩容xfs文件系统(创建大于2T的磁盘分区并使用LVM管理)的主要内容,如果未能解决你的问题,请参考以下文章