LearnHub

  • 首页
  • 科学上网
  • 网络相关
  • 谷歌相关
  • 实用工具
  • 在线视频
  • 搭建工具
  • 新闻快讯
  • 原创类
  • 教程类
Kratos
专注于用户阅读体验的响应式博客主题
  1. 首页
  2. 教程类
  3. 正文

【CentOS】CentOS8.1 系统盘/根目录扩容方法等内容

2023年 10月 12日 10次阅读 0人点赞 0条评论

基本概念
PV(Physical Volume)- 物理卷
物理卷在逻辑卷管理中处于最底层,它可以是实际物理硬盘上的分区,也可以是整个物理硬盘,也可以是raid设备。

VG(Volumne Group)- 卷组
卷组建立在物理卷之上,一个卷组中至少要包括一个物理卷,在卷组建立之后可动态添加物理卷到卷组中。一个逻辑卷管理系统工程中可以只有一个卷组,也可以拥有多个卷组。

LV(Logical Volume)- 逻辑卷
逻辑卷建立在卷组之上,卷组中的未分配空间可以用于建立新的逻辑卷,逻辑卷建立后可以动态地扩展和缩小空间。系统中的多个逻辑卷可以属于同一个卷组,也可以属于不同的多个卷组。

CentOS8.1 中文语言改为英文语言

#vim /etc/locale.conf  

LANG="zh_CN.UTF-8"
修改为           
LANG=en_US.UTF-8
#reboot


重启动生效

CentOS8.1 图像化启动改为字符多用户


[root@centos8 etc]# more  inittab 
# inittab is no longer used.
#
# ADDING CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# Ctrl-Alt-Delete is handled by /usr/lib/systemd/system/ctrl-alt-del.target
#
# systemd uses 'targets' instead of runlevels. By default, there are two main targets:
#
# multi-user.target: analogous to runlevel 3
# graphical.target: analogous to runlevel 5
#
# To view current default target, run:
# systemctl get-default
#
# To set a default target, run:
# systemctl set-default TARGET.target
[root@centos8 etc]# systemctl set-default multi-user.target
Removed /etc/systemd/system/default.target.
Created symlink /etc/systemd/system/default.target → /usr/lib/systemd/system/multi-user.target.
[root@centos8 etc]# reboot

重启动生效

CentOS8.1 系统盘/根目录扩容

1. 查看磁盘大小及剩余空间



[root@centos8 ~]# df -Th
Filesystem          Type      Size  Used Avail Use% Mounted on
devtmpfs            devtmpfs  7.8G     0  7.8G   0% /dev
tmpfs               tmpfs     7.8G     0  7.8G   0% /dev/shm
tmpfs               tmpfs     7.8G  8.9M  7.8G   1% /run
tmpfs               tmpfs     7.8G     0  7.8G   0% /sys/fs/cgroup
/dev/mapper/cl-root xfs       8.0G  4.1G  3.9G  52% /
/dev/vda1           ext4      976M  143M  766M  16% /boot
tmpfs               tmpfs     1.6G  4.0K  1.6G   1% /run/user/0

  1. 查看硬盘数量和分区情况
[root@centos8 ~]# fdisk -l
Disk /dev/vda: 540 GiB, 579820584960 bytes, 1132462080 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
Disklabel type: dos
Disk identifier: 0x1cdf0571

Device     Boot   Start      End  Sectors Size Id Type
/dev/vda1  *       2048  2099199  2097152   1G 83 Linux
/dev/vda2       2099200 20971519 18872320   9G 8e Linux LVM

Disk /dev/mapper/cl-root: 8 GiB, 8585740288 bytes, 16769024 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/cl-swap: 1 GiB, 1073741824 bytes, 2097152 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@centos8 ~]# fdisk /dev/vda
Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): n
Partition type
   p   primary (2 primary, 0 extended, 2 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (3,4, default 3): 
First sector (20971520-1132462079, default 20971520): 
Last sector, +sectors or +size{K,M,G,T,P} (20971520-1132462079, default 1132462079): +42GB

Created a new partition 3 of type 'Linux' and of size 39.1 GiB.

Command (m for help): P
P: unknown command

Command (m for help): p

Disk /dev/vda: 540 GiB, 579820584960 bytes, 1132462080 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
Disklabel type: dos
Disk identifier: 0x1cdf0571

Device     Boot    Start       End  Sectors  Size Id Type
/dev/vda1  *        2048   2099199  2097152    1G 83 Linux
/dev/vda2        2099200  20971519 18872320    9G 8e Linux LVM
/dev/vda3       20971520 103002111 82030592 39.1G 83 Linux

Command (m for help): w
The partition table has been altered.
Syncing disks.

4. 将磁盘分区表变化信息通知内核,系统重新加载分区表

[root@centos8 ~]# partprobe -s
/dev/vda: msdos partitions 1 2 3

5. 创建物理卷

[root@centos8 ~]# pvcreate /dev/vda3
  Physical volume "/dev/vda3" successfully created.

6. 查看lvm卷

[root@centos8 ~]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/vda2
  VG Name               cl
  PV Size               <9.00 GiB / not usable 3.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              2303
  Free PE               0
  Allocated PE          2303
  PV UUID               bJ39om-je2X-7eVI-99cr-ieNt-Qlkm-LfqOBM
   
  "/dev/vda3" is a new physical volume of "<39.12 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/vda3
  VG Name               
  PV Size               <39.12 GiB
  Allocatable           NO
  PE Size               0   
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               fhAswC-ab3g-qgdN-5hoW-iIFE-rzKI-FFg9GC

7. 查看卷组 ,卷组名为 “cl”(有的系统默认为“centos”,注意修改)

vgdisplay

8. 将新卷扩展进原有的“cl”卷组里

[root@centos8 ~]# vgextend cl /dev/vda3
  Volume group "cl" successfully extended

9. 扩展逻辑卷

[root@centos8 ~]# lvextend -l +100%free /dev/mapper/cl-root
  Size of logical volume cl/root changed from <8.00 GiB (2047 extents) to <47.11 GiB (12060 extents).
  Logical volume cl/root successfully resized.
### 查看逻辑卷文件系统类型 
[root@centos8 ~]# blkid /dev/mapper/cl-root
/dev/mapper/cl-root: UUID="b67bbb1c-3845-4fe5-9906-9902394816e2" TYPE="xfs"

10. 扩展文件系统,如果是ext类型分区,使用resize2fs命

[root@centos8 ~]# xfs_growfs /
meta-data=/dev/mapper/cl-root    isize=512    agcount=4, agsize=524032 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1
data     =                       bsize=4096   blocks=2096128, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 2096128 to 12349440
[root@centos8 ~]# df -Th
Filesystem          Type      Size  Used Avail Use% Mounted on
devtmpfs            devtmpfs  7.8G     0  7.8G   0% /dev
tmpfs               tmpfs     7.8G     0  7.8G   0% /dev/shm
tmpfs               tmpfs     7.8G  8.9M  7.8G   1% /run
tmpfs               tmpfs     7.8G     0  7.8G   0% /sys/fs/cgroup
/dev/mapper/cl-root xfs        48G  4.4G   43G  10% /
/dev/vda1           ext4      976M  143M  766M  16% /boot
tmpfs               tmpfs     1.6G  4.0K  1.6G   1% /run/user/0
标签: 暂无
最后更新:2023年 10月 12日

骑着毛驴看世界

我们是一个汇集了各种教程的在线知识宝库。无论您是寻找如何精通编程、烹饪美食、学习新技能,还是探索创意艺术和健康生活的窍门,我们的网站都为您提供了丰富的教程资源。不仅可以浏览他人的精彩教程,还可以轻松创建和分享自己的知识,与全球的学习者互动。无论您是一位导师还是一名学徒,『LearnHub』都是您不可或缺的学习伙伴,助您在各种领域不断成长。加入我们,开启学习的无限可能!

点赞
< 上一篇
下一篇 >

文章评论

您需要 登录 之后才可以评论

归档

  • 2026 年 11 月
  • 2023 年 10 月

分类

  • 原创类
  • 搭建工具
  • 教程类
  • 科学上网
  • 网络相关

近期文章

  • WordPress一键替换域名
  • 绿盾客户端文件加密不显示锁的图标,加密功能正常
  • centos 9 安装 详细步骤,包含安装环境,软件,分区等简单使用以及讲解
  • WordPress自适应WebP格式图片加速方法-Nginx,WP插件和CDN三种方式
  • SmartDNS +dnsmasq+Passwall+AdguardHome 优化

近期评论

  1. 睡瞌睡 发表在 DOCKER安装CUPS容器实现无线打印(支持大部分ARM设备)
  2. 萨达加 发表在 centos stream9 设置网卡IP
  3. 骑着毛驴看世界 发表在 centos stream9 设置网卡IP

COPYRIGHT © 2023 LearnHub. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang