How can Centos7 expand disk space in virtual machines?
Description
Situation:You have created a disk in the VirtualBox Virtual Machine and installed the system. It is found that the disk space is too small and you need to add another disk size. Or the Centos7 system needs to expand disk space.
Procedure
1. Create a new disk in VirtualBox and select "add virtual hard disk"
2. Start the system that needs to expand the disk space and enter the terminal as root.
2.1 fdisk-l view disk Information
Explanation: the disk information of the system is marked in red. I added a/dev/sdb disk to the system, and the red box shows the partitions of the corresponding disk. (A disk can be divided into multiple zones)
3. Enter the Newly Added Disk for partitioning
Fdisk/dev/sdb
3.1 InputNAdd a new partition)
Step X in the Figure 3.2 indicates the setting of the new partition on the disk, step 2 indicates the category of the created partition, step 3 and step 4 set the start position of the partition, step 5 Save the partition settings and exit
(You can use fdisk-l to view the sdb1 partition in the/dev/sdb disk)
4. Format Disk Partitions
Mkfs. ext4/dev/sdb1
(Partition format is in ext4 format or another format)
5. Mount the partition of the new disk to the file directory.
Mkdir/data create a mount point
Mount-t ext4/dev/sdb1/work mount with mount
6. Set automatic mounting upon startup
Vi/etc/fstab
Add/dev/sdb1/data ext4 defaults 0 0 in the last row