Technology Sharing

Disk partition in Centos system

2024-07-12

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

Disk partition in Centos system

It is recommended to back up important data in advance.
Take the expansion of the root directory to 50G as an example:

1. Unmount the /home directory

umount /home

2. Delete the logical volume y to confirm

lvremove /dev/mapper/centos-home

3. Check with df -h, the /home directory is gone

4. Add 50G capacity to the root directory partition

lvextend -L +50G /dev/mapper/centos-root

5. Synchronize the file system

xfs_growfs /dev/mapper/centos-root

6. Create the /home directory back to 20G size, and create a 20G home directory logical volume

lvcreate -L 20G -n /dev/mapper/centos-home

7. Create a file system

mkfs.xfs /dev/mapper/centos-home

8. Mount the created file system

mount /dev/mapper/centos-home

Note: Different versions of the system may have different names for the files under /dev/. You can use the lsblk command to query the specific names and then perform corresponding operations.
insert image description here