警告:

1.调整过分区管理方式的,例如lvm管理方式,请忽略此教程。

2.ubuntu18系统暂不支持脚本扩容,请手动扩容,参看下面ubuntu18部分,用parted操作

脚本自动处理(推荐)

SSH登录服务器下载自动执行脚本 :

wget -O auto_expansion.sh http://downinfo.myhostadmin.net/vps/auto_expansion.sh && bash auto_expansion.sh && rm -rf auto_expansion.sh

手工处理方法

红色为您要键入的指令,绿色为需要注意的内容,蓝色为说明

特别提醒:删除分区后一定要先建立分区再保存,删除后点了保存会导致数据丢失,如果对linux不熟悉的,建议提交维护工单我司手工处理,费用100元。该操作有风险,为避免误操作导致数据丢失,操作前请对您的重要数据进行备份!

centos6用gdisk工具

Centos:
[root@ebs-89713 ~]yum -y install gdisk        //安装分区工具

[root@ebs-89713 ~]gdisk /dev/vda        //操作根分区磁盘

Command (? for help): p    //查看分区

Disk /dev/vda: 104857600 sectors, 50.0 GiB

Logical sector size: 512 bytes

Disk identifier (GUID): B7172F0B-2C30-4535-981D-F0ED8B4A6065

Partition table holds up to 128 entries

First usable sector is 34, last usable sector is 104857566

Partitions will be aligned on 2048-sector boundaries

Total free space is 41945021 sectors (20.0 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name

1            2048        62914559   30.0 GiB    8300  Linux filesystem    //注意这个值

Command (? for help): d        //删除分区

Using 1

Command (? for help): 1

b       back up GPT data to a file

c       change a partition's name

d       delete a partition

i       show detailed information on a partition

l       list known partition types

n       add a new partition

o       create a new empty GUID partition table (GPT)

p       print the partition table

q       quit without saving changes

r       recovery and transformation options (experts only)

s       sort partitions

t       change a partition's type code

v       verify disk

w       write table to disk and exit

x       extra functionality (experts only)

?       print this menu

Command (? for help): n

Partition number (1-128, default 1): 1

First sector (34-104857566, default = 2048) or {+-}size{KMGTP}: 2048   //刚才记录的

Last sector (2048-104857566, default = 104857566) or {+-}size{KMGTP}:   //直接回车

Current type is 'Linux filesystem'

Hex code or GUID (L to show codes, Enter = 8300):            //直接回车

Changed type of partition to 'Linux filesystem'

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING

PARTITIONS!!

Do you want to proceed? (Y/N): y

OK; writing new GUID partition table (GPT) to /dev/vda.

Warning: The kernel is still using the old partition table.

The new table will be used at the next reboot.

The operation has completed successfully.

[root@ebs ~]#reboot                        //重启让分区生效

[root@ebs ~]#resize2fs -f /dev/vda1                 //开始扩容根分区,如果是centos8.x系统需要使用这个命令:xfs_growfs /dev/vda1

resize2fs -f /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 = 4

Performing an on-line resize of /dev/vda1 to 13106939 (4k) blocks.

The filesystem on /dev/vda1 is now 13106939 blocks long.

[root@ebs ~]#df -vh                            //完成,查看新的根分区大小

centos7,centos8用fdisk工具

[root@ebs-89713 ~]# fdisk /dev/vda

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.

Command (m for help): p

Disk /dev/vda: 53.7 GB, 53687091200 bytes, 104857600 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: 0x000c1d0e

Device Boot      Start         End      Blocks   Id  System

/dev/vda1            2048    83886079    41942016   83  Linux

Command (m for help): d

Selected partition 1

Partition 1 is deleted

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): 1

First sector (2048-104857599, default 2048): 2048

Last sector, +sectors or +size{K,M,G} (2048-104857599, default 104857599): 104857599

Partition 1 of type Linux and of size 50 GiB is set

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.

The kernel still uses the old table. The new table will be used at

the next reboot or after you run partprobe(8) or kpartx(8)

Syncing disks.

[root@ebs-89713 ~]# reboot                        //重启让分区生效

重启完,重新登陆服务器

centos7系统执行:

[root@ebs-89713 ~]# resize2fs -f /dev/vda1   //开始扩容根分区

centos8系统执行:

[root@ebs-89713 ~]# xfs_growfs /dev/vda1  //开始扩容根分区

[root@ebs-89713 ~]# df -vh   //完成,查看新的根分区大小

Ubuntu16,Ubuntu20,debian8,debian9用parted工具

[root@ebs-89713 ~] parted /dev/vda

(parted) unit b

(parted) print

Model: Virtio 块设备 (virtblk)

磁盘 /dev/vda: 107374182400B

Sector size (logical/physical): 512B/512B

分区表:msdos

数字  开始:    End           大小          类型     文件系统  标志

1    1048576B  32211206143B  32210157568B  primary  ext4      启动

(parted) rm 1               //删除1分区,记1的开始   删除2分区,记2分区的开始

警告: Partition /dev/vda1 is being used. Are you sure you want to continue?

是/Yes/否/No? yes

错误: Partition(s) 1 on /dev/vda have been written, but we have been unable to inform the kernel of the change,

probably because it/they are in use.  As a result, the old partition(s) will remain in use.  You should reboot

now before making further changes.

忽略/Ignore/放弃/Cancel? I

(parted) mkpart

分区类型?  primary/主分区/extended/扩展分区? p

文件系统类型?  [ext2]?

起始点? 1048576B     //删除1分区,记1的开始   删除2分区,记2分区的开始

结束点? 100%

(parted) print

Model: Virtio 块设备 (virtblk)

磁盘 /dev/vda: 107374182400B

Sector size (logical/physical): 512B/512B

分区表:msdos

数字  开始:    End            大小           类型     文件系统  标志

1    1048576B  107374182399B  107373133824B  primary  ext4

(parted) quit

信息: You may need to update /etc/fstab.

[root@ebs-89713 ~]# reboot                        //重启让分区生效

重启完,重新登陆服务器

[root@ebs-89713 ~]# resize2fs -f /dev/vda1   //开始扩容根分区

[root@ebs-89713 ~]# df -vh   //完成,查看新的根分区大小

ubuntu18(系统盘存在两个分区vda1,vda2)用parted工具

root@ebs-89713:~# parted /dev/vda

GNU Parted 3.2

Using /dev/vda

Welcome to GNU Parted! Type 'help' to view a list of commands.

(parted) unit b

(parted) print

Warning: Not all of the space available to /dev/vda appears to be used, you can fix the GPT to use all of the space (an extra 20971520 blocks) or continue

with the current setting?

Fix/Ignore? Fix

Model: Virtio Block Device (virtblk)

Disk /dev/vda: 42949672960B

Sector size (logical/physical): 512B/512B

Partition Table: gpt

Disk Flags:

Number  Start     End           Size          File system  Name  Flags

1      1048576B  2097151B      1048576B                         bios_grub

2      2097152B  32211206143B  32209108992B  ext4

(parted) rm 2

Warning: Partition /dev/vda2 is being used. Are you sure you want to continue?

Yes/No? Yes

Error: Partition(s) 2 on /dev/vda have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use.  As a

result, the old partition(s) will remain in use.  You should reboot now before making further changes.

Ignore/Cancel? I

(parted) mkpart

Partition name?  []?     //直接回车

File system type?  [ext2]?  //直接回车

Start? 2097152B    //上面number 2中的start起始位置

End? 100%

(parted) print

Model: Virtio Block Device (virtblk)

Disk /dev/vda: 42949672960B

Sector size (logical/physical): 512B/512B

Partition Table: gpt

Disk Flags:

Number  Start     End           Size          File system  Name  Flags

1      1048576B  2097151B      1048576B                         bios_grub

2      2097152B  42948624383B  42946527232B  ext2

(parted) quit

root@ebs-89713:~# reboot  //重启让分区生效

重启完,重新登陆服务器

root@ebs-89713:~# resize2fs -f /dev/vda2   //开始扩容根分区

root@ebs-89713:~# df -vh   //完成,查看新的根分区大小

Llinux系统(Centos/Ubuntu/Debian)弹性云系统盘扩容方法的更多相关文章

  1. MySQL For Linux(CentOS/Ubuntu/Debian/Fedora/Arch)一键安装脚本(5.1-8.0)

    简介 很多童鞋不懂这么在Linux系统安装MySQL,网上大多数教程较复杂,不太适合小白安装,本教程提供一键安装脚本供大家使用,教大家怎么在Linux操作系统( 支持CentOS/Ubuntu/Deb ...

  2. Linux系统(Ubuntu/Debian/RedHat/CentOS)超级简单的samba配置文件smb.conf

    1.超简单的smb.conf 该配置文件对Ubuntu和CentOS都好用. #============== Global Settings ============== [global] ## Br ...

  3. LNMP一键安装包-CentOS/Ubuntu/Debian自动安装Nginx,MySQL,PHP

    适用环境: 系统支持:CentOS.Ubuntu.Debian 内存要求:≥128M 安装了什么: 1.Nginx-1.2.1 2.MySQL 5.5.25 3.PHP 5.2.17或PHP 5.3. ...

  4. ubuntu/debian gpg error no_pubkey 解决方法

    GPG error: http://ppa.launchpad.net precise Release: The following signatures couldn’t be verified b ...

  5. Linux添加快捷启动方式 (Ubuntu Debian CentOS)

    ubuntu桌面快捷方式的创建 debian添加快捷启动方式 centos 6 桌面建立应用程序的快捷方式的方法   今天用着用着ubuntu,突然抽搐了,感觉特别别扭,特别不方便.新装的应用程序不好 ...

  6. ubuntu, Debian, CentOS

    ubuntu源自debian,内核很多文档都还是debian的字样,稳定性逐渐增强,基本满足日常开发. debian的核心稳定,性能强劲. centos的内核版本低,安全性高. 选择Debian是因为 ...

  7. [转帖]云服务器使用CentOS、Debian、Ubuntu的哪个版本

    云服务器使用CentOS.Debian.Ubuntu的哪个版本 2018-09-09 12:32:45作者:ywnz稿源:云网牛站 https://ywnz.com/linuxyffq/2986.ht ...

  8. centos系统与ubuntu系统的区别

    centos和ubuntu简述 CentOS(Community ENTerprise Operating System)是Linux发行版之一,它是来自于Red Hat Enterprise Lin ...

  9. linux下获取软件源码包 centos/redhat, debian/ubuntu

    linux下获取软件源码包 centos/redhat, debian/ubuntu centos下: 1. yum install yum-utils 主要为了获取yumdownloader 2. ...

  10. Linux系统virtualbox + ubuntu + xshell 问题与注意事项

    序言:ubuntu闭源软件太多,一般不推荐使用:没钱可以使用centos.debian:有钱使用redhat 目前主流和常用的Linux版本主要有:1.Redhat 版本5.5和6.0最新:培训.学习 ...

随机推荐

  1. idea开发使用外置tomcat配置

    1. 添加依赖 <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId> ...

  2. Python使用Eel和HTML开发桌面应用GUI直接用web前端的VUE+VANT来做

    python的gui太难用了,唯一能配置独立前端的程序只有web.所以用web做前端,到python,完美! 环境准备    Python 3.9    Chrome浏览器(由于Eel是直接调用的Ch ...

  3. 使用react-vite-antd,修改antd主题,报错 [vite] Internal server error: Inline JavaScript is not enabled. Is it set in your options? It is hacky way to make this function will be compiled preferentially by less

    一般报错 在官方文档中,没有关于vite中如何使用自定义主题的相关配置,经过查阅 1.安装less  yarn add less (已经安装了就不必再安装) 2.首先将App.css改成App.les ...

  4. python selenium 操作文件上传,并发操作时,文件选择窗口混乱解决方案

    上传文件 使用的是 python + autoit 模块,这种方式有一个问题,当出现多条任务同时选择文件上传的时候,无法判断那个文件选择窗口的归属,从而出现上传了错误的文件! 解决方法: 要上载文件而 ...

  5. python安装第三方库出现“'pip' is not recognized ...”报错及其解决

    命令行安装第三方库,直接 通过命令 pip install XXX 会报错: 'pip' is not recognized as an internal or external command, o ...

  6. GO语言学习笔记-工具链篇 Study for Go ! Chapter eleven - Tool Chain

    持续更新 Go 语言学习进度中 ...... GO语言学习笔记-类型篇 Study for Go! Chapter one - Type - slowlydance2me - 博客园 (cnblogs ...

  7. Linux0.11源码学习(二)

    Linux0.11源码学习(二) linux0.11源码学习笔记 参考资料:https://github.com/sunym1993/flash-linux0.11-talk 源码查看:https:/ ...

  8. 项目构建node-sass源码报错 SyntaxError:Unexpectedtoken"?"

    背景 vue2项目,之前一直构建正常.今天改了代码,构建时报错,报错原因显示编译node-sass源码时出错. 报错信息: Modulebuild failed:/node_modules/node- ...

  9. Mathematica的Combinatorica`程序包使用笔记

    目录 官方给出的程序包使用指南和一些示例 引论 步骤 0x00 导入程序包 0x01 Integer Partitions 0x02 Integer Compositions 0x03 partiti ...

  10. 教你如何用纯css代码实现太极阴阳鱼动画效果

    今天看到一个有意思的效果,闲来无事做一个: 把2d静态的太极图改成了3d,阴极和阳极分到了两个平面里实现旋转效果,这个好实现,重点是实现它的透明效果,平面太极图显示出两极是用另加的块元素挡住底面的颜色 ...