RHEL|如何扩展Liunx系统分区大小
作者:IT邦德
中国DBA联盟(ACDU)成员,目前从事DBA及程序编程
(Web\java\Python)工作,主要服务于生产制造
现拥有 Oracle 11gOCP/OCM、
Mysql、Oceanbase(OBCA)认证
分布式TBase\TDSQL数据库、国产达梦数据库以及红帽子认证
从业8年DBA工作,在数据库领域有丰富的经验
B站主播Oracle、Mysql、PG实战课程,请搜索:jeames007擅长Oracle数据库运维开发,备份恢复,安装迁移,性能优化、故障应急处理等。
文章图片
文章目录
- 前言
-
- 1.分区大小
- 2.裸盘划分
- 3.创建 PV
- 4.扩展逻辑卷
- 5.再次确认分区大小
前言 近日服务器的根目录快满了,仔细一查看使用的是逻辑卷,本文总结了以下扩展分区的方法, 本次扩展的是根分区 1.分区大小
[root@rhel76 ~]# df -Th
FilesystemTypeSizeUsed Avail Use% Mounted on
/dev/mapper/rhel-root xfs30G4.3G26G15% /
devtmpfsdevtmpfs2.0G02.0G0% /dev
tmpfstmpfs2.0G02.0G0% /dev/shm
tmpfstmpfs2.0G13M2.0G1% /run
tmpfstmpfs2.0G02.0G0% /sys/fs/cgroup
/dev/sda1xfs950M164M786M18% /boot
/dev/mapper/rhel-u01xfs28G33M28G1% /u01
tmpfstmpfs394M4.0K394M1% /run/user/42
tmpfstmpfs394M48K394M1% /run/user/0可以看出/分区已经明明显不足,需要扩展
文章图片
2.裸盘划分
[root@rhel76 ~]# ll /dev/sd*
brw-rw----. 1 root disk 8,0 Nov 28 23:34 /dev/sda
brw-rw----. 1 root disk 8,1 Nov 28 23:34 /dev/sda1
brw-rw----. 1 root disk 8,2 Nov 28 23:34 /dev/sda2
brw-rw----. 1 root disk 8, 16 Nov 28 23:34 /dev/sdb
文章图片
[root@rhel76 ~]# fdisk /dev/sdb
[root@rhel76 ~]# fdisk /dev/sdb
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 0xa1773dc6.Command (m for help): n
Partition type:
pprimary (0 primary, 0 extended, 4 free)
eextended
Select (default p):
Using default response p
Partition number (1-4, default 1): 1
First sector (2048-41943039, default 2048):
Using default value 2048
Last sector, +sectors or +size{
K,M,G} (2048-41943039, default 41943039):
Using default value 41943039
Partition 1 of type Linux and of size 20 GiB is setCommand (m for help): w
The partition table has been altered!Calling ioctl() to re-read partition table.[root@rhel76 ~]# ll /dev/sd*
brw-rw----. 1 root disk 8,0 Nov 28 23:34 /dev/sda
brw-rw----. 1 root disk 8,1 Nov 28 23:34 /dev/sda1
brw-rw----. 1 root disk 8,2 Nov 28 23:34 /dev/sda2
brw-rw----. 1 root disk 8, 16 Nov 28 23:49 /dev/sdb
brw-rw----. 1 root disk 8, 17 Nov 28 23:49 /dev/sdb1[root@rhel76 ~]# fdisk -l | grep dev
Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
/dev/sdb12048419430392097049683Linux
Disk /dev/sda: 64.4 GB, 64424509440 bytes, 125829120 sectors
/dev/sda1*2048195379197587283Linux
/dev/sda21953792125829119619376648eLinux LVM
Disk /dev/mapper/rhel-root: 31.4 GB, 31415336960 bytes, 61358080 sectors
Disk /dev/mapper/rhel-swap: 2000 MB, 2000683008 bytes, 3907584 sectors
Disk /dev/mapper/rhel-u01: 30.0 GB, 30001856512 bytes, 58597376 sectors
文章图片
3.创建 PV
[root@rhel76 ~]# pvs
PVVGFmtAttr PSizePFree
/dev/sda2rhel lvm2 a--<59.07g 4.00m[root@rhel76 ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created.[root@rhel76 ~]# pvs
PVVGFmtAttr PSizePFree
/dev/sda2rhel lvm2 a--<59.07g4.00m
/dev/sdb1lvm2 ---<20.00g <20.00g
4.扩展逻辑卷
[root@rhel76 ~]# vgs
VG#PV #LV #SN AttrVSizeVFree
rhel130 wz--n- <59.07g 4.00m[root@rhel76 ~]# vgextend rhel /dev/sdb1[root@rhel76 ~]# vgextend rhel /dev/sdb1
Volume group "rhel" successfully extended
[root@rhel76 ~]# vgs
VG#PV #LV #SN AttrVSizeVFree
rhel230 wz--n- 79.06g 20.00g[root@rhel76 ~]# vgs
VG#PV #LV #SN AttrVSizeVFree
jem_vg100 wz--n- <20.00g <20.00g
rhel130 wz--n- <59.07g4.00m[root@rhel76 ~]# lvdisplay
--- Logical volume ---
LV Path/dev/rhel/root
LV Nameroot
VG Namerhel
LV UUIDfB06rl-92CE-trM6-e2tM-pP4o-6SKt-p03lGC
LV Write Accessread/write
LV Creation host, time rhel76, 2021-06-26 22:04:57 +0000
LV Statusavailable
# open1
LV Size<29.26 GiB
Current LE7490
Segments1
Allocationinherit
Read ahead sectorsauto
- currently set to8192
Block device253:0[root@rhel76 ~]# lvs
LVVGAttrLSizePool Origin Data%Meta%Move Log Cpy%Sync Convert
root rhel -wi-ao---- <29.26g
swap rhel -wi-ao----1.86g
u01rhel -wi-ao----27.94g[root@rhel76 ~]# lvextend -L +18G /dev/rhel/root
Size of logical volume rhel/root changed from <29.26 GiB (7490 extents) to <47.26 GiB (12098 extents).
Logical volume rhel/root successfully resized.使用以下命令刷新lv
[root@rhel76 ~]# xfs_growfs /dev/rhel/root
meta-data=https://www.it610.com/dev/mapper/rhel-rootisize=512agcount=4, agsize=1917440 blks
=sectsz=512attr=2, projid32bit=1
=crc=1finobt=0 spinodes=0
data=bsize=4096blocks=7669760, imaxpct=25
=sunit=0swidth=0 blks
naming=version 2bsize=4096ascii-ci=0 ftype=1
log=internalbsize=4096blocks=3745, version=2
=sectsz=512sunit=0 blks, lazy-count=1
realtime =noneextsz=4096blocks=0, rtextents=0
data blocks changed from 7669760 to 12388352
5.再次确认分区大小
[root@rhel76 ~]# df -TH
FilesystemTypeSizeUsed Avail Use% Mounted on
/dev/mapper/rhel-root xfs51G4.4G47G9% /
devtmpfsdevtmpfs2.1G02.1G0% /dev
tmpfstmpfs2.1G02.1G0% /dev/shm
tmpfstmpfs2.1G14M2.1G1% /run
tmpfstmpfs2.1G02.1G0% /sys/fs/cgroup
/dev/sda1xfs996M172M825M18% /boot
/dev/mapper/rhel-u01xfs30G34M30G1% /u01
tmpfstmpfs413M4.1k413M1% /run/user/42
tmpfstmpfs413M54k413M1% /run/user/0
文章图片
很明显,/ 分区由原来的30G扩展到了51G
如果觉得文章对你有帮助,点赞、收藏、关注、评论,一键四连支持
您的批评指正是我写作的最大动力!
【RHEL|如何扩展Liunx系统分区大小】?? 技术交流可以 关注公众号:IT邦德 ??
推荐阅读
- 考研英语阅读终极解决方案——阅读理解如何巧拿高分
- 如何寻找情感问答App的分析切入点
- mybatisplus如何在xml的连表查询中使用queryWrapper
- MybatisPlus使用queryWrapper如何实现复杂查询
- 如何在Mac中的文件选择框中打开系统隐藏文件夹
- 漫画初学者如何学习漫画背景的透视画法(这篇教程请收藏好了!)
- java中如何实现重建二叉树
- Linux下面如何查看tomcat已经使用多少线程
- thinkphp|thinkphp 3.2 如何调用第三方类库
- 2019女表什么牌子好(如何挑选女士手表?)