首页 > 系统相关 >centos7分区扩容(新增盘)

centos7分区扩容(新增盘)

时间:2023-03-17 16:44:49浏览次数:49  
标签:扩容 512 centos data 分区 dev centos7 2.0 root

新增⼀块60G硬盘,根分区及data分区各增加30G空间

⼀、初始⼤⼩

[root@localhost ~]# df -Th
Filesystem             Type    Size   Used   Avail   Use%   Mounted on
devtmpfs               devtmpfs 2.0G    0     2.0G    0%       /dev
tmpfs                   tmpfs   2.0G    0     2.0G    0%       /dev/shm
tmpfs                   tmpfs   2.0G   12M    2.0G    1%       /run
tmpfs                   tmpfs   2.0G    0     2.0G    0%       /sys/fs/cgroup
/dev/mapper/centos-root xfs     40G    1.5G   38G     4%       /
/dev/mapper/centos-data xfs     40G     33M   40G     1%       /data
/dev/sda1               xfs     497M   143M   354M    29%      /boot
tmpfs                   tmpfs   407M    0     407M    0%       /run/user/0

⼆、查看卷名

[root@localhost ~]# vgdisplay |grep -E "VG Name"     查看卷组名称(也可以查看剩余空间,FREE SIZE⼀⾏)

 VG Name centos

三、查看路径

[root@localhost ~]# lvdisplay |grep -E "LV Path"
LV Path /dev/centos/swap
LV Path /dev/centos/root
LV Path /dev/centos/data

四、查看新增磁盘⼤⼩及名称,这⾥是/dev/sdb

[root@localhost ~]# fdisk -l /dev/sdb
Disk /dev/sdb: 64.4 GB, 64424509440 bytes, 125829120 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@test-server ~]# fdisk -l            #查看磁盘情况
[root@test-server ~]# fdisk /dev/sdb      #进⼊磁盘(可以依次按键p->n->e->回⻋->回⻋->w,即⽤此磁盘    所有空闲空间创建分区)
Command (m for help): n                    #n 为添加⼀个分区, p查看分区
First cylinder (2898-10443, default 2898): #按Enter 键决定
Using default value 2898 #起始柱⾯选择默认值
Last cylinder or +size or +sizeM or +sizeK (289810443, default 10443): +2G # 给2G的⼤⼩
Command (m for help): t        #更改分区类型
Partition number (1-5): 5      #选分区
Hex code (type L to list codes): l      #分区类型列表
Hex code (type L to list codes):8e      #将新添加的分区标注成 lvm
Command (m for help): p      #查看分区表
/dev/sda5 2756 2999 1959898+ 8e Linux LVM
Command (m for help): w      #保存

[root@test-server ~]# partprobe /dev/sdb     #系统识别分区(代替重启)

六、格式化磁盘/dev/sdb

[root@localhost ~]# mkfs.xfs /dev/sdb1
meta-data=/dev/sdb isize=512 agcount=4, agsize=3932160 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=15728640, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=7680, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0

七、/dev/sdb加⼊centos虚拟组

pvcreate /dev/sdb1
vgextend centos /dev/sdb1

[root@localhost ~]# pvcreate /dev/sdb1
WARNING: xfs signature detected on /dev/sdb at offset 0. Wipe it? [y/n]: y
Wiping xfs signature on /dev/sdb.
Physical volume "/dev/sdb" successfully created.
⼋、增加/data分区空间
[root@localhost ~]# lvextend -L +30G /dev/centos/data    #或者直接使⽤" lvextend -l +100%FREE /dev/centos/data "命令,即使⽤卷组剩余所有空间。
Size of logical volume centos/data changed from 39.46 GiB (10103 extents) to 69.46 GiB (17783 extents).
Logical volume centos/data successfully resized.

九、刷新,激活分区

[root@localhost ~]# xfs_growfs /dev/mapper/centos-data
meta-data=/dev/mapper/centos-data isize=512 agcount=4, agsize=2586368 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=10345472, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=5051, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 10345472 to 18209792

⼗、同上,增加/根分区空间

[root@localhost ~]# lvextend -L +30G /dev/centos/root
Size of logical volume centos/root changed from 39.06 GiB (10000 extents)to 69.06 GiB (17680 extents).
Logical volume centos/root successfully resized.
[root@localhost ~]# xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=2560000 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=10240000, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=5000, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 10240000 to 18104320

[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 2.0G 0 2.0G 0% /dev
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 2.0G 12M 2.0G 1% /run
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/mapper/centos-root 70G 1.5G 68G 3% /
/dev/mapper/centos-data 70G 33M 70G 1% /data
/dev/sda1 497M 143M 354M 29% /boot
tmpfs 407M 0 407M 0% /run/user/0

//以上可以看出/根分区 及/data分区各增加了30G空间⼤⼩

标签:扩容,512,centos,data,分区,dev,centos7,2.0,root
From: https://www.cnblogs.com/yanghaizhen/p/17227300.html

相关文章

  • Clickhouse集群扩容和收缩
    集群节点信息节点IPClickhousenode121.198.165.19Clickhousenode221.198.165.20Clickhousenode321.198.165.21集群配置信息......
  • Linux安装python3 Centos7
    Linux安装python3Linux自带python2环境,以下是python3的安装步骤一、python3安装包下载地址:https://www.python.org/downloads/release/python-380/也可以使用wget命令下......
  • Centos7系统在开启进入系统报错:Give root password for maintenance(or type Control-D
    报错信息:在进入系统时,不能正常进入系统,出现了Giverootpasswordformaintenance(ortypeControl-Dtocontinue):的报错。 报错原因:1、在之前写入的/etc/fstab文件有......
  • centos7 最小化安装ifconfig不可用,无法上网
    原因:在虚拟机中以最小化方式安装centos7,后无法上网,因为centos7默认网卡未激活;而且在sbin目录中没有ifconfig文件,这是因为centos7已经不使用ifconfig命令了,已......
  • 安装Centos7初始化操作系统
    设置静态网络1、设置静态网络,一是用来不让地址飘忽不定,二来是为了访问外网。命令如下:[root@localhost~]#vim/etc/sysconfig/network-scripts/ifcfg-ens33修改内容......
  • centos7 安装 postgresql-9.2
    1.添加yum配置yuminstall-yhttp://download.postgresql.org/pub/repos/yum/9.2/redhat/rhel-7-x86_64/pgdg-centos92-9.2-3.noarch.rpm2.安装服务yumins......
  • Centos7配置本地及网络yum源
    开源镜像站:阿里云开源镜像站:https://mirrors.aliyun.com/网易开源镜像站:https://mirrors.163.com/中科大开源镜像站:https://mirrors.ustc.edu.cn/清华开源镜像站:http......
  • CentOS7永久挂载硬盘
    mkdir/mnt/cdrom//创建挂载硬盘目录mount-orw/dev/vdb1/mnt/cdrom//挂载硬盘设备/dev/vdb1rw是可读可写,ro是只读上面步骤重启会失效,解决办......
  • centos7拷贝挂载硬盘一些命令检查硬盘序列号
    Centos新增硬盘以后,系统不能自动进行识别。1.由于不知道新增硬盘挂载的位置,可以先查看现有硬盘挂载的适配器。ls-l/sys/block/sdalrwxrwxrwx.1rootroot0Jun1511......
  • centos7 安装docker 错误解决
    yum-config-manager--add-repohttp://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repoyum-yinstalldocker-ce安装报错:错误:软件包:2:container-selinux-2......