1. home page
  2. Unclassified

[Note] Linux virtual machine extended partition and file system

According to Alibaba Cloud's Extended Partition and File System_Linux System Disk One document operation

Hard disk valuable data is priceless, please identify by yourself if the operation risk is high! For matters not covered in this article, please go to Alibaba Cloud to query or leave a message

The operating environment is: hyper-v virtual machine (theoretical ECS, virtual machine and other operations are the same)

The system in the virtual machine is Ubuntu 20.04 (all theoretical linux are universal)


When building a virtual machine, I dug a hole for myself. The hard disk space is limited to 10G. As the files are filled in, they become less and less used. Similar operations have been carried out under Windows before. It is thought that Linux can also be easily expanded. Who knew that Baidu was confused by all kinds of operations after the sky was full... Finally, a convenient and fast way to expand capacity was found in Alibaba Cloud's document station. (Security unknown)


Remind again! Please pay attention to data backup! And remember the disk partition in the process of operation,

1. Expanding virtual disks

Alibaba Cloud and other ECS servers can pay for capacity expansion on the management page. Read Part II after capacity expansion

The virtual disk of the virtual machine needs to be shut down first, and then find the edit in Disk Settings to expand your disk space according to the prompts.

2. Check whether the hard disk after capacity expansion can be recognized in the system

Log in to the server and run fdisk -l View disk location and capacity settings in the system

The red box is what we should pay attention to/ Dev/sda is the physical address of the hard disk, and 50G is the size of the disk.

The following sda2 is the second partition 10G of the hard disk. This is the partition we need to expand

3. Start capacity expansion

Install the growpart and xfsprogs resizing and formatting tools according to the operating system.

Please sudo - i enter root permission for permission operation

 CentOS 7, Aliyun Linux: use the next noodle command yum install cloud-utils-growpart yum install xfsprogs Ubuntu 14, Ubuntu 16, Ubuntu 18, Debian 9: use the noodle command apt install cloud-guest-utils apt install xfsprogs

Use the growpart tool to expand partitions

 Growpart<hard disk physical address><partition number>

For example, in the previous figure. Fruit cat operation growpart /dev/sda 2

After running successfully, enter df - h and find that the partition size has not changed. This is because the partition has been expanded but the file system has not. Run resize2fs/dev/sda2 to expand the file system.

The file system has been expanded. It can be used normally~

4. Summary

There are still some unclear points in the article, such as those supporting file systems. Some file systems are unusable. There are still risks. Backup is still the first.

score zero , full marks 5-star
zero ticket
fabulous zero
After reading and collecting, you can find it next time
  • Copyright notice: This article is published based on the Knowledge Sharing Attribution - Sharing in the Same Way 3.0 Mainland China License Agreement. Please follow this agreement for reprinting
  • Article link: https://moe.xin/1376.html [ copy ](Please indicate the source and link of this article when reprinting)
  • No relevant articles in this article
Previous:
: Next

1 comment

 gravatar

  1. Big man, meow meow

    #1st floor