阿里云云盘扩容教程
随着业务的增长,你的云盘容量已经不够用了。所以就需要扩大容量。扩容与新增云盘同样没那么简单。需要格式化等操作。我在这做个笔记,以便以后好查询
扩容前
建议在扩容磁盘之前手动创建快照,以备份数据。
磁盘上如果正在执行创建快照的操作,则此时不允许进行扩容操作。
只做磁盘容量的扩容,不做文件系统的扩容。
支持普通盘的扩容,不支持本地盘(本地磁盘、本地 SSD 盘)的扩容。
挂载在实例上的数据盘,只有实例为 Running 或者 Stopped 状态时,才可以进行扩容操作。
扩容后
使用 ECS 控制台或者 Open API 扩容磁盘之后,需要在 ECS 控制台或者使用 Open API 重启实例之后才可以生效。
扩容生效之后的磁盘,仍然需要用户手动格式化扩展的存储空间。
操作步骤
本文档以 Ubuntu 14.04 系统为例,介绍如何进行磁盘扩容。其他 Linux 系统的操作相似。
本实例中,选定最初的磁盘大小为 63 GB,我们将其扩容到 70 GB。
登录 云服务器管理控制台。
单击左侧导航中的 实例。然后选择页面顶部的地域。
首先进入磁盘列表页面,点击 更多 > 磁盘扩容。注意只有 数据盘 才有该选项。对于 系统盘, 需要通过 更换系统盘的方式进行扩容。
进入扩容页后,填写扩容后的磁盘容量大小,单击 去扩容。
也可以直接使用 OpenAPI 进行扩容操作:
ResizeDisk --DiskId=d-94tomxanq --NewSize=70
重启服务器。进入实例列表页面,点击 更多,选择 重启。
或者使用 OpenAPI 进行重启操作: RebootInstance --InstanceId=i-94lw423m7
登录到 ECS 实例。
如果磁盘是之前是 mount 在服务器上的,先 umount 磁盘。 umount /mnt/dev1
删除原有分区并新建分区。
有些用户使用 parted 工具来操作分区,但是 parted 和 fdisk 不能交叉使用的,否则会导致分区的起始扇区不一致的问题。因此删除原有分区建新分区的时候,请按照如下步骤进行操作:
1). 使用 fdisk -l 罗列一下分区信息并记录一下即将扩容磁盘的最终容量、起始扇区位置。
2). 使用 fdisk 指令,输入 d 来删除原有的分区。
3). 依次输入 n,p,1 来新建分区。
4). 选择 sector 时,在此示例中直接回车选择默认值,您也可以按照自己的需求来选择。为了保证数据的一致性,First sector 建议和之前的分区保持一致。
下面是使用 fdisk的示例:```<br>
<br>
root@iZ94lw423m7Z:~# fdisk /dev/xvdb<br>
<br>
Command (m for help): d<br>
Selected partition 1<br>
<br>
Command (m for help): n<br>
Partition type:<br>
p primary (0 primary, 0 extended, 4 free)<br>
e extended<br>
Select (default p): p<br>
Partition number (1-4, default 1): 1<br>
First sector (2048-146800639, default 2048):<br>
Using default value 2048<br>
Last sector, +sectors or +size{K,M,G} (2048-146800639, default 146800639):<br>
Using default value 146800639<br>
<br>
Command (m for help): wq<br>
The partition table has been altered!<br>
<br>
Calling ioctl() to re-read partition table.<br>
Syncing disks.<br>
<br>
```
如果在 First sector 这发现位置和之前记录的不一致,说明之前可能使用了 parted 来分区的,那么就停止当前的 fdisk 操作,使用 parted 重新操作。
使用 parted 指令,输入p罗列当前的分区情况,如有则使用 rm+ 序列号来删除老的分区表,然后使用 unit s 定义起始位置单位使用扇区个数计量,最后使用 mkpart 命令来创建即可,如下图所示。
9 格式化磁盘。
使用 e2fsck 的时候由于系统需要检查并订正文件系统元数据,所以速度较慢、耗时较长,请耐心等待。
使用 e2fsck 和 resize2fs 指令,正确操作情况下,不会造成原有数据丢失的。```<br>
e2fsck -f /dev/xvdb1<br>
resize2fs /dev/xvdb1<br>
```
10 将扩容完毕的磁盘挂载回原有的挂载点。```<br>
mount /dev/xvdb1 /mnt/dev1<br>
```
11 用 df -TH 指令可以查看到磁盘的信息。```<br>
df -TH<br>
Filesystem Type Size Used Avail Use% Mounted on<br>
/dev/xvda1 ext4 22G 1.4G 19G 7% /<br>
none tmpfs 4.1k 0 4.1k 0% /sys/fs/cgroup<br>
udev devtmpfs 510M 4.1k 510M 1% /dev<br>
tmpfs tmpfs 105M 381k 104M 1% /run<br>
none tmpfs 5.3M 0 5.3M 0% /run/lock<br>
none tmpfs 521M 0 521M 0% /run/shm<br>
none tmpfs 105M 0 105M 0% /run/user<br>
/dev/xvdb1 ext4 74G 55M 71G 1% /mnt/dev1<br>
<br>
```
总结:我第一次操作的时候,就没成功。当然数据也没不会丢失。因为按教程那样格式化或者操作是不会丢失数据的。当然以防万一,也最好做个快照比较好。
我说下比较容易出错的地方。fdisk /dev/xvdb 这一步注意是没有1的 而格式化这里e2fsck -f /dev/xvdb1 resize2fs /dev/xvdb1 是有1的。不然会没效果的。
如果还有什么不懂得地方可以留言或者加我QQ164418960
AD:真正免费,域名+虚机+企业邮箱=0元

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Learn about Python programming with introductory code examples Python is an easy-to-learn, yet powerful programming language. For beginners, it is very important to understand the introductory code examples of Python programming. This article will provide you with some concrete code examples to help you get started quickly. Print HelloWorldprint("HelloWorld") This is the simplest code example in Python. The print() function is used to output the specified content

"Go Language Programming Examples: Code Examples in Web Development" With the rapid development of the Internet, Web development has become an indispensable part of various industries. As a programming language with powerful functions and superior performance, Go language is increasingly favored by developers in web development. This article will introduce how to use Go language for Web development through specific code examples, so that readers can better understand and use Go language to build their own Web applications. 1. Simple HTTP Server First, let’s start with a

PHP variables store values during program runtime and are crucial for building dynamic and interactive WEB applications. This article takes an in-depth look at PHP variables and shows them in action with 10 real-life examples. 1. Store user input $username=$_POST["username"];$passWord=$_POST["password"]; This example extracts the username and password from the form submission and stores them in variables for further processing. 2. Set the configuration value $database_host="localhost";$database_username="username";$database_pa

The simplest code example of Java bubble sort Bubble sort is a common sorting algorithm. Its basic idea is to gradually adjust the sequence to be sorted into an ordered sequence through the comparison and exchange of adjacent elements. Here is a simple Java code example that demonstrates how to implement bubble sort: publicclassBubbleSort{publicstaticvoidbubbleSort(int[]arr){int

Title: From Beginner to Mastery: Code Implementation of Commonly Used Data Structures in Go Language Data structures play a vital role in programming and are the basis of programming. In the Go language, there are many commonly used data structures, and mastering the implementation of these data structures is crucial to becoming a good programmer. This article will introduce the commonly used data structures in the Go language and give corresponding code examples to help readers from getting started to becoming proficient in these data structures. 1. Array Array is a basic data structure, a group of the same type

Huawei Cloud Edge Computing Interconnection Guide: Java Code Samples to Quickly Implement Interfaces With the rapid development of IoT technology and the rise of edge computing, more and more enterprises are beginning to pay attention to the application of edge computing. Huawei Cloud provides edge computing services, providing enterprises with highly reliable computing resources and a convenient development environment, making edge computing applications easier to implement. This article will introduce how to quickly implement the Huawei Cloud edge computing interface through Java code. First, we need to prepare the development environment. Make sure you have the Java Development Kit installed (

How to use PHP to write the inventory management function code in the inventory management system. Inventory management is an indispensable part of many enterprises. For companies with multiple warehouses, the inventory management function is particularly important. By properly managing and tracking inventory, companies can allocate inventory between different warehouses, optimize operating costs, and improve collaboration efficiency. This article will introduce how to use PHP to write code for inventory warehouse management functions, and provide you with relevant code examples. 1. Establish the database before starting to write the code for the inventory warehouse management function.

Java Selection Sorting Method Code Writing Guide and Examples Selection sorting is a simple and intuitive sorting algorithm. The idea is to select the smallest (or largest) element from the unsorted elements each time and exchange it until all elements are sorted. This article will provide a code writing guide for selection sorting, and attach specific Java sample code. Algorithm Principle The basic principle of selection sort is to divide the array to be sorted into two parts, sorted and unsorted. Each time, the smallest (or largest) element is selected from the unsorted part and placed at the end of the sorted part. Repeat the above
