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.
Tools/raw materials
-
Linux system -
Partition command
1. View existing partitions
-
Enter the command df - h on the terminal to view the partition[ root@localhost ~]# df -h END
2. Unload/home
-
Using[ root@localhost ~]#When umount/home uninstalls/home, the following prompt may appear, indicating that a program is occupying the partition. -
Next use[ root@localhost ~]#Fuser - km/home to terminate the occupied process. Then use[ root@localhost ~]#Umount/home Unloads the partition. -
Using[ root@localhost ~]#Df - h View that the partition has been uninstalled END
3. Resize partition
-
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. -
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. -
Using[ root@localhost ~]#The mount/home command mounts/home, and then uses df - h to view. You can see that/home has become 6G. -
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". -
[ 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. -
[ root@localhost ~]#Lvextend - L+8G/dev/sba1 Mount the idle space to/boot, and use resize2fs - p/dev/sba1 to activate it.