Ubuntu disk expansion
Because the author failed because of insufficient disk space when compiling the kernel, I have this disk expansion article. Alas, if I say too much, I will cry.
The first step is to expand the disk
First, we need to shut down the virtual machine, and then perform disk expansion in the settings. Here we expand the disk to 100GB.
One thing to note is that disk expansion is an expansion of the entire virtual machine. So if you have taken a snapshot before , you need to delete the snapshot before you can expand it.
The second step is to check the size of the system partition
Check the size of our system space.
df -h
It can be seen that the size of our root directory is only 29G, and there is only 13G of free space left.
Here you may have questions, why we have expanded the disk, but our partitions and files have not expanded?
Because the disk is only expanded here, but the space we expanded has not been used.
Enter the command fdisk -l
to view the specific usage of disk space.
sudo fdisk -l
It can be seen that we have indeed successfully expanded the disk capacity.
The third step is to allocate disk space
The next step is to allocate unused disk partitions /dev/sda
to /dev/sda3
file systems.
parted /dev/sda # 划分/dev/sda
1) Enter p
to view the total disk space and usage.
2) Expand capacity according to the serial number . The serial number of the system disk here is 3 .
3) Enter resizepart 3
, reallocate ext4 space. There will be a warning here, but that's okay, let's move on.
4) Set the end point of ext4 , the author entered it here 80GB
, but did not use up all the disk space. Because there may be other functions in the future, let's keep it for now.
5) Enter q
to exit.
Step 4 Application
In the previous step, we have allocated the disk. The next step is to apply.
resize2fs /dev/sda3
Fifth Step Verification
Finally, it is the verification process. We enter again df -h
to view the partition.
df -h
As you can see, we have successfully /
expanded the root directory.
ok, it's over!
Reference article:
https://cloud.tencent.com/developer/article/1986094