Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Can the data disk be expanded? How to make the expanded capacity available?

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces the method of data disk expansion, which has a certain reference value and can be used for reference by friends who need it. The following information is about the detailed steps of data disk expansion.

Expand the capacity of data disk _ Linux

With the growth of your business, your data disk capacity may not be able to meet the needs of data storage. In this case, you can use the disk expansion feature to expand the data disk capacity.

Description

The data disk mounted on the instance can be expanded only if the instance is running (Running) or has been stopped (Stopped). To expand the capacity of this data disk, you need to restart the instance on the console to make the expanded capacity effective. Restarting the instance will stop the instance and disrupt your business, so please proceed with caution.

It is recommended to manually create a snapshot before expanding the data disk to back up the data.

The disk expansion operation can be performed regardless of whether the status of the data disk is to be mounted or in use.

If a prepaid instance has been renewed and downconfigured, the prepaid cloud disk on the instance does not support disk expansion for the rest of the current billing cycle.

If the data disk is creating a snapshot, the operation of expanding the data disk is not allowed.

The disk capacity expansion feature can only expand the data disk, not the system disk or local disk (local SSD, etc.).

This article takes a data disk of an efficient cloud disk and an ECS instance running CentOS 7.3.64-bit as an example to illustrate how to expand the data disk and make the capacity available after expansion.

You can complete the expansion operation by following the steps below:

Step 1. Expand the disk space of the data disk on the console

Step 2. Log in to the instance to expand the file system

Step 1. Expand the disk space of the data disk on the console

Follow these steps to expand the disk space of the data disk on the console:

Log in to the ECS Management console.

In the left navigation bar, select Storage > Cloud disk.

Description

If the data disk you need to expand has been mounted on an instance, you can click the instance, find the corresponding instance, go to the instance details page, and click the instance disk.

Select the region.

Find the disk that needs to be expanded, and in the Operation column, select more > disk expansion.

On the disk expansion page, set the capacity after expansion, which in this example is 30 GiB. The expanded capacity can only be larger than the current capacity.

After the cost information is displayed on the page, click OK to expand the capacity.

Description

After the expansion is successful, the capacity after the expansion is displayed in the disk list. However, if your data disk is mounted to the instance, the login instance will not see the new disk space capacity until the instance is restarted on the console.

After expanding the disk space of the data disk on the console

If the data disk has been mounted to the instance, you must perform step 2. Log in to the instance to expand the file system.

If the data disk is not mounted to the instance, you must first mount the data disk (see mounting the cloud disk), and then perform different operations according to the actual situation of the data disk:

If this is an unformatted data disk, you must format the data disk. For more information, see Linux formatting and mounting data disks.

If the data disk has been formatted and partitioned before, you must step 2. Log in to the instance to expand the file system.

Step 2. Log in to the instance to expand the file system

After the disk expansion is completed on the ECS console, the file system of each partition of the disk is not expanded. You need to log in to the instance to expand the file system.

In this example, assume that the data disk is mounted on a Linux instance, and the operating system of the instance is CentOS 7.3.64 bit. Before the expansion, the data disk has only one primary partition (/ dev/vdb1,ext4 file system), and the mount point of the file system is / resizetest. After the expansion of the file system, the data disk still has only one primary partition.

Use username and password authentication to connect to the Linux instance.

Run the umount command to unmount the primary partition.

Umount / dev/vdb1

Description

Use df-h to see if the uninstall is successful. If you don't see the / dev/vdb1 message, the uninstall is successful. The following is a sample output.

[root@iXXXXXX ~] # df-hFilesystem Size Used Avail Use% Mounted on/dev/vda1 40G 1.5G 36G 4% / devtmpfs 487M 0 487M 0% / devtmpfs 497M 0497M 0% / dev/shmtmpfs 497M 312K 496M 1% / runtmpfs 497M 0497M 0% / sys/fs/cgrouptmpfs 100M 0100M 0% / run/user/0

Use the fdisk command to delete the original partition and create a new partition:

Description

If you use the parted tool to manipulate a partition, you cannot cross-use it with fdisk, otherwise it will cause the starting sector of the partition to be inconsistent. You can refer to here for instructions on how to use the parted tool.

Run the command fdisk-l to list the partition information and record the final capacity and starting sector (First sector) location of the data disk before expansion.

Run the command fdisk [data disk configuration name] to enter the fdisk interface. In this example, the command is fdisk / dev/vdb.

Type d and press enter to delete the original partition.

Description

Deleting a partition will not result in the loss of data on the data disk.

Enter n and press enter to start creating a new partition.

Enter p and press enter to create the primary partition. Because you are creating a single-partition data disk, only the primary partition needs to be created.

Description

If you want to create more than 4 partitions, you should create at least one extended partition, that is, select e.

Enter the partition number and press enter. Because only one partition is created here, enter 1.

Enter the first available sector number: to ensure data consistency, the First sector needs to be consistent with the original partition. In this example, press enter to use the default value.

Description

If you find that the location shown by First sector is not consistent with the previously recorded location, indicating that you may have used parted to partition before, then stop the current fdisk operation and use parted to re-operate.

Enter the last sector number: because only one partition is created here, press enter to use the default value.

Enter wq and press enter to start the partition.

[root@iXXXXXX] # fdisk / dev/vdbWelcome 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): dSelected partition 1Partition 1 is deletedCommand (m for help): nPartition type:p primary (0 primary, 0 extended, 4 free) e extendedSelect (default p): Using default response pPartition number (1-4, default 1): First sector (2048-62914559, default 2048): Using default value 2048Last sector, + sectors or + size {KJM G} (2048-62914559, default 62914559): Using default value 62914559Partition 1 of type Linux and of size 30 GiB is setCommand (m for help): wqThe partition table has been altered calling ioctl () to re-read partition table.Syncing disks.

Description

If you are using the parted tool, enter the parted interface and type p to list the current partition. If there is a partition, use the rm+ serial number to delete the old partition table, then use unit s to define the starting position, the unit is measured by the number of sectors, and finally use the mkpart command to create it, as shown in the following figure.

In some operating systems, the file system may be automatically mounted again after the partition is modified. It is recommended that you first perform df-h to re-check the file system space and usage. If the file system is mounted again, execute umount [File system name] to unmount the file system again.

Check the file system and change the file system size.

E2fsck-f / dev/vdb1 # check file system resize2fs / dev/vdb1 # change file system size

Description

When using e2fsck, please wait patiently because the system needs to check and correct the file system metadata, so it is slow and time-consuming.

The correct use of e2fsck and resize2fs instructions will not result in the loss of original data.

The following is a sample output.

[root@iXXXXXX] # e2fsck-f / dev/vdb1e2fsck 1.42.9 (28-Dec-2013) Pass 1: Checking inodes, blocks, and sizesPass 2: Checking directory structurePass 3: Checking directory connectivityPass 4: Checking reference countsPass 5: Checking group summary information/dev/vdb1: 11Checking directory connectivityPass 1835008 files (0.0% non-contiguous), 159218Checking directory connectivityPass 7339776 blocks [root@iXXXXXX] # resize2fs / dev/vdb1resize2fs 1.42.9 (28-Dec-2013) Resizing the filesystem on/dev/vdb1 to 7864064 (4k) blocks.The filesystem on/dev/vdb1 is now 7864064 blocks long.

Mount the expanded file system to the original mount point (such as / resizetest in this example).

Mount / dev/vdb1 / resizetest

View file system space and usage: run the command df-h. If the expanded file system information appears, it means that the mount is successful and the expanded file system can be used.

Description

After the mount operation is completed, you do not need to restart the instance on the console to start using the expanded file system.

The following is a sample output.

[root@iXXXXXX ~] # df-hFilesystem Size Used Avail Use% Mounted on/dev/vda1 40G 1.5G 36G 4% / devtmpfs 487M 0 487M 0 / devtmpfs 497M 0497M 0% / dev/shmtmpfs 497M 312K 496M 1% / runtmpfs 497M 0497M 0% / sys/fs/cgrouptmpfs 100M 0100M 0% / run/user/0/dev/vdb1 30G 44M 28G 1% / resizetest

The above is the knowledge summary of data disk expansion, the content is more comprehensive, the editor believes that there may be some knowledge points that we may see or use in our daily work. I hope you can learn more from this article.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report