When we use Linux, partitions may not be allocated reasonably during the initial installation, resulting in insufficient partitions after a period of use. Let's share the method of adjusting partitions, taking/home as an example.

 Anchor point Tools/raw materials

  • Linux system
  • Partition command

 Anchor point 1. View existing partitions

  • Enter the command df - h on the terminal to view the partition[ root@localhost ~]# df -h

    END

 Anchor point 2. Unload/home

  1. one

    Using[ root@localhost ~]#When umount/home uninstalls/home, the following prompt may appear, indicating that a program is occupying the partition.

  2. two

    Next use[ root@localhost ~]#Fuser - km/home to terminate the occupied process. Then use[ root@localhost ~]#Umount/home Unloads the partition.

  3. three

    Using[ root@localhost ~]#Df - h View that the partition has been uninstalled

    END

 Anchor point 3. Resize partition

  1. one

    Since the/home partition is under/dev/sda5[ root@localhost ~]#The resize2fs - p/dev/sda5 6G command sets the size. Here, I want the/home partition to become 6G.

  2. two

    Directly use the resize2fs - p/dev/sda5 6G command to set it. You may be prompted to first use the e2fsck - f/dev/sda5 6G command, and then execute the resize2fs - p/dev/sda5 6G command.

  3. three

    Using[ root@localhost ~]#The mount/home command mounts/home, and then uses df - h to view. You can see that/home has become 6G.

  4. four

    Next, to set the free space, you can use the vgdisplay command to view the information of the volume group. When using the lvreduce command, the space occupied by the LVM logical volume will be reduced, and the existing data on the logical volume may be deleted. Pay special attention to this. Remember to enter "y".

  5. five

    [ root@localhost ~]#Lvreduce - L 6G/dev/sda5 Note that uppercase L is set to 6G for the current file system, and lowercase - l is reduced by 6G from the current file system.

  6. six

    [ root@localhost ~]#Lvextend - L+8G/dev/sba1 Mount the idle space to/boot, and use resize2fs - p/dev/sba1 to activate it.

Post reply

Can't comment until