Directory Migration Experiment
Migrate a directory to a new partition experiment (the migration directory must ensure that it cannot be accessed by the process for a certain period of time before it can be migrated). This article takes the migration of the /home directory as an example
Experimental steps:
1. fdisk /dev/sde first divide a new partition
2. mkfs.ext4 /dev/sde1 -L /home creates a filesystem for the new partition
3. mkdir /mnt/home creates a temporary home directory for use as migration data
4. mount /dev/sde1 /mnt/home to mount the temporary home directory on the new partition
5. init 1 switch to single-user mode (the network will be disconnected; operate on the host); avoid users still writing data during replication, resulting in inaccurate data
6. cp -av / home / * / mnt / home
7. ls /mnt/home/* Confirm that the files under /home are copied to /mnt/home
8. rm -rf /home/* Delete the data of the original partition in /home to avoid residual junk files ( Before doing this, be sure to confirm that the data under /home has been backed up )
9. Modify the /etc/fstab file
Add UUID=e0041648-d616-4844-908b-b815d6e835f9 /home ext4 defaults 0 0 to mount /home on the new partition
10. mount -a mounts /dev/sde1 to /home
11. df or mount to see if the hang is successful
12. ls /home/* Confirm whether the migration data is successful
13. umount /mnt/home to unmount the temporary home directory
14. rm -rf /mnt/home delete the temporary home directory
15. init 3 switch back to character login mode