A Letter To Modern Music Analysis

I joined Medium in December of 2020, in the midst of the pandemic. As many did at the time, I needed an outlet for creative expression and maybe a little extra cash on the side. Initially just…


独家优惠奖金 100% 高达 1 BTC + 180 免费旋转

The wonders of chroot

You might have heard of the Linux chroot command, read about it or even got to use it. For me, the more I think about it, the more it feels like some sort of dark magic. To get it out of the way, when you run chroot you get to specify a new root filesystem for the current shell. The filesystem is not allowed to interact with the host filesystem, so it’s like being transported in a closed down container.

But chroot is much lighter than a container: it cannot have dedicated networking and it cannot map host users and host names. Basically it’s like you would take your own computer and magically switch its root filesystem with another. Beside the filesystem switch, everything else remains. One second you are in your usual Linux install and the next you are in a wholly different one, but with your same hardware. Like you would have instantly installed a different Linux.

So first of all, let’s see how it works. Let’s say we have a Fedora Workstation 36 live image: fedora-workstation-live-36.iso. We got it from the official website and didn’t touch it otherwise. Could we transport ourselves into this live image using chroot? Yes. First, let’s mount the image:

This being a live image, mount will inform us that the source is mounted as read-only. That’s fine for our exercise. The image has a squashfs image in it so we need to mount that too in a different place:

And yes, the squashfs image has in it the root filesystem so let’s mount that too, again in a different directory:

If we list the files in /mnt/fedora-root, we can see we reached our goal:

Add a comment

Related posts:

The Trickster

Everybody always wants a friend. Some people are easily fooled in times that are grim. Be careful, Be careful of the trickster. He and she, well they are out there. Looking for what you may think is…

2K x Lego

Lego is partnering with 2K to bring gamers a range of Lego sports games, the gaming publisher has just signed a multi-game partnership with the global toy company themselves! This has come as quite a…

C static libraries

When a C program is compiled, the compiler generates object code. After generating the object code, the compiler also invokes linker. One of the main tasks for linker is to make code of library…