Resize CentOS 7 Root Directory: Step-by-Step Guide
To expand the root directory of CentOS 7, you can follow these steps:
- Firstly, make sure you have a partition or disk space available to expand the root directory. You can use the fdisk command to view the available disk space on the system.
- Create a new partition and mount it to a temporary directory. Use the fdisk command to create the partition and the mkfs command to format it with the desired file system type.
- Use the temporary directory as the mounting point to mount the partition onto it. This step can be completed using the mount command.
- Copy the contents of the root directory to the temporary directory. This can be done using the rsync command.
- Copy all files and directories from the root directory to the /mnt/temp/ directory.
- This will recursively copy all files and directories from the root directory to a temporary directory.
- Create a backup in the root directory and copy its contents to a new partition. This can be done using the tar command.
- Create a backup of the root directory excluding the temporary folder, then extract the backup into the temporary folder.
- This will create a backup file named root_backup.tar and extract its contents to a temporary directory.
- Unmount the temporary directory and mount the new partition to the root directory. You can use the umount and mount commands to complete this step.
- Update the /etc/fstab file to add the new partition as a permanent mount point for the root directory.
- Please restart the system to apply the changes.
It is highly recommended to backup important data before performing these operations. Additionally, if you are not familiar with disk operations, it is advised to seek guidance from a professional to prevent data loss or system damage.