VMware virtual machine Linux system disk expansion

VMware virtual machine Linux system disk expansion

Many friends use VMware to create virtual machines, and often choose the default disk size of 20G.
After using it, they find that 20G is not enough, and the service starts No.
Let us solve it together today, VMwarevirtual machineLinuxsystem disk expansion.

Check disk space

df -h

Focus on the selected logical volume name
The names of each system may not be the same
but they are all/dev/mapper What follows the beginning is the name of the logical volume

Check disk space on Linux

step:

  1. Add new disk to virtual machine
  2. Create partitions for new disk
  3. Format the newly created partition
  4. Create a physical volume for the partition you just formatted
  5. Add the just created physical volume to the logical volume that needs to be expanded.
  6. Increase file system size
  7. Comparison before and after verification expansion

Add new disk to virtual machine

  1. Edit virtual machine settings
    Edit virtual machine settings
  2. Add toEdit virtual machine settings
  3. After selecting the disk, click Next
    Add disk to virtual machine
  4. Check the recommended disk type and click Next
    Add disk to virtual machine
  5. Check Create a new disk and click Next
    Add disk to virtual machine
  6. Set the maximum disk size, check Store disk as a single file, and click Next
    Add disk to virtual machine
  7. Complete the wizard
    Insert image description here
  8. Confirm virtual machine settings
    Add disk to virtual machine
  9. Virtual machine after adding new disk
    Add disk to virtual machine

View disk information

fdisk -l

Red box Chinese new disk

Linux disk expansion

Create partition

Usefdisk /dev/sdb to create a partition and complete the following operations according to the wizard
First enter n to create a new partition
and then enter p primary Partition
Select the starting position of the partition and press Enter to use the default value
Select the end position of the partition and press Enter to use the default value
Then enter wq to save and exit
This creates a partition with a size of 200G

fdisk /dev/sdb

Linux disk partition

Format the newly created partition

mkfs is make filesystem to create a file system
Common Linux file systems are xfs and ext4
This case uses the xfs file system

mkfs.xfs -f /dev/sdb1

Format disk partition in Linux

ext4 and XFS are two common file systems in Linux operating systems. They are both modern, high-performance file systems, each with their own pros and cons. Here's how they compare:

Performance: XFS performs better than ext4 when handling large files and directories. ext4 performs better when processing small files and directories. In addition, XFS has better concurrent access performance and higher throughput.

Reliability: ext4 recovers faster than XFS after a file system crash, but XFS has better data protection capabilities. XFS has better metadata checksum recovery capabilities, allowing fast recovery even if the file system is damaged.

Scalability: XFS performs better in terms of scalability as it supports large storage and large files. At the same time, XFS supports online file system expansion, which can expand the file system without interrupting service. ext4 can also be extended online, but it is not as flexible as XFS.

Compatibility: ext4 is the default file system of Linux and has good compatibility with various Linux distributions and tools. It also supports other operating systems such as Windows and MacOSX. XFS has poor compatibility between Linux distributions, but is well compatible with other operating systems.

Function: ext4 supports functions such as encryption and snapshots, while XFS does not support encryption and snapshots. However, XFS supports advanced features such as file system management, space quotas, permission control, and file attributes, which are not so powerful in ext4.

Generally speaking, XFS is more suitable for large enterprise environments and large-capacity data storage, while ext4 is suitable for small and medium-sized enterprises and home users. Which file system to choose should be determined based on specific application scenarios and needs.

Create physical volumes for partitions

Use pvcreate /dev/sdb1 to create a physical volume
Prompt for warning input y Enter

pvcreate /dev/sdb1

Linux creates physical volume

View physical volume properties

pvdisplay

Linux View physical volume properties

Add a physical volume to a logical volume

Add the physical volume /dev/sdb1 to the logical volume centos_lihaozhe

vgextend centos_lihaozhe /dev/sdb1

Linux adds physical volume to logical volume

Increase file system size

xfs_growfs  /dev/mapper/centos_lihaozhe-root

Insert image description here

Comparison before and after verification expansion

df -h

Before expansion

Check disk space on Linux

After expansion

Check disk space on Linux

pvdisplay

Before expansion

Linux View physical volume properties

After expansion

Linux View physical volume properties

Guess you like

Origin blog.csdn.net/qq_24330181/article/details/134702754