# Tar copy



## balanga (Jun 8, 2018)

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


```
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?


----------



## SirDice (Jun 8, 2018)

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.


----------



## ShelLuser (Jun 8, 2018)

If this is a UFS based filesystem I'd suggest using dump(8) instead though.


----------

