Expansion of centos root directory in virtualbox

background

Virtualbox6.1 installed a mini version of centos7. The disk space was set to 8g during installation. Today, I checked that the size of the root directory partition is 6.2G, and there is not much free space. Use the du command to check, /sbin, /share, /bin The catalog occupies more than 4G in total, and there is nothing to delete, only the space is expanded.

The following picture is after I expanded it, and it has increased by more than 10G:

The following operations are for reference only, are related to the partition type, system environment, etc., and are not universal.

Root partition expansion

1. Create a new disk with a size of more than 10G (centos7_1.vdi)

2. Start the virtual machine to enter the system

3. Command: lsblk, check one more disk sdb, different types/environments may have different names

4. Use cfdisk /dev/sdb to partition the disk. The name I assigned is sdb5. When creating a new partition, select the logical partition. Type 8e. The picture is taken after I finish the operation. The actual operation process shows that it will not be the same as this. Exactly the same, ignore the sdb1 that I divided

For how to use cfdisk partitions, see here: https://blog.csdn.net/x763795151/article/details/106882988 , there is a partitioning step for reference

5. Create a physical volume: pvcreate /dev/sdb5

6. Look at the logical volume path: lvdisplay 

Just to expand this

7. Expansion: lvresize -L +10G /dev/centos/root /dev/sdb5, the lvresize command adjusts the size of the logical volume, you can take a look at the usage by man:

Check the volume group information, you can see that it has been enlarged:

Not over yet

8. Expand the file system: xfs_growfs /dev/centos/root

I used xfs_growfs because my file system type is xfs: you can see, if it is ext2/ext3/ext4, use resize2fs

Finished, finally look at the result:

Guess you like

Origin blog.csdn.net/x763795151/article/details/107358305