Quick and easy Fedora Minimal chroot
This is a quick guide on how to quickly make a Fedora Minimal chroot environment without any special tools. The only prerequisite is that you have root access on the machine you are using, and
chroot binary (or busybox even). I am also using
tar but you probably have that. :)
We are going to use a Container image as it contains a very well packaged Fedora Minimal rootfs.
Container images are available for x86_64 and ARM architectures here:
Lets get ready:
# make sure you are root sudo su - # create a directory for Fedora mkdir -p /fedora cd /fedora # get the Container image wget https://download.fedoraproject.org/linux/releases/34/Container/x86_64/images/Fedora-Container-Base-34-1.2.x86_64.tar.xz
To unpack the image:
# unpack Container image tar xvf Fedora-Container-Base-34-1.2.x86_64.tar.xz --strip-components=1 # unpack the main tar tar xvpf layer.tar # cleanup rm layer.tar rm Fedora-Container-Base-34-1.2.x86_64.tar.xz rm json rm VERSION
So you now have a base Fedora Minimal root filesystem in
It’s a good idea to create a script to enter it quickly. With your favorite text editor create
#!/bin/sh echo "Entering Fedora chroot" mount -t proc proc /fedora/proc/ mount -t sysfs sys /fedora/sys/ mount -o bind /dev /fedora/dev/ mount -o bind /dev /fedora/dev/pts chroot /fedora /bin/env -i \ HOME=/root TERM="$TERM" PS1='[\u@f34chroot \W]\$ ' \ PATH=/bin:/usr/bin:/sbin:/usr/sbin:/bin \ /bin/bash --login echo "Exiting Fedora chroot" umount /fedora/dev/pts umount /fedora/dev/ umount /fedora/sys/ umount /fedora/proc/ echo "Cleaned up"
and mark it as executable:
chmod +x /usr/bin/enter-fedora-chroot
Now you can enter Fedora from literally anywhere! Just run the script with
When inside the chroot, you will probably have to setup DNS to have working internet connection with a quick
echo nameserver 22.214.171.124 > /etc/resolv.conf.
That’s it, it is really very easy.
Copy and rewrite from: