linux 根分区磁盘 LVM 拉升(磁盘扩容)

简介: linux 根分区磁盘 LVM 拉升(磁盘扩容)
[root@zabbix-mariadb ~]# df -h
Filesystem Size Used Avail Use% Mounted on
'/dev/mapper/centos-root 36G 14G 23G 37% / #待扩容的分区'
devtmpfs 7.8G 0 7.8G 0% /dev
tmpfs 7.8G 0 7.8G 0% /dev/shm
tmpfs 7.8G 561M 7.3G 8% /run
tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup
/dev/vda1 497M 126M 371M 26% /boot
tmpfs 1.6G 0 1.6G 0% /run/user/0
tmpfs 7.8G 0 7.8G 0% /tmp
[root@zabbix-mariadb ~]# fdisk -l
Disk /dev/vda: 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: 0x0004c100
 Device Boot Start End Blocks Id System
/dev/vda1 * 2048 1026047 512000 83 Linux
/dev/vda2 1026048 83886079 41430016 8e Linux LVM
Disk /dev/mapper/centos-root: 38.2 GB, 38214303744 bytes, 74637312 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/centos-swap: 4160 MB, 4160749568 bytes, 8126464 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
'(已添加的 300G 盘,待扩容)
Disk /dev/vdb: 322.1 GB, 322122547200 bytes, 629145600 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@zabbix-mariadb ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 1024M 0 rom 
vda 252:0 0 100G 0 disk 
├─vda1 252:1 0 500M 0 part /boot
└─vda2 252:2 0 39.5G 0 part 
 ├─centos-root 253:0 0 35.6G 0 lvm /
 └─centos-swap 253:1 0 3.9G 0 lvm [SWAP]
'vdb 252:16 0 300G 0 disk '
[root@zabbix-mariadb ~]# fdisk /dev/vdb
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 0x193b6c2b.
Command (m for help): n
Partition type:
 p primary (0 primary, 0 extended, 4 free)
 e extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-629145599, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-629145599, default 629145599): 
Using default value 629145599
Partition 1 of type Linux and of size 300 GiB is set
Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): p
Disk /dev/vdb: 322.1 GB, 322122547200 bytes, 629145600 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: 0x193b6c2b
 Device Boot Start End Blocks Id System
/dev/vdb1 2048 629145599 314571776 8e Linux LVM
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@zabbix-mariadb ~]# pvcreate /dev/vdb1
Physical volume "/dev/vdb1" successfully created
[root@zabbix-mariadb ~]# vgdisplay 
--- Volume group ---
' VG Name centos #记住该 VG Name'
 System ID 
 Format lvm2
 Metadata Areas 1
 Metadata Sequence No 3
 VG Access read/write
 VG Status resizable
 MAX LV 0
 Cur LV 2
 Open LV 2
 Max PV 0
 Cur PV 1
 Act PV 1
 VG Size 39.51 GiB
 PE Size 4.00 MiB
 Total PE 10114
 Alloc PE / Size 10103 / 39.46 GiB
 Free PE / Size 11 / 44.00 MiB
 VG UUID 9l3Np0-jm8N-IbfG-7Gm8-n62e-ICTn-kZy2Ux
[root@zabbix-mariadb ~]# vgextend centos /dev/vdb1 #centos 为查询信息的 VG Name
 Volume group "centos" successfully extended
[root@zabbix-mariadb ~]# pvscan
 PV /dev/vda2 VG centos lvm2 [39.51 GiB / 44.00 MiB free]
 PV /dev/vdb1 VG centos lvm2 [300.00 GiB / 300.00 GiB free]
 Total: 2 [339.50 GiB] / in use: 2 [339.50 GiB] / in no VG: 0 [0 ]
[root@zabbix-mariadb ~]# lvdisplay 
 --- Logical volume ---
 LV Path /dev/centos/swap
 LV Name swap
 VG Name centos
 LV UUID SOiDoo-oAey-fgAo-6m9E-4H12-gPb5-05iMZ0
 LV Write Access read/write
 LV Creation host, time localhost, 2017-10-30 12:32:56 +0800
 LV Status available
 # open 2
 LV Size 3.88 GiB
 Current LE 992
 Segments 1
 Allocation inherit
 Read ahead sectors auto
 - currently set to 8192
 Block device 253:1
 --- Logical volume ---
 LV Path /dev/centos/root
 LV Name root
 VG Name centos
 LV UUID jG0H1b-tNnQ-Utai-JYsW-W9JS-vNH5-dfEZWJ
 LV Write Access read/write
 LV Creation host, time localhost, 2017-10-30 12:32:56 +0800
 LV Status available
 # open 1
 LV Size 35.59 GiB
 Current LE 9111
 Segments 1
 Allocation inherit
 Read ahead sectors auto
 - currently set to 8192
 Block device 253:0
[root@zabbix-mariadb ~]# lvextend /dev/centos/root /dev/vdb1 
Size of logical volume centos/root changed from 35.59 GiB (9111 extents) to 335.59 GiB 
(85910 extents).
 Logical volume root successfully resized
[root@zabbix-mariadb ~]# cat /etc/fstab 
# /etc/fstab
# Created by anaconda on Mon Oct 30 12:32:57 2017
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root / xfs defaults 0 0
UUID=1cedfb5c-6866-413c-b217-ea94143ec03e /boot xfs 
defaults 0 0
/dev/mapper/centos-swap swap swap defaults 0 0
'检查主机目标扩容分区的文件系统类型是 xfs,所以格式化文件系统使用 xfs_growfs'
[root@zabbix-mariadb ~]# xfs_growfs /dev/centos/root 
meta-data=/dev/mapper/centos-root isize=256 agcount=4, agsize=2332416 blks
 = sectsz=512 attr=2, projid32bit=1
 = crc=0 finobt=0
data = bsize=4096 blocks=9329664, imaxpct=25
 = sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal bsize=4096 blocks=4555, version=2
 = sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 9329664 to 87971840
[root@zabbix-mariadb ~]# df -h ##添加成功
Filesystem Size Used Avail Use% Mounted on
'/dev/mapper/centos-root 336G 14G 323G 4% /'
devtmpfs 7.8G 0 7.8G 0% /dev
tmpfs 7.8G 0 7.8G 0% /dev/shm
tmpfs 7.8G 561M 7.3G 8% /run
tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup
/dev/vda1 497M 126M 371M 26% /boot
tmpfs 1.6G 0 1.6G 0% /run/user/0
tmpfs 7.8G 0 7.8G 0% /tmp
相关文章
|
28天前
|
Linux Shell C语言
【Shell 命令集合 磁盘维护 】Linux 分区管理的工具 sfdisk命令使用教程
【Shell 命令集合 磁盘维护 】Linux 分区管理的工具 sfdisk命令使用教程
29 1
|
28天前
|
存储 Shell Linux
【Shell 命令集合 磁盘维护 】Linux 管理硬盘分区 mpartition命令使用教程
【Shell 命令集合 磁盘维护 】Linux 管理硬盘分区 mpartition命令使用教程
36 1
|
28天前
|
Shell Linux API
【Shell 命令集合 磁盘维护 】Linux 查找指定目录下的所有符号链接文件 symlinks 命令使用教程
【Shell 命令集合 磁盘维护 】Linux 查找指定目录下的所有符号链接文件 symlinks 命令使用教程
31 1
|
28天前
|
监控 Linux Shell
【Shell 命令集合 磁盘维护 】Linux 交换分区的特殊文件或设备 swapon命令使用指南
【Shell 命令集合 磁盘维护 】Linux 交换分区的特殊文件或设备 swapon命令使用指南
35 1
|
28天前
|
存储 Shell Linux
【Shell 命令集合 磁盘维护 】Linux 创建一个用作交换空间(swap space)的特殊文件或设备 mkswap命令使用教程
【Shell 命令集合 磁盘维护 】Linux 创建一个用作交换空间(swap space)的特殊文件或设备 mkswap命令使用教程
33 0
|
10天前
|
Linux
Linux操作系统调优相关工具(三)查看IO运行状态相关工具 查看哪个磁盘或分区最繁忙?
Linux操作系统调优相关工具(三)查看IO运行状态相关工具 查看哪个磁盘或分区最繁忙?
21 0
|
10天前
|
Linux 虚拟化
linux 虚拟机扩容--直接扩容到根目录
linux 虚拟机扩容--直接扩容到根目录
23 1
|
28天前
|
存储 缓存 Shell
【Shell 命令集合 磁盘维护 】⭐⭐⭐Linux 将文件系统的缓冲区数据立即写入磁盘 sync 命令使用教程
【Shell 命令集合 磁盘维护 】⭐⭐⭐Linux 将文件系统的缓冲区数据立即写入磁盘 sync 命令使用教程
37 1
|
28天前
|
存储 Linux Shell
【Shell 命令集合 磁盘维护 】Linux 关闭Linux系统中的交换空间 swapoff命令使用教程
【Shell 命令集合 磁盘维护 】Linux 关闭Linux系统中的交换空间 swapoff命令使用教程
29 1
|
28天前
|
存储 安全 Linux
【Shell 命令集合 磁盘维护 】Linux 在特定的分区上建立 linux 文件系统 mkfs命令使用教程
【Shell 命令集合 磁盘维护 】Linux 在特定的分区上建立 linux 文件系统 mkfs命令使用教程
25 0