Interesting read. Thanks for sharing. Maybe it is by lack of experience, but I always treat tarballs like a loaded gun. I extract then inside an empty subdirectory in my home first just to be sure and then move the data as required. It is no fun having to cleanup the mess left by an incorrect extraction.
Any time you see a command starting with “sudo” and with a path of “/“ in the arguments, alarm bells should be going off. Here be dragons.
It’s funny how tar came out first. Then cpio came out which was a lot better but tar had the momentum and it never lost it. I still find cpio more controllable and use that as a preference.

But cpio existed when I first used Unix in 1982/3

I never understood why so few people use `pax` instead of `tar`. It has always seemed more user friendly to begin with.

With pax, the `-k` option will not overwrite existing files. Also not using `-p o` or `-p e` will not preserve rights. I don't know why you would extract and preserve rights to extract binaries in a chroot, usually you would want to control the permissions instead.

This reminds me once of using gparted on a disk.

I got in and out of it a few times to make sure what I was going to do, then I launched it again (but I didn't add any arguments).

Not only didn't it complain, it defaulted to my root disk, and I ended up destroying my partition table.

Luckily the system was still running and I was able to backup everything before I shut the system down.

Never untar anything to /. In this case, inexpensive, but a very valuable lesson.
Bubblewrap will allow you to create a chroot for xbps. No root needed. If $HOME/void_chroot is a void rootfs:

       bwrap --bind $HOME/void_chroot/  /  --ro-bind /etc/resolv.conf /etc/resolv.conf  --rw-bind /home/ /home/  --proc /proc --dev /dev /bin/sh
Instead of xchroot, use bwrap.
I'm kind of annoyed that tar doesn't back up directories starting with a period unless you throw in a command flag.

I wish I knew this before taking a backup and reformatting.

Always test your backups I guess..

If I'm reading this right, using --no-overwrite-dir should have prevented this, I think.

I'd still extract to a local folder as nonroot, though, so still the right conclusion.

Been there. That was an interesting day.
ah the joys of tar...the one time I got the input and output args confused and I lost a lot of data woops
Alternative title: How to destroy your OS by not understanding your OS.

Don't take this the wrong way. Nice write up. :)


Sudo ... why would you sudo a command that you don't understand?

RTFM ... all of the behaviour you experienced is well documented. There are no surprises.

POSIX and UNIX utils are flexible and powerful. This is why we love them. Don't blame the hammer.

Sandbox anything you extract and review it. Extract in a test environment. Extract without sudo and copy the files and permissions you need.

tar -tv is simply tests the archive and outputs the paths. You ignored what it told you - that it would overwrite ./ :)

#### Never ever do this! $ sudo tar -C / -xvfp xbps-static-latest.x86_64-musl.tar.xz


Cheers :)