The rsync command is the best tool for merging directory contents, as it is designed to synchronize files and directories recursively and efficiently, merging contents rather than attempting a direct overwrite of the directory itself.
-a: Archive mode, which preserves permissions, ownership, timestamps, and recursively copies directories.
-v: Verbose output (optional, but helpful to see progress).
-A (ACLs): Preserves Access Control Lists. This ensures advanced, fine-grained user permissions are not lost.
-X (Extended Attributes): Preserves extended file attributes. CentOS 9 Stream uses these heavily for SELinux security contexts. Without this flag, your system will likely fail to boot or block services due to SELinux denials.
rsync -av /path/to/source_dir/ /path/to/destination_dir/
sudo rsync -aAXv /* /mnt/newdrive --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/var/tmp/*,/run/*,/mnt/*,/media/*,/lost+found}
same command using copy (cp)
cp -r /path/to/source_dir/* /path/to/destination_dir/
After using rsync to merge the contents, you can safely remove the original source directory using rm -rf.
rm -rf /path/to/source_dir