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 Docker image as it contains a very well packaged Fedora Minimal rootfs.
Docker images are available for x86_64 and ARM architectures here:
I am setting up my Raspberry Pi 2 in this example so I used the ARM image. The “host” operating system is LibreELEC media center, but this will work on any Linux distribution.
# make sure you are root sudo su # create a directory for Fedora mkdir -p /fedora cd /fedora # get the Docker image wget https://download.fedoraproject.org/pub/fedora/linux/releases/24/Docker/armhfp/images/Fedora-Docker-Base-24-1.2.armhfp.tar.xz
To unpack the image:
# unpack Docker image tar xvf Fedora-Docker-Base-24-1.2.armhfp.tar.xz --strip-components=1 # unpack the main tar tar xvpf layer.tar # cleanup rm layer.tar rm Fedora-Docker-Base-24-1.2.armhfp.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@f24chroot \W]\$ ' \ PATH=/bin:/usr/bin:/sbin:/usr/sbin:/bin \ /bin/bash --login echo "Exiting Fedora chroot" umount /fedora/dev/ umount /fedora/dev/pts 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 18.104.22.168 > /etc/resolv.conf.
That’s it, it is really very easy.