如何扩展Linux系统分区大小
作者:IT邦德
中国DBA联盟(ACDU)成员,目前从事DBA及程序编程
(Web\java\Python)工作,主要服务于生产制造
现拥有 Oracle 11g OCP/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
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/rhel-root xfs 30G 4.3G 26G 15% /
devtmpfs devtmpfs 2.0G 0 2.0G 0% /dev
tmpfs tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs tmpfs 2.0G 13M 2.0G 1% /run
tmpfs tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/sda1 xfs 950M 164M 786M 18% /boot
/dev/mapper/rhel-u01 xfs 28G 33M 28G 1% /u01
tmpfs tmpfs 394M 4.0K 394M 1% /run/user/42
tmpfs tmpfs 394M 48K 394M 1% /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:p primary (0 primary, 0 extended, 4 free)e extended
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/sdb1 2048 41943039 20970496 83 Linux
Disk /dev/sda: 64.4 GB, 64424509440 bytes, 125829120 sectors
/dev/sda1 * 2048 1953791 975872 83 Linux
/dev/sda2 1953792 125829119 61937664 8e Linux 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 ~]# pvsPV VG Fmt Attr PSize PFree/dev/sda2 rhel lvm2 a-- <59.07g 4.00m[root@rhel76 ~]# pvcreate /dev/sdb1Physical volume "/dev/sdb1" successfully created.[root@rhel76 ~]# pvsPV VG Fmt Attr PSize PFree /dev/sda2 rhel lvm2 a-- <59.07g 4.00m/dev/sdb1 lvm2 --- <20.00g <20.00g
4.扩展逻辑卷
[root@rhel76 ~]# vgsVG #PV #LV #SN Attr VSize VFreerhel 1 3 0 wz--n- <59.07g 4.00m[root@rhel76 ~]# vgextend rhel /dev/sdb1[root@rhel76 ~]# vgextend rhel /dev/sdb1Volume group "rhel" successfully extended
[root@rhel76 ~]# vgsVG #PV #LV #SN Attr VSize VFree rhel 2 3 0 wz--n- 79.06g 20.00g[root@rhel76 ~]# vgsVG #PV #LV #SN Attr VSize VFree jem_vg 1 0 0 wz--n- <20.00g <20.00grhel 1 3 0 wz--n- <59.07g 4.00m[root@rhel76 ~]# lvdisplay--- Logical volume ---LV Path /dev/rhel/rootLV Name rootVG Name rhelLV UUID fB06rl-92CE-trM6-e2tM-pP4o-6SKt-p03lGCLV Write Access read/writeLV Creation host, time rhel76, 2021-06-26 22:04:57 +0000LV Status available# open 1LV Size <29.26 GiBCurrent LE 7490Segments 1Allocation inheritRead ahead sectors auto- currently set to 8192Block device 253:0[root@rhel76 ~]# lvsLV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convertroot rhel -wi-ao---- <29.26g swap rhel -wi-ao---- 1.86g u01 rhel -wi-ao---- 27.94g [root@rhel76 ~]# lvextend -L +18G /dev/rhel/rootSize 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=/dev/mapper/rhel-root isize=512 agcount=4, agsize=1917440 blks= sectsz=512 attr=2, projid32bit=1= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=7669760, imaxpct=25= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=3745, version=2= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 7669760 to 12388352
5.再次确认分区大小
[root@rhel76 ~]# df -TH
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/rhel-root xfs 51G 4.4G 47G 9% /
devtmpfs devtmpfs 2.1G 0 2.1G 0% /dev
tmpfs tmpfs 2.1G 0 2.1G 0% /dev/shm
tmpfs tmpfs 2.1G 14M 2.1G 1% /run
tmpfs tmpfs 2.1G 0 2.1G 0% /sys/fs/cgroup
/dev/sda1 xfs 996M 172M 825M 18% /boot
/dev/mapper/rhel-u01 xfs 30G 34M 30G 1% /u01
tmpfs tmpfs 413M 4.1k 413M 1% /run/user/42
tmpfs tmpfs 413M 54k 413M 1% /run/user/0
很明显,/ 分区由原来的30G扩展到了51G
如果觉得文章对你有帮助,点赞、收藏、关注、评论,一键四连支持
您的批评指正是我写作的最大动力!
❤️ 技术交流可以 关注公众号:IT邦德 ❤️
如何扩展Linux系统分区大小相关推荐
- 在对linux系统分区进行格式化时需要对磁盘簇(或i节点密度)的大小进行选择,请说明选择的原则。
在对linux系统分区进行格式化时需要对磁盘簇(或i节点密度)的大小进行选择,请说明选择的原则. 参考答案: 磁盘簇(或i节点密度)是文件系统调度文件的基本单元.磁盘簇的大小,直接影响系统调度磁盘空间 ...
- Linux系统分区及LVM使用(一)
一.MBR分区 使用fdisk等分区工具,使用MBR(Master Boot Record)管理单个磁盘,这就决定了其分区表最多支持4个分区,分区类型包括主分区和扩展分区,逻辑分区可以被再次分割成多个 ...
- Linux系统分区和挂载浅谈
好久没有写BLOG了,之前出差了2个月,都没怎么看书,也没有太多时间写.回来后一个月人也有点放松.现在开始还是得继续努力啊.不废话了,下面就介绍下Linux系统的分区和挂载 一 Linux的安装 Li ...
- linux系统分区不,其中,不属于Linux系统分区的是()。
在Linux中,分区分为主分区.扩展分区和逻辑分区,使用fdisk-1命令获得分区信息如下所示: Disk/dev/hda: 240 heads, 63 sectors, 1940 cylinders ...
- linux分区方案 500g,linux系统分区建议
linux系统分区建议 linux系统中对于怎么分区现在做一个小的经验总结. 可以大致把服务器用途分为三类:虚拟空间服务器.大型系统服务器.常规服务器. 由于这三种服务器的主要应用场景和功能不同所以针 ...
- linux系统分区方案:
linux系统分区方案: 1.通用分区方案 c盘==/boot 引导分区(200M) swap 交互分区 当内存不够用时候,将硬盘中的空间当内存使用 内存<8G 建议交互分区的大小=内存大小的1 ...
- linux系统分区扩展,linux系统扩展根分区容量大小
#查看新增加的磁盘 [root@centos002 ~]# fdisk -l Disk /dev/sda: 21.5 GB, 21474836480 bytes 255 heads, 63 secto ...
- win10和linux双系统分区大小,win10与Linux双系统分区问题
安装参考(我用的linuxmint): 1.准备 linuxmint启动盘启动电脑,进入linuxlive 用usb image write把下载的镜像写入u盘 打开gparted,调整分区,分出一个 ...
- linux+swap分区规则_扩展Linux swap分区 两种方法
先来查询一下系统的swap [root@localhost ~]# free -m total used free shared buffers cached Mem: 375 369 6 0 7 8 ...
最新文章
- 万能门店小程序_门店小程序起名如何快速引流?
- 掘金翻译计划,翻译掘金上优质的英文文章
- JAVA学习篇--Servlet详解
- android:textAppearance设置文字外观
- load和pageshow的区别
- java设计模式之单例模式(七种方法)
- 657. 机器人能否返回原点
- 职责链模式(Chain of Responsibility Pattern)
- 漫画家Neal Adams推出以蝙蝠侠等超级英雄为主题的NFT
- python调用excel的宏_Python – 运行Excel宏
- string类用法Java_Java中String类的用法
- JDBC学习笔记(2)---B站尚硅谷宋红康
- CVE和NVD的关系
- python max函数_python的max函数的用法
- 【性能定位】使用jstack定位线程堆栈信息
- 深度学习方法(五):卷积神经网络CNN经典模型整理Lenet,Alexnet,Googlenet,VGG,Deep Residual Learning...
- IDEA如何进行远程Debug
- oracle rownum left join,SQL常用指令集(Oracle)
- 计算机硬件毛利率是多少,毛利率
- 最佳sd卡恢复数据软件/sd卡恢复照片软件