Tar copy

If I want to use tar to copy an existing filesystem to a device mounted as /mnt/device-a, would

Code:
tar -C / -cf - * | tar -C /mnt/device-a -xvf -

work? Or would /mnt/device-a be included in the source?

What is the recommended way of copying an existing filesystem to a new device?
 
The command will copy the entire contents of / to the directory /mnt/device-a/.

You will probably want to exclude a few directories though, as it stands it would also copy the contents of /dev/ and /mnt. Especially the latter could potentially cause a loop because you are writing to a subdirectory of /mnt.
 
Back
Top