Linux系统/根分区扩容
背景
项目中遇到/分区不足需要扩容,需要对/分区进行扩容
查看主机挂载信息
查看当前挂载使用的磁盘信息
df -Th
使用fdisk –l
查看当前主机磁盘信息,给主机挂上多余的磁盘
通过 fdisk /dev/sdb
操作来分出一块分区/dev/sdb1,将磁盘修改成lvm
[root@localhost ~]# 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 0x680e669a.
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-209715199, default 2048):
Using default value 2048
Last sector, sectors or size{K,M,G} (2048-209715199, default 209715199):
Using default value 209715199
Partition 1 of type Linux and of size 100 GiB is set
Command (m for help): p
Disk /dev/sdb: 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: 0x680e669a
Device Boot Start End Blocks Id System
/dev/sdb1 2048 209715199 104856576 83 Linux
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): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
再次查看磁盘列表,发现磁盘/dev/sdb已经有了sdb1的分区
使用pvcreate /dev/sdb1
对新分区出来的磁盘创建物理卷
使用vgdisplay
命令查看当前主机的卷组
使用vgextend rhel /dev/sdb1
命令将新分区的sdb1加入到卷组rhel
扩容
当前主机/目录磁盘容量大小
使用lvextend -L 99G /dev/mapper/rhel-root
对/目录进行扩容
最后对文件系统进行扩容,不对文件系统进行扩容不会生效,使用resize2fs /dev/mapper/rhel-root
进行扩容
特别注意:文件格式是ext4使用resize2fs进行系统扩容,文件格式是xfs使用xfs_growfs /dev/mapper/rhel-root
验证
使用df –Th 进行查看当前主机的/目录发现以及扩容到108G
使用其他目录下的逻辑卷对/目录扩容
df –Th查看当前主机挂载情况,如图,使用/app下的逻辑卷对/目录进行扩容,在此请先确认所使用的卷组是否和/目录所使用的的卷组是否是同一个,如果不是同一个卷组,使用lvremove命令删除逻辑卷,然后在对/根目录对应的卷组扩容后。在参考下面操作。
卸载前请先对/app目录下的文件进行备份。
删除原/app逻辑卷
lvremove /dev/mapper/rhel-captcahlv
2) 扩容/逻辑卷
lvextend -L 98G /dev/mapper/rhel-root
最后扩大/根分区容量,操作命令参考扩容部分步骤。
验证
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /boutique/detail/tanhgebjfj
系列文章
更多
同类精品
更多
-
photoshop保存的图片太大微信发不了怎么办
PHP中文网 06-15 -
Android 11 保存文件到外部存储,并分享文件
Luke 10-12 -
《学习通》视频自动暂停处理方法
HelloWorld317 07-05 -
word里面弄一个表格后上面的标题会跑到下面怎么办
PHP中文网 06-20 -
photoshop扩展功能面板显示灰色怎么办
PHP中文网 06-14 -
微信公众号没有声音提示怎么办
PHP中文网 03-31 -
excel下划线不显示怎么办
PHP中文网 06-23 -
excel打印预览压线压字怎么办
PHP中文网 06-22 -
怎样阻止微信小程序自动打开
PHP中文网 06-13 -
TikTok加速器哪个好免费的TK加速器推荐
TK小达人 10-01