阿里云ECS服务器扩容系统盘

1、通过ECS控制台或者API扩容云盘

在阿里云ECS控制台中,选择你要扩容的那个服务器,进行扩容。扩容完成后,重启服务器,并创建快照以备份数据。

2、根据操作系统安装growpart扩容格式化工具

  • 2.1 CentOS 7、Aliyun Linux:
   yum install cloud-utils-growpart

   
   
    • 2.2 Ubuntu 14、Ubuntu 16、Ubuntu 18、Debian 9:
       apt install cloud-guest-utils
    
       
       
      • 2.3 Debian 8、OpenSUSE 42.3、OpenSUSE 13.1、SUSE Linux Enterprise Server 12 SP2:请使用上游版本(upstream)的growpart工具

      3、检查你的服务器内核版本

      [root@izwz9e66hx6no4074nle2lz ~]# uname -a
      Linux izwz9e66hx6no4074nle2lz 3.10.0-693.5.2.el7.x86_64 #1 SMP Fri Oct 20 20:32:50 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
      [root@izwz9e66hx6no4074nle2lz ~]#
      
         
         

        3.10.0,就是我的服务器内核版本。

        4、高内核版本的操作步骤

        4.1 查看现有磁盘大小

        [root@localhost ~]# fdisk -l
        

        Disk /dev/vda: 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: 0x0008d73a

        Device Boot Start End Blocks Id System
        /dev/vda1 * 2048 41943039 20970496 83 Linux

          示例返回磁盘(/dev/vda)容量是100 GiB,但是分区容量只有20G。

          4.2 查看磁盘分区大小

          [root@localhost ~]# df -h
          

          Filesystem Size Used Avail Use% Mounted on
          /dev/vda1 20G 19G 0G 100% /
          devtmpfs 7.8G 0 7.8G 0% /dev
          tmpfs 7.8G 0 7.8G 0% /dev/shm
          tmpfs 7.8G 344K 7.8G 1% /run
          tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup
          tmpfs 1.6G 0 1.6G 0% /run/user/0

            4.3 调用growpart为需要扩容的磁盘和对应的第几个分区扩容

            [root@localhost ~]# growpart /dev/vda 1
            

            CHANGED: partition=1 start=2048 old: size=41940992 end=41943040 new: size=209710462,end=209712510

              命令表示:为系统盘的第一个分区扩容,即4.2步骤中的第一个分区。

              4.4 调用resize2fs扩容文件系统

              [root@localhost ~]# resize2fs /dev/vda1
              

              resize2fs 1.42.9 (28-Dec-2013)
              Filesystem at /dev/vda1 is mounted on /; on-line resizing required
              old_desc_blocks = 2, new_desc_blocks = 7
              The filesystem on /dev/vda1 is now 26213807 blocks long.

                命令表示:为系统盘的/dev/vda1分区扩容文件系统。

                4.5 再次查看分区大小

                [root@localhost ~]# df -h
                

                Filesystem Size Used Avail Use% Mounted on
                /dev/vda1 100G 19G 80G 25% /
                devtmpfs 7.8G 0 7.8G 0% /dev
                tmpfs 7.8G 0 7.8G 0% /dev/shm
                tmpfs 7.8G 344K 7.8G 1% /run
                tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup
                tmpfs 1.6G 0 1.6G 0% /run/user/0

                  5、低内核版本的操作步骤

                  以CentOS 6操作系统为例演示分区扩展的步骤

                  5.1 安装dracut-modules-growroot工具

                  [root@AliYunOS ~]# yum install -y dracut-modules-growroot
                  
                   
                   

                    5.2 覆盖已有的initramfs文件

                    [root@AliYunOS ~]# dracut -f
                    
                     
                     

                      5.3 查看现有磁盘大小

                      [root@AliYunOS ~]# fdisk -l
                      

                      Disk /dev/vda: 107.4 GB, 107374182400 bytes
                      255 heads, 63 sectors/track, 13054 cylinders
                      Units = cylinders of 16065 * 512 = 8225280 bytes
                      Sector size (logical/physical): 512 bytes / 512 bytes
                      I/O size (minimum/optimal): 512 bytes / 512 bytes
                      Disk identifier: 0x0003a7b4

                      Device Boot Start End Blocks Id System
                      /dev/vda1 * 1 2611 20970496 83 Linux

                        5.4 查看磁盘分区大小

                        [root@AliYunOS ~]# df -h
                        

                        Filesystem Size Used Avail Use% Mounted on
                        /dev/vda1 20G 1.1G 18G 6% /
                        tmpfs 7.8G 0 7.8G 0% /dev/shm

                          5.5 调用growpart为需要扩容的磁盘和对应的第几个分区扩容

                          [root@AliYunOS ~]# growpart /dev/vda 1
                          

                          CHANGED: partition=1 start=2048 old: size=41940992 end=41943040 new: size=209710462,end=209712510

                            命令表示:为系统盘的第一个分区扩容。

                            5.6 重启实例

                            [root@AliYunOS ~]# reboot
                            
                             
                             

                              5.7 调用resize2fs扩容文件系统

                              [root@AliYunOS ~]# resize2fs /dev/vda1
                              

                              resize2fs 1.41.12 (17-May-2010)
                              Filesystem at /dev/vda1 is mounted on /; on-line resizing required
                              old desc_blocks = 2, new_desc_blocks = 7
                              Performing an on-line resize of /dev/vda1 to 26213807 (4k) blocks.
                              The filesystem on /dev/vda1 is now 26213807 blocks long.

                                5.8 再次查看磁盘分区大小

                                [root@AliYunOS ~]# df -h
                                

                                Filesystem Size Used Avail Use% Mounted on
                                /dev/vda1 99G 1.1G 93G 2% /
                                tmpfs 7.8G 0 7.8G 0% /dev/shm

                                                                  </div>
                                              <link href="https://csdnimg.cn/release/phoenix/mdeditor/markdown_views-b6c3c6d139.css" rel="stylesheet">
                                                                              <div class="more-toolbox">
                                              <div class="left-toolbox">
                                                  <ul class="toolbox-list">
                                                      
                                                      <li class="tool-item tool-active is-like "><a href="javascript:;"><svg class="icon" aria-hidden="true">
                                                          <use xlink:href="#csdnc-thumbsup"></use>
                                                      </svg><span class="name">点赞</span>
                                                      <span class="count"></span>
                                                      </a></li>
                                                      <li class="tool-item tool-active is-collection "><a href="javascript:;" data-report-click="{&quot;mod&quot;:&quot;popu_824&quot;}"><svg class="icon" aria-hidden="true">
                                                          <use xlink:href="#icon-csdnc-Collection-G"></use>
                                                      </svg><span class="name">收藏</span></a></li>
                                                      <li class="tool-item tool-active is-share"><a href="javascript:;"><svg class="icon" aria-hidden="true">
                                                          <use xlink:href="#icon-csdnc-fenxiang"></use>
                                                      </svg>分享</a></li>
                                                      <!--打赏开始-->
                                                                              <!--打赏结束-->
                                                                              <li class="tool-item tool-more">
                                                          <a>
                                                          <svg t="1575545411852" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5717" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M179.176 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5718"></path><path d="M509.684 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5719"></path><path d="M846.175 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5720"></path></svg>
                                                          </a>
                                                          <ul class="more-box">
                                                              <li class="item"><a class="article-report">文章举报</a></li>
                                                          </ul>
                                                      </li>
                                                                          </ul>
                                              </div>
                                                          </div>
                                          <div class="person-messagebox">
                                              <div class="left-message"><a href="https://blog.csdn.net/huazhiliandong">
                                                  <img src="https://profile.csdnimg.cn/8/A/1/3_huazhiliandong" class="avatar_pic" username="huazhiliandong">
                                                                          <img src="https://g.csdnimg.cn/static/user-reg-year/2x/5.png" class="user-years">
                                                                  </a></div>
                                              <div class="middle-message">
                                                                      <div class="title"><span class="tit"><a href="https://blog.csdn.net/huazhiliandong" data-report-click="{&quot;mod&quot;:&quot;popu_379&quot;}" target="_blank">東陽賢</a></span>
                                                                          </div>
                                                  <div class="text"><span>发布了10 篇原创文章</span> · <span>获赞 5</span> · <span>访问量 3568</span></div>
                                              </div>
                                                              <div class="right-message">
                                                                          <a href="https://im.csdn.net/im/main.html?userName=huazhiliandong" target="_blank" class="btn btn-sm btn-red-hollow bt-button personal-letter">私信
                                                      </a>
                                                                                          <a class="btn btn-sm  bt-button personal-watch" data-report-click="{&quot;mod&quot;:&quot;popu_379&quot;}">关注</a>
                                                                  </div>
                                                          </div>
                                                  </div>
                                  
                                  • 0
                                    点赞
                                  • 0
                                    收藏
                                    觉得还不错? 一键收藏
                                  • 0
                                    评论
                                  评论
                                  添加红包

                                  请填写红包祝福语或标题

                                  红包个数最小为10个

                                  红包金额最低5元

                                  当前余额3.43前往充值 >
                                  需支付:10.00
                                  成就一亿技术人!
                                  领取后你会自动成为博主和红包主的粉丝 规则
                                  hope_wisdom
                                  发出的红包
                                  实付
                                  使用余额支付
                                  点击重新获取
                                  扫码支付
                                  钱包余额 0

                                  抵扣说明:

                                  1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
                                  2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

                                  余额充值