杨海振
当自己的才华撑不起野心时,那就沉下心来学习吧!
随笔 - 15,  文章 - 0,  评论 - 0,  阅读 - 8669

新增⼀块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空间⼤⼩

posted on   沧海浮尘  阅读(298)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示