Ubuntu disk expansion

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.
(img-Wo6MoZB1-1667969367144)(C:\Users\Lenovo\AppData\Local\Temp\1667967504079.png)]

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

insert image description here

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 -lto view the specific usage of disk space.

sudo fdisk -l

insert image description here

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/sdato /dev/sda3file systems.

parted /dev/sda		# 划分/dev/sda

1) Enter pto 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 qto exit.

insert image description here

Step 4 Application

In the previous step, we have allocated the disk. The next step is to apply.

resize2fs /dev/sda3 

insert image description here

Fifth Step Verification

Finally, it is the verification process. We enter again df -hto view the partition.

df -h

insert image description here

As you can see, we have successfully /expanded the root directory.

ok, it's over!

Reference article:

https://cloud.tencent.com/developer/article/1986094

Guess you like

Origin blog.csdn.net/weixin_51480590/article/details/127767660