1

I just created a rootfs with debootstrap in a Debian Jessie VirtualBox VM. Now I would like to transfer this to the host, by first compressing the directory to a tar archive, so I can upload it and download it again on the host.

I want the tar archive to preserve permissions and make an exact copy of the rootfs. So I used tar -czpvf --one-file-system like the Arch Linux Wiki suggests. However I get "tar: Exiting with failure status due to previous errors", those previous errors seem to "tar: $path: Cannot open: Permission denied" errors. I am afraid that running tar as root will modify the ownership/permissions of the files and directories in the rootfs folder. How do I preserve the permissions and ownership of this rootfs when compressing it to a gzipped tar?

  • Take a look at the selected answer here http://unix.stackexchange.com/questions/67375/is-copying-the-root-folder-an-adequate-form-of-backup (Is copying the root folder an adequate form of backup?) – iyrin May 08 '15 at 17:19

1 Answers1

2

To make a copy of a filesystem as you want you have to be root. In addition you need a "clean version". As such you want to use a bind mount of your root so you get the entire filesystem as is. You may even be able to bind mount read only if you're worried about tar.