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
相关文章
|
1月前
|
Ubuntu Linux Shell
Linux系统中如何查看磁盘情况
【9月更文挑战第3天】在Linux系统中,有多种方式查看磁盘情况。可通过命令行工具`df`查看文件系统磁盘使用情况,选项`-h`以人类可读格式显示,`-T`显示文件系统类型;`du`命令显示目录或文件磁盘使用情况,`-h`以人类可读格式显示,`-s`仅显示总计;`fdisk -l`列出磁盘和分区信息。此外,图形界面的磁盘管理工具和文件管理器也可用于查看磁盘使用情况。这些方法有助于更好地管理磁盘空间。
|
2月前
|
存储 监控 安全
在Linux中,⼀个EXT3的文件分区,当使用touch test.file命令创建⼀个新文件时报错,报错的信息是提示磁盘已满,但是采用df -h命令查看磁盘大小时,只使用了,60%的磁盘空间,为什么会出现这个情况?
在Linux中,⼀个EXT3的文件分区,当使用touch test.file命令创建⼀个新文件时报错,报错的信息是提示磁盘已满,但是采用df -h命令查看磁盘大小时,只使用了,60%的磁盘空间,为什么会出现这个情况?
|
8天前
|
存储 Linux 5G
Linux 基于 LVM 逻辑卷的磁盘管理【简明教程】
这篇文章介绍了LVM(逻辑卷管理)如何提供灵活的磁盘管理方式,允许动态调整逻辑卷的大小而不会丢失数据。
Linux 基于 LVM 逻辑卷的磁盘管理【简明教程】
|
2月前
|
存储 监控 Linux
|
2月前
|
存储 Linux
在Linux中,LVM是什么?
在Linux中,LVM是什么?
|
2月前
|
Prometheus 监控 Ubuntu
在Linux中,如何进行磁盘性能监控?
在Linux中,如何进行磁盘性能监控?
|
2月前
|
存储 Linux 5G
linux操作系统初始化后,再也不用手动分区了
linux操作系统初始化后,再也不用手动分区了
28 0
|
2月前
|
监控 Shell Linux
在Linux中,如何使用shell脚本检测磁盘使用率?
在Linux中,如何使用shell脚本检测磁盘使用率?
|
2月前
|
存储 监控 Linux
在Linux中,如何使用LVM管理逻辑卷?
在Linux中,如何使用LVM管理逻辑卷?
|
2月前
|
存储 数据挖掘 Linux
在Linux中,LVM(逻辑卷管理)的主要优势是什么?如何扩展LVM卷?
在Linux中,LVM(逻辑卷管理)的主要优势是什么?如何扩展LVM卷?
下一篇
无影云桌面