I want to perform something similar to a 'clone' on vmware fusion/virtualbox/a VM manager.

Host and chroot are both ubuntu. One complicating factor may be that this chroot may have one or more child chroots. Just experimenting with one child right now.

So far I've tried this, but don't think I'm capturing EVERYTHING

# OUTSIDE THE CHROOT: Create a test chroot
cd ~
sudo apt-get install debootstrap dchroot
sudo debootstrap trusty my-chroot
sudo chroot my-chroot

# INSIDE THE CHROOT: Compress the chroot
mkdir -p /mnt/root
mount --bind / /mnt/root
tar --create --preserve-permissions --numeric-owner --verbose --gzip --file=/tmp/my-snapshot.tar.gz /mnt/root
umount /mnt/root

# OUTSIDE THE CHROOT: Decompress the chroot
cd ~
sudo tar --extract --preserve-permissions --verbose --file=/home/me/my-snapshot.tar.gz
sudo mv ./mnt/root/ my-chroot
sudo rm -rf ./mnt
sudo chroot my-chroot

I also am unsure how I can figure out whether I have successfully captured everything (symbolic links, hard links, permissions, etc)


  • Instead of tar(1), I think you should use star(1) which can also save Posix ACLs and xattrs. Also, you may want to run lsattr -R and save its output, because I think not even star(1) saves these attributes. – András Korn Jan 13 '16 at 20:07
  • Forget it, apparently tar(1) supports ACLs and xattrs too now, you just have to pass --acls --xattrs. – András Korn Jan 13 '16 at 20:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.