PCL(鹏城实验室开发者云)虚机云硬盘扩容教程【图文】

抱歉,各位亲们,让你们久等了,今天更新blog!
关于云硬盘扩容,个人已经用了很久了,并没有什么问题,所以今天跟大家分享出来,
也就是云硬盘扩容本教程


首先,致谢!

我们要非常感谢PCL(鹏城实验室开发者云)为我们提供了公益平台,
因此所有开发者(无论是技术专家、工程师,还是高校教师、学生等用户)都可以免费申请虚机试用,
申请云主机教程请参考–> 鲲鹏arm64 CentOS7 虚拟机学习https://blog.csdn.net/frdevolcqzyxynjds/article/details/105578249。


其次,温故而知新!

关注本博主的小伙伴们一定知道,之前出过扩容相关的文章,在此也跟大家贴出来分享一下:

  • linux服务器物理磁盘扩容 https://blog.csdn.net/frdevolcqzyxynjds/article/details/106088432
  • linux云主机磁盘根目录扩容 https://blog.csdn.net/frdevolcqzyxynjds/article/details/105141073

第三,进入正题(PCL云硬盘扩容)!

娱乐一刻:
把大象装冰箱里需要几步?

  • 打开冰箱门
  • 把大象装冰箱里
  • 关上冰箱门

1、扩容前

哪里有需求哪里就有解决方案

需求场景: 由于个人搭建的小型镜像站(http://210.22.22.150:3731/)存储空间有限(仅80G),故需要扩容。
因此,在扩容前我们必须要申请云硬盘

  • 1.1需求申请

    • 注意类型选择云硬盘
      PCL(鹏城实验室开发者云)虚机云硬盘扩容教程【图文】_第1张图片
    • 然后选择使用时长、数量、云硬盘大小
      PCL(鹏城实验室开发者云)虚机云硬盘扩容教程【图文】_第2张图片
    • 之后提交申请!
  • 1.2申请完等待后台管理员通过申请,若着急使用可跟后台管理员小姐姐发邮件([email protected])说明实际情况哟!
    下面看到的是申请通过之后的截图:
    PCL(鹏城实验室开发者云)虚机云硬盘扩容教程【图文】_第3张图片
    PCL(鹏城实验室开发者云)虚机云硬盘扩容教程【图文】_第4张图片

PCL(鹏城实验室开发者云)虚机云硬盘扩容教程【图文】_第5张图片

PCL(鹏城实验室开发者云)虚机云硬盘扩容教程【图文】_第6张图片

PCL(鹏城实验室开发者云)虚机云硬盘扩容教程【图文】_第7张图片
此时可以找到更多操作–> Attach
PCL(鹏城实验室开发者云)虚机云硬盘扩容教程【图文】_第8张图片

PCL(鹏城实验室开发者云)虚机云硬盘扩容教程【图文】_第9张图片
选择需要扩容的云主机
PCL(鹏城实验室开发者云)虚机云硬盘扩容教程【图文】_第10张图片

看到下图说明添加卷成功!
PCL(鹏城实验室开发者云)虚机云硬盘扩容教程【图文】_第11张图片
可以看到In-use,设备名/dev/sdb,证明成功!
PCL(鹏城实验室开发者云)虚机云硬盘扩容教程【图文】_第12张图片

此时查看云主机磁盘情况,可以看到如下所示

PCL(鹏城实验室开发者云)虚机云硬盘扩容教程【图文】_第13张图片

到这,准备工作已经就绪!

Are you ready?

那我们下面开始扩容吧!

2、扩容进行时

  • 加挂前:
    PCL(鹏城实验室开发者云)虚机云硬盘扩容教程【图文】_第14张图片
  • 开始操作

PCL(鹏城实验室开发者云)虚机云硬盘扩容教程【图文】_第15张图片

  • 继续操作

PCL(鹏城实验室开发者云)虚机云硬盘扩容教程【图文】_第16张图片
继续操作
PCL(鹏城实验室开发者云)虚机云硬盘扩容教程【图文】_第17张图片
先检查文件系统类型
PCL(鹏城实验室开发者云)虚机云硬盘扩容教程【图文】_第18张图片
否则,擅自使用xfs_growfs会报错哦!
PS:博主最初就是遇到这个锅,才想起来来查看文件系统

在这里插入图片描述

同步文件系统(成功)
PCL(鹏城实验室开发者云)虚机云硬盘扩容教程【图文】_第19张图片

注意观察文件系统类型是ext4,所以同步文件系统时是使用resize2fs,所以在resize2fs之前一定要检测文件系统类型

3、扩容后

加挂后
PCL(鹏城实验室开发者云)虚机云硬盘扩容教程【图文】_第20张图片
PCL(鹏城实验室开发者云)虚机云硬盘扩容教程【图文】_第21张图片

看一下镜像站磁盘现在(2021-03-12)使用多少啦?

PCL(鹏城实验室开发者云)虚机云硬盘扩容教程【图文】_第22张图片


最后,注意细节!

关键要注意
在这里插入图片描述
其实也可以使用 df -hT查看文件系统类型哈


2021年第6篇原创,欢迎大家 一键三连 哈!
对啦,都看到最后啦,欢迎各位小伙伴们关注博主微信公众号哈!

PCL(鹏城实验室开发者云)虚机云硬盘扩容教程【图文】_第23张图片
PS:这次关注一定更新哟!


本来不打算分享扩容记录文件的,都知道博主是热爱分享的开源小能手,于是就把操作步骤放在这篇blog最后了啦,所以,你有没有看到最后丫。。。

[root@pc148 ~]# lsblk
NAME            MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sdb               8:16   0   500G  0 disk
└─sdb1            8:17   0   500G  0 part
  └─centos-root 253:0    0 579.4G  0 lvm  /
sdc               8:32   0   500G  0 disk
sda               8:0    0    80G  0 disk
├─sda2            8:2    0   520M  0 part /boot
├─sda3            8:3    0  79.4G  0 part
│ └─centos-root 253:0    0 579.4G  0 lvm  /
└─sda1            8:1    0   100M  0 part /boot/efi
[root@pc148 ~]#
[root@pc148 ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                  16G     0   16G   0% /dev
tmpfs                     16G     0   16G   0% /dev/shm
tmpfs                     16G   40M   16G   1% /run
tmpfs                     16G     0   16G   0% /sys/fs/cgroup
/dev/mapper/centos-root  571G   36G  511G   7% /
/dev/sda2                496M  117M  344M  26% /boot
/dev/sda1                100M  4.5M   96M   5% /boot/efi
tmpfs                    3.2G     0  3.2G   0% /run/user/0
[root@pc148 ~]#
[root@pc148 ~]# fdisk -u /dev/sdc
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 0x466d811e.

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):
First sector (2048-1048575999, default 2048):
Using default value 2048
Last sector, +sectors or +size{
     K,M,G} (2048-1048575999, default 1048575999):
Using default value 1048575999
Partition 1 of type Linux and of size 500 GiB is set

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@pc148 ~]#
[root@pc148 ~]# partprobe
[root@pc148 ~]#
[root@pc148 ~]# lsblk
NAME            MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sdb               8:16   0   500G  0 disk
└─sdb1            8:17   0   500G  0 part
  └─centos-root 253:0    0 579.4G  0 lvm  /
sdc               8:32   0   500G  0 disk
└─sdc1            8:33   0   500G  0 part
sda               8:0    0    80G  0 disk
├─sda2            8:2    0   520M  0 part /boot
├─sda3            8:3    0  79.4G  0 part
│ └─centos-root 253:0    0 579.4G  0 lvm  /
└─sda1            8:1    0   100M  0 part /boot/efi
[root@pc148 ~]#
[root@pc148 ~]# lvm
lvm> pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda3
  VG Name               centos
  PV Size               79.39 GiB / not usable 2.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              20324
  Free PE               0
  Allocated PE          20324
  PV UUID               jCCAWQ-lY1Q-9Lxy-UG16-0VkB-Qz21-YPzPp4

  --- Physical volume ---
  PV Name               /dev/sdb1
  VG Name               centos
  PV Size               <500.00 GiB / not usable 3.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              127999
  Free PE               0
  Allocated PE          127999
  PV UUID               avxuWc-Yfrd-D10u-xATo-g2AS-ongA-3bG86V

lvm> pvcreate /dev/sdc1
  Physical volume "/dev/sdc1" successfully created.
lvm> pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda3
  VG Name               centos
  PV Size               79.39 GiB / not usable 2.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              20324
  Free PE               0
  Allocated PE          20324
  PV UUID               jCCAWQ-lY1Q-9Lxy-UG16-0VkB-Qz21-YPzPp4

  --- Physical volume ---
  PV Name               /dev/sdb1
  VG Name               centos
  PV Size               <500.00 GiB / not usable 3.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              127999
  Free PE               0
  Allocated PE          127999
  PV UUID               avxuWc-Yfrd-D10u-xATo-g2AS-ongA-3bG86V

  "/dev/sdc1" is a new physical volume of "<500.00 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdc1
  VG Name
  PV Size               <500.00 GiB
  Allocatable           NO
  PE Size               0
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               KJEvTc-pvyR-KUae-0ztG-K6iA-6wgo-K9JXVt

lvm> vgdisplay
  --- Volume group ---
  VG Name               centos
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               <579.39 GiB
  PE Size               4.00 MiB
  Total PE              148323
  Alloc PE / Size       148323 / <579.39 GiB
  Free  PE / Size       0 / 0
  VG UUID               dD7rcV-XeKC-aUCa-YU9M-TASi-7jx2-wtULgK

lvm> vgextend centos /dev/sdc1
  Volume group "centos" successfully extended
lvm> vgdisplay
  --- Volume group ---
  VG Name               centos
  System ID
  Format                lvm2
  Metadata Areas        3
  Metadata Sequence No  5
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                3
  Act PV                3
  VG Size               1.05 TiB
  PE Size               4.00 MiB
  Total PE              276322
  Alloc PE / Size       148323 / <579.39 GiB
  Free  PE / Size       127999 / <500.00 GiB
  VG UUID               dD7rcV-XeKC-aUCa-YU9M-TASi-7jx2-wtULgK

lvm> pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda3
  VG Name               centos
  PV Size               79.39 GiB / not usable 2.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              20324
  Free PE               0
  Allocated PE          20324
  PV UUID               jCCAWQ-lY1Q-9Lxy-UG16-0VkB-Qz21-YPzPp4

  --- Physical volume ---
  PV Name               /dev/sdb1
  VG Name               centos
  PV Size               <500.00 GiB / not usable 3.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              127999
  Free PE               0
  Allocated PE          127999
  PV UUID               avxuWc-Yfrd-D10u-xATo-g2AS-ongA-3bG86V

  --- Physical volume ---
  PV Name               /dev/sdc1
  VG Name               centos
  PV Size               <500.00 GiB / not usable 3.00 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              127999
  Free PE               127999
  Allocated PE          0
  PV UUID               KJEvTc-pvyR-KUae-0ztG-K6iA-6wgo-K9JXVt

lvm> lvextend -l +100%FREE /dev/centos/root
  Size of logical volume centos/root changed from <579.39 GiB (148323 extents) to 1.05 TiB (276322 extents).
  Logical volume centos/root successfully resized.
lvm> exit
  Exiting.
[root@pc148 ~]#
[root@pc148 ~]# fsck -f /dev/centos/root
fsck from util-linux 2.23.2
e2fsck 1.42.9 (28-Dec-2013)
/dev/mapper/centos-root is mounted.
e2fsck: Cannot continue, aborting.

[root@pc148 ~]#
[root@pc148 ~]# resize2fs /dev/centos/root
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/centos/root is mounted on /; on-line resizing required
old_desc_blocks = 73, new_desc_blocks = 135
The filesystem on /dev/centos/root is now 282953728 blocks long.

[root@pc148 ~]#
[root@pc148 ~]# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sdb               8:16   0  500G  0 disk
└─sdb1            8:17   0  500G  0 part
  └─centos-root 253:0    0  1.1T  0 lvm  /
sdc               8:32   0  500G  0 disk
└─sdc1            8:33   0  500G  0 part
  └─centos-root 253:0    0  1.1T  0 lvm  /
sda               8:0    0   80G  0 disk
├─sda2            8:2    0  520M  0 part /boot
├─sda3            8:3    0 79.4G  0 part
│ └─centos-root 253:0    0  1.1T  0 lvm  /
└─sda1            8:1    0  100M  0 part /boot/efi
[root@pc148 ~]#
[root@pc148 ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                  16G     0   16G   0% /dev
tmpfs                     16G     0   16G   0% /dev/shm
tmpfs                     16G   40M   16G   1% /run
tmpfs                     16G     0   16G   0% /sys/fs/cgroup
/dev/mapper/centos-root  1.1T   36G  983G   4% /
/dev/sda2                496M  117M  344M  26% /boot
/dev/sda1                100M  4.5M   96M   5% /boot/efi
tmpfs                    3.2G     0  3.2G   0% /run/user/0
[root@pc148 ~]#

你可能感兴趣的:(Linux,经验分享,cloud,linux,lvm,运维,服务器,centos)