<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.fex-emu.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Nottucks</id>
	<title>FEX-Emu Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.fex-emu.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Nottucks"/>
	<link rel="alternate" type="text/html" href="https://wiki.fex-emu.com/index.php/Special:Contributions/Nottucks"/>
	<updated>2026-05-19T02:12:13Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.0</generator>
	<entry>
		<id>https://wiki.fex-emu.com/index.php?title=Development:Setting_up_RootFS&amp;diff=1497</id>
		<title>Development:Setting up RootFS</title>
		<link rel="alternate" type="text/html" href="https://wiki.fex-emu.com/index.php?title=Development:Setting_up_RootFS&amp;diff=1497"/>
		<updated>2026-01-12T22:53:33Z</updated>

		<summary type="html">&lt;p&gt;Nottucks: /* Chrooting in to rootfs with FEX-Emu Rootfs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Development]]&lt;br /&gt;
= Setting up a RootFS =&lt;br /&gt;
'''For AArch64 hosts you are required to have an x86-64 rootfs'''. With or without 32bit compatibility libraries.&lt;br /&gt;
&lt;br /&gt;
This isn't strictly required for testing on x86-64 host environments but is useful for ensuring correct behaviour there.&lt;br /&gt;
&lt;br /&gt;
= Quick Setup with FEXRootFSFetcher =&lt;br /&gt;
FEX comes with a FEXRootFSFetcher tool that can download an official preconfigured rootfs from the FEX servers.&lt;br /&gt;
This tool operates as either a terminal application or a Zenity application depending on if it is launched from terminal or not.&lt;br /&gt;
&lt;br /&gt;
This tool will walk you through selecting a RootFS for FEX:&lt;br /&gt;
* If your host OS matches one in the download list then it will recommend that one&lt;br /&gt;
* After selecting the RootFS, it will download it&lt;br /&gt;
** This downloads to the default location in '''$HOME/.fex-emu/RootFS/'''&lt;br /&gt;
* After downloading the RootFS the tool will ask if you want to use the SquashFS file directly or extract it&lt;br /&gt;
* It will then ask if you want to set the downloaded RootFS as your default&lt;br /&gt;
** This writes to the default configuration in '''$HOME/.fex-emu/Config.json'''&lt;br /&gt;
&lt;br /&gt;
You can skip the rest of the guide if you used FEXRootFSFetcher to download the rootfs.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
* The squashfs image will fail to extract if you don't have unsquashfs installed&lt;br /&gt;
** Install the squashfs-tools package to get this application&lt;br /&gt;
&lt;br /&gt;
* '''SquashFS RootFS file corrupted?'''&lt;br /&gt;
** Rerun the tool, select the rootfs from the list, and if the rootfs already exists it will ask to verify&lt;br /&gt;
** If verification fails it will ask if you want to redownload&lt;br /&gt;
* '''Want to manually check the hash?'''&lt;br /&gt;
** Run the rootfs file directly through the tool to get a hash&lt;br /&gt;
** '''FEXRootFSFetcher $HOME/.fex-emu/RootFS/Ubuntu_21_10.sqsh'''&lt;br /&gt;
** Ubuntu_21_10.sqsh has hash: bf9507fbdbaec2cf&lt;br /&gt;
* '''Want to use the Zenity UI but still launch through terminal?'''&lt;br /&gt;
** Force Zenity from terminal with '''FEXRootFSFetcher 1&amp;gt; /dev/null'''&lt;br /&gt;
* '''What if my Linux distro isn't listed?'''&lt;br /&gt;
** Don't worry, select one that is most similar to yours or newest&lt;br /&gt;
** This will work in most cases&lt;br /&gt;
* '''How can I trust these images?'''&lt;br /&gt;
** These images are generated by scripts living in our public repo&lt;br /&gt;
** If you want to rebuild them yourself, you are free to do so.&lt;br /&gt;
** https://github.com/FEX-Emu/RootFS&lt;br /&gt;
* '''I want to add a distro'''&lt;br /&gt;
** Follow how our current rootfs is generated and add your own&lt;br /&gt;
** Open a pull request to add the rootfs setup&lt;br /&gt;
** Contact us on the official FEX-Emu Discord to get the RootFS added to the server.&lt;br /&gt;
* '''Where is the raw list of images at?'''&lt;br /&gt;
** The image links live on our website at the following link&lt;br /&gt;
** https://rootfs.fex-emu.gg/RootFS_links.json&lt;br /&gt;
** This file is in a format that our tool understands&lt;br /&gt;
** Generally the format is:&lt;br /&gt;
*** Distro Name&lt;br /&gt;
*** Distro Version&lt;br /&gt;
*** Human readable name&lt;br /&gt;
*** Raw rootfs link&lt;br /&gt;
*** xxhash based file hash&lt;br /&gt;
&lt;br /&gt;
= Making a custom rootfs prerequisites =&lt;br /&gt;
An x86-64 PC or FEX-Emu installed for chrooting&lt;br /&gt;
&lt;br /&gt;
= Getting Started =&lt;br /&gt;
The easiest way to get started is to just download a prebuilt x86-64 rootfs from your favourite distribution and extract it to where you want.&lt;br /&gt;
* Ubuntu - http://cdimage.ubuntu.com/ubuntu-base/releases/&lt;br /&gt;
* Debian Debootstrap guide - https://wiki.debian.org/Debootstrap&lt;br /&gt;
** Debootstrap is more involved and not explained here.&lt;br /&gt;
&lt;br /&gt;
Using chroot you can then enter the rootfs and install applications that you desire for testing purposes.&lt;br /&gt;
It's easiest to set this up on an x86-64 host and then copy it to an AArch64 device.&lt;br /&gt;
&lt;br /&gt;
== Cross architecture chroot ==&lt;br /&gt;
'''You need to have binfmt_misc setup for x86-64 support on your host system.'''&lt;br /&gt;
* ls /proc/sys/fs/binfmt_misc &lt;br /&gt;
** If there are files in this folder then your host supports binfmt_misc&lt;br /&gt;
* Once you have binfmt_misc running and FEX-Emu installed in to it, you can chroot in to an x86-64 rootfs&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Chrooting in to rootfs with FEX-Emu Rootfs ==&lt;br /&gt;
* If you're using a FEX-Emu provided RootFS then we provide a script to handle this.&lt;br /&gt;
** This script can be called uing '''./chroot.py chroot''' inside the root directory of the RootFS.&lt;br /&gt;
** When you finish, make sure to exit the chroot cleanly.&lt;br /&gt;
If the chroot is working, the remaining steps of this guide can safely be skipped.&lt;br /&gt;
&lt;br /&gt;
* Issues&lt;br /&gt;
** As of January 12th, 2026, Fedora packages for FEX-Emu are a few months out of date. &lt;br /&gt;
** This causes the chroot script to fail, saying &amp;quot;Host program 'FEX' isn't available and is required!&amp;quot;.&lt;br /&gt;
** The solution is to copy &amp;quot;/usr/bin/FEXInterpreter&amp;quot; to &amp;quot;/usr/bin/FEX&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Chrooting in to custom rootfs with FEX-Emu ==&lt;br /&gt;
* If you're setting up your own rootfs then you need to follow the binding steps that are following.&lt;br /&gt;
** We have a script that if you know what you're doing you can cherry pick parts from [https://github.com/FEX-Emu/RootFS/blob/main/unbreak_chroot.sh here]&lt;br /&gt;
&lt;br /&gt;
= Additional TmpFS folders =&lt;br /&gt;
Depending on what you're doing in the chroot, you may need or want some tmpfs folders that applications are expecting&lt;br /&gt;
&lt;br /&gt;
* sudo mount -t proc /proc ${ROOTFS}/proc/&lt;br /&gt;
* sudo mount --rbind --make-rslave /sys ${ROOTFS}/sys/&lt;br /&gt;
* sudo mount --rbind --make-rslave /dev ${ROOTFS}/dev/&lt;br /&gt;
* sudo mount --rbind --make-rslave /dev/pts ${ROOTFS}/dev/pts/&lt;br /&gt;
* sudo mount --rbind /lib/ld-linux-aarch64.so.1 ${ROOTFS}/lib/ld-linux-aarch64.so.1&lt;br /&gt;
* sudo mount --rbind /lib/aarch64-linux-gnu ${ROOTFS}/lib/aarch64-linux-gnu&lt;br /&gt;
&lt;br /&gt;
Then of course, make sure to unmount these partitions when you're done&lt;br /&gt;
&lt;br /&gt;
* sudo umount ${ROOTFS}/proc/&lt;br /&gt;
* sudo umount -R ${ROOTFS}/sys/&lt;br /&gt;
* sudo umount -R ${ROOTFS}/dev/pts/&lt;br /&gt;
* sudo umount -R ${ROOTFS}/dev/&lt;br /&gt;
* sudo umount -R ${ROOTFS}/lib/ld-linux-aarch64.so.1&lt;br /&gt;
* sudo umount -R ${ROOTFS}/lib/aarch64-linux-gnu&lt;br /&gt;
&lt;br /&gt;
= Using the RootFS with FEX =&lt;br /&gt;
&lt;br /&gt;
Run the graphical FEXConfig tool to select and change the active RootFS. Any file or folder in $HOME/.fex-emu/RootFS will be detected automatically.&lt;br /&gt;
&lt;br /&gt;
= Additional Steps for building a custom rootfs = &lt;br /&gt;
== Running under WSL1 ==&lt;br /&gt;
/etc/hosts and /etc/resolv.conf change on the host side. You'll need to copy those over to the rootfs if you want network functionality to work.&lt;br /&gt;
&lt;br /&gt;
== Ubuntu packages to install ==&lt;br /&gt;
Sample packages to install in the rootfs&lt;br /&gt;
* apt-get install pulseaudio libgles1 libgles2 libglx-mesa0 libgl1-mesa-dri libgl1-mesa-glx mesa-utils mesa-utils-extra&lt;br /&gt;
Pulseaudio specifically is required so pulseaudio will work when talking to the host pulseaudio&lt;br /&gt;
&lt;br /&gt;
== File deletion ==&lt;br /&gt;
Some files need to be deleted from the rootfs otherwise some applications will fail to work.&lt;br /&gt;
&lt;br /&gt;
Note that deleting these files '''WILL''' break the rootfs and you won't be able to chroot in to it anymore.&lt;br /&gt;
&lt;br /&gt;
A likely better route would be a script that moves these files and folders then brings them back when you want to chroot&lt;br /&gt;
&lt;br /&gt;
=== Files to remove ===&lt;br /&gt;
* ${ROOTFS}/etc/hosts&lt;br /&gt;
* ${ROOTFS}/etc/resolv.conf&lt;br /&gt;
* ${ROOTFS}/etc/timezone&lt;br /&gt;
* ${ROOTFS}/etc/localtime&lt;br /&gt;
* ${ROOTFS}/etc/passwd&lt;br /&gt;
&lt;br /&gt;
=== Folders to remove ===&lt;br /&gt;
* ${ROOTFS}/boot&lt;br /&gt;
* ${ROOTFS}/dev&lt;br /&gt;
* ${ROOTFS}/home&lt;br /&gt;
* ${ROOTFS}/media&lt;br /&gt;
* ${ROOTFS}/mnt&lt;br /&gt;
* ${ROOTFS}/proc&lt;br /&gt;
* ${ROOTFS}/root&lt;br /&gt;
* ${ROOTFS}/srv&lt;br /&gt;
* ${ROOTFS}/tmp&lt;br /&gt;
* ${ROOTFS}/var/cache/apt&lt;br /&gt;
* ${ROOTFS}/var/lib/apt&lt;br /&gt;
* ${ROOTFS}/sys&lt;br /&gt;
* ${ROOTFS}/opt&lt;br /&gt;
&lt;br /&gt;
== Creating a Squashfs rootfs from custom rootfs ==&lt;br /&gt;
SquashFS is a great way to do binary distribution of the rootfs. If you have created a rootfs and you want to roll it in to a squashfs like the FEX-Emu provided images then this is information on how to do that.&lt;br /&gt;
&lt;br /&gt;
'''SquashFS is currently only recommended for binary distribution. User should unpack it to not get dangling processes and mounts.'''&lt;br /&gt;
* Offers tooling to mount in userspace&lt;br /&gt;
* Supports ZSTD compression&lt;br /&gt;
* Is a readonly partition that matches FEX's use case&lt;br /&gt;
&lt;br /&gt;
=== Tools that FEX needs to run squashfs ===&lt;br /&gt;
* squashfuse&lt;br /&gt;
* fusermount&lt;br /&gt;
&lt;br /&gt;
=== Making the squashfs image ===&lt;br /&gt;
Making the squashfs image is very straightforward&lt;br /&gt;
* mksquashfs ${ROOTFS}/ Squashfs.sqsh -comp zstd&lt;br /&gt;
&lt;br /&gt;
This creates a file called Squashfs.sqsh that contains the original rootfs that we generated above.&lt;br /&gt;
&lt;br /&gt;
=== Using the squashfs image in FEX ===&lt;br /&gt;
* Copy the resulting sqsh file in to ${XDG_DATA_HOME}/.fex-emu/RootFS/&lt;br /&gt;
** If ${XDG_DATA_HOME} doesn't exist then that will be replaced with ${HOME}&lt;br /&gt;
* Use FEXConfig to select the sqsh file as a named rootfs&lt;br /&gt;
* or pass the name in to the FEX_ROOTFS argument in the various ways FEX supports&lt;br /&gt;
* or the absolute path if you don't want it in the FEX RootFS folder&lt;br /&gt;
&lt;br /&gt;
=== Extracting the squashfs ===&lt;br /&gt;
If you don't want to use squashfs for whatever reason then you can extract it in to the FEX RootFS folder and use the directory directly&lt;br /&gt;
* unsquashfs -f -d NewRootFS/ Squashfs.sqsh&lt;br /&gt;
&lt;br /&gt;
=== If you want to install packages in the squashfs ===&lt;br /&gt;
The squashfs image is immutable and can't be modified.&lt;br /&gt;
* Extract the squashfs first&lt;br /&gt;
* Change the working directory to the rootfs&lt;br /&gt;
* execute `unbreak_chroot.sh`&lt;br /&gt;
* `apt-get update`&lt;br /&gt;
* `apt-get install &amp;lt;Whatever you want&amp;gt;`&lt;br /&gt;
* `exit` to leave the chroot&lt;br /&gt;
* Use the new extracted chroot directly, or follow the previous steps to recompress it to a squashfs format.&lt;br /&gt;
&lt;br /&gt;
=== Known problems with squashfs ===&lt;br /&gt;
'''FEX automatically mounts your squashfs file and can leave dangling squashfs mounts around in some instances.'''&lt;br /&gt;
* '''This is fairly rare but it can occur. Whenever an instance of FEX is run, it registers with the FEXMountDaemon'''&lt;br /&gt;
** FEXMountDaemon then watches these instances of FEX to ensure they have exited before unmounting&lt;br /&gt;
** There is roughly a ten second grace period of no instances of FEX running before unmounting&lt;br /&gt;
** If an instance of FEX starts running then it will reuse the mount partition and reset the timeout&lt;br /&gt;
* To get rid of these dangling mounts if they do manage to manifest, use the following commands&lt;br /&gt;
** fusermount -u /tmp/.FEXMount* ; rmdir /tmp/.FEXMount*&lt;br /&gt;
** These don't require root to unmount&lt;br /&gt;
* In some cases the unmounting can end up returning busy status and not unmount&lt;br /&gt;
** Check the output of `mount` for any /tmp/.FEXMount folders&lt;br /&gt;
** This is due to either FEXMountDaemon or squashfuse still running in the background&lt;br /&gt;
** Can force the application to exit&lt;br /&gt;
** step 1: kill `pidof squashfuse`&lt;br /&gt;
** This will attempt to send SIGTERM to all squashfuse applications, which will unmount the partition on terminate&lt;br /&gt;
** Failing that, you can try to be more abusive&lt;br /&gt;
** kill -9 `pidof FEXMountDaemon`&lt;br /&gt;
** This will forcibly terminate FEXMountDaemon which should also take out the child mounted process&lt;br /&gt;
* If any instances of the mount still exists then you may need to kill more FEX processes.&lt;br /&gt;
** Any ''FEX'' process will end up keeping the folder mounted and keep it busy&lt;br /&gt;
&lt;br /&gt;
'''strace breaks squashfs'''&lt;br /&gt;
* If you run FEX with `strace -f` then the process that mounts your rootfs loses its setuid bit.&lt;br /&gt;
** This means you then can't mount the rootFS&lt;br /&gt;
* The only workaround is to not use a squashfs in this instance.&lt;br /&gt;
* Alternatively you can spin up a FEXBash instance to force squashfs to be mounted. Then strace a different FEX instance which will use the mounted squashfs location.&lt;/div&gt;</summary>
		<author><name>Nottucks</name></author>
	</entry>
	<entry>
		<id>https://wiki.fex-emu.com/index.php?title=Development:Setting_up_RootFS&amp;diff=1496</id>
		<title>Development:Setting up RootFS</title>
		<link rel="alternate" type="text/html" href="https://wiki.fex-emu.com/index.php?title=Development:Setting_up_RootFS&amp;diff=1496"/>
		<updated>2026-01-12T22:53:18Z</updated>

		<summary type="html">&lt;p&gt;Nottucks: /* Chrooting in to rootfs with FEX-Emu Rootfs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Development]]&lt;br /&gt;
= Setting up a RootFS =&lt;br /&gt;
'''For AArch64 hosts you are required to have an x86-64 rootfs'''. With or without 32bit compatibility libraries.&lt;br /&gt;
&lt;br /&gt;
This isn't strictly required for testing on x86-64 host environments but is useful for ensuring correct behaviour there.&lt;br /&gt;
&lt;br /&gt;
= Quick Setup with FEXRootFSFetcher =&lt;br /&gt;
FEX comes with a FEXRootFSFetcher tool that can download an official preconfigured rootfs from the FEX servers.&lt;br /&gt;
This tool operates as either a terminal application or a Zenity application depending on if it is launched from terminal or not.&lt;br /&gt;
&lt;br /&gt;
This tool will walk you through selecting a RootFS for FEX:&lt;br /&gt;
* If your host OS matches one in the download list then it will recommend that one&lt;br /&gt;
* After selecting the RootFS, it will download it&lt;br /&gt;
** This downloads to the default location in '''$HOME/.fex-emu/RootFS/'''&lt;br /&gt;
* After downloading the RootFS the tool will ask if you want to use the SquashFS file directly or extract it&lt;br /&gt;
* It will then ask if you want to set the downloaded RootFS as your default&lt;br /&gt;
** This writes to the default configuration in '''$HOME/.fex-emu/Config.json'''&lt;br /&gt;
&lt;br /&gt;
You can skip the rest of the guide if you used FEXRootFSFetcher to download the rootfs.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
* The squashfs image will fail to extract if you don't have unsquashfs installed&lt;br /&gt;
** Install the squashfs-tools package to get this application&lt;br /&gt;
&lt;br /&gt;
* '''SquashFS RootFS file corrupted?'''&lt;br /&gt;
** Rerun the tool, select the rootfs from the list, and if the rootfs already exists it will ask to verify&lt;br /&gt;
** If verification fails it will ask if you want to redownload&lt;br /&gt;
* '''Want to manually check the hash?'''&lt;br /&gt;
** Run the rootfs file directly through the tool to get a hash&lt;br /&gt;
** '''FEXRootFSFetcher $HOME/.fex-emu/RootFS/Ubuntu_21_10.sqsh'''&lt;br /&gt;
** Ubuntu_21_10.sqsh has hash: bf9507fbdbaec2cf&lt;br /&gt;
* '''Want to use the Zenity UI but still launch through terminal?'''&lt;br /&gt;
** Force Zenity from terminal with '''FEXRootFSFetcher 1&amp;gt; /dev/null'''&lt;br /&gt;
* '''What if my Linux distro isn't listed?'''&lt;br /&gt;
** Don't worry, select one that is most similar to yours or newest&lt;br /&gt;
** This will work in most cases&lt;br /&gt;
* '''How can I trust these images?'''&lt;br /&gt;
** These images are generated by scripts living in our public repo&lt;br /&gt;
** If you want to rebuild them yourself, you are free to do so.&lt;br /&gt;
** https://github.com/FEX-Emu/RootFS&lt;br /&gt;
* '''I want to add a distro'''&lt;br /&gt;
** Follow how our current rootfs is generated and add your own&lt;br /&gt;
** Open a pull request to add the rootfs setup&lt;br /&gt;
** Contact us on the official FEX-Emu Discord to get the RootFS added to the server.&lt;br /&gt;
* '''Where is the raw list of images at?'''&lt;br /&gt;
** The image links live on our website at the following link&lt;br /&gt;
** https://rootfs.fex-emu.gg/RootFS_links.json&lt;br /&gt;
** This file is in a format that our tool understands&lt;br /&gt;
** Generally the format is:&lt;br /&gt;
*** Distro Name&lt;br /&gt;
*** Distro Version&lt;br /&gt;
*** Human readable name&lt;br /&gt;
*** Raw rootfs link&lt;br /&gt;
*** xxhash based file hash&lt;br /&gt;
&lt;br /&gt;
= Making a custom rootfs prerequisites =&lt;br /&gt;
An x86-64 PC or FEX-Emu installed for chrooting&lt;br /&gt;
&lt;br /&gt;
= Getting Started =&lt;br /&gt;
The easiest way to get started is to just download a prebuilt x86-64 rootfs from your favourite distribution and extract it to where you want.&lt;br /&gt;
* Ubuntu - http://cdimage.ubuntu.com/ubuntu-base/releases/&lt;br /&gt;
* Debian Debootstrap guide - https://wiki.debian.org/Debootstrap&lt;br /&gt;
** Debootstrap is more involved and not explained here.&lt;br /&gt;
&lt;br /&gt;
Using chroot you can then enter the rootfs and install applications that you desire for testing purposes.&lt;br /&gt;
It's easiest to set this up on an x86-64 host and then copy it to an AArch64 device.&lt;br /&gt;
&lt;br /&gt;
== Cross architecture chroot ==&lt;br /&gt;
'''You need to have binfmt_misc setup for x86-64 support on your host system.'''&lt;br /&gt;
* ls /proc/sys/fs/binfmt_misc &lt;br /&gt;
** If there are files in this folder then your host supports binfmt_misc&lt;br /&gt;
* Once you have binfmt_misc running and FEX-Emu installed in to it, you can chroot in to an x86-64 rootfs&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Chrooting in to rootfs with FEX-Emu Rootfs ==&lt;br /&gt;
* If you're using a FEX-Emu provided RootFS then we provide a script to handle this.&lt;br /&gt;
** This script can be called uing '''./chroot.py chroot''' inside the root directory of the RootFS.&lt;br /&gt;
** When you finish, make sure to exit the chroot cleanly.&lt;br /&gt;
If the chroot is working, the remaining steps of this guide can safely be skipped.&lt;br /&gt;
&lt;br /&gt;
Issues&lt;br /&gt;
* As of January 12th, 2026, Fedora packages for FEX-Emu are a few months out of date. &lt;br /&gt;
* This causes the chroot script to fail, saying &amp;quot;Host program 'FEX' isn't available and is required!&amp;quot;.&lt;br /&gt;
* The solution is to copy &amp;quot;/usr/bin/FEXInterpreter&amp;quot; to &amp;quot;/usr/bin/FEX&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Chrooting in to custom rootfs with FEX-Emu ==&lt;br /&gt;
* If you're setting up your own rootfs then you need to follow the binding steps that are following.&lt;br /&gt;
** We have a script that if you know what you're doing you can cherry pick parts from [https://github.com/FEX-Emu/RootFS/blob/main/unbreak_chroot.sh here]&lt;br /&gt;
&lt;br /&gt;
= Additional TmpFS folders =&lt;br /&gt;
Depending on what you're doing in the chroot, you may need or want some tmpfs folders that applications are expecting&lt;br /&gt;
&lt;br /&gt;
* sudo mount -t proc /proc ${ROOTFS}/proc/&lt;br /&gt;
* sudo mount --rbind --make-rslave /sys ${ROOTFS}/sys/&lt;br /&gt;
* sudo mount --rbind --make-rslave /dev ${ROOTFS}/dev/&lt;br /&gt;
* sudo mount --rbind --make-rslave /dev/pts ${ROOTFS}/dev/pts/&lt;br /&gt;
* sudo mount --rbind /lib/ld-linux-aarch64.so.1 ${ROOTFS}/lib/ld-linux-aarch64.so.1&lt;br /&gt;
* sudo mount --rbind /lib/aarch64-linux-gnu ${ROOTFS}/lib/aarch64-linux-gnu&lt;br /&gt;
&lt;br /&gt;
Then of course, make sure to unmount these partitions when you're done&lt;br /&gt;
&lt;br /&gt;
* sudo umount ${ROOTFS}/proc/&lt;br /&gt;
* sudo umount -R ${ROOTFS}/sys/&lt;br /&gt;
* sudo umount -R ${ROOTFS}/dev/pts/&lt;br /&gt;
* sudo umount -R ${ROOTFS}/dev/&lt;br /&gt;
* sudo umount -R ${ROOTFS}/lib/ld-linux-aarch64.so.1&lt;br /&gt;
* sudo umount -R ${ROOTFS}/lib/aarch64-linux-gnu&lt;br /&gt;
&lt;br /&gt;
= Using the RootFS with FEX =&lt;br /&gt;
&lt;br /&gt;
Run the graphical FEXConfig tool to select and change the active RootFS. Any file or folder in $HOME/.fex-emu/RootFS will be detected automatically.&lt;br /&gt;
&lt;br /&gt;
= Additional Steps for building a custom rootfs = &lt;br /&gt;
== Running under WSL1 ==&lt;br /&gt;
/etc/hosts and /etc/resolv.conf change on the host side. You'll need to copy those over to the rootfs if you want network functionality to work.&lt;br /&gt;
&lt;br /&gt;
== Ubuntu packages to install ==&lt;br /&gt;
Sample packages to install in the rootfs&lt;br /&gt;
* apt-get install pulseaudio libgles1 libgles2 libglx-mesa0 libgl1-mesa-dri libgl1-mesa-glx mesa-utils mesa-utils-extra&lt;br /&gt;
Pulseaudio specifically is required so pulseaudio will work when talking to the host pulseaudio&lt;br /&gt;
&lt;br /&gt;
== File deletion ==&lt;br /&gt;
Some files need to be deleted from the rootfs otherwise some applications will fail to work.&lt;br /&gt;
&lt;br /&gt;
Note that deleting these files '''WILL''' break the rootfs and you won't be able to chroot in to it anymore.&lt;br /&gt;
&lt;br /&gt;
A likely better route would be a script that moves these files and folders then brings them back when you want to chroot&lt;br /&gt;
&lt;br /&gt;
=== Files to remove ===&lt;br /&gt;
* ${ROOTFS}/etc/hosts&lt;br /&gt;
* ${ROOTFS}/etc/resolv.conf&lt;br /&gt;
* ${ROOTFS}/etc/timezone&lt;br /&gt;
* ${ROOTFS}/etc/localtime&lt;br /&gt;
* ${ROOTFS}/etc/passwd&lt;br /&gt;
&lt;br /&gt;
=== Folders to remove ===&lt;br /&gt;
* ${ROOTFS}/boot&lt;br /&gt;
* ${ROOTFS}/dev&lt;br /&gt;
* ${ROOTFS}/home&lt;br /&gt;
* ${ROOTFS}/media&lt;br /&gt;
* ${ROOTFS}/mnt&lt;br /&gt;
* ${ROOTFS}/proc&lt;br /&gt;
* ${ROOTFS}/root&lt;br /&gt;
* ${ROOTFS}/srv&lt;br /&gt;
* ${ROOTFS}/tmp&lt;br /&gt;
* ${ROOTFS}/var/cache/apt&lt;br /&gt;
* ${ROOTFS}/var/lib/apt&lt;br /&gt;
* ${ROOTFS}/sys&lt;br /&gt;
* ${ROOTFS}/opt&lt;br /&gt;
&lt;br /&gt;
== Creating a Squashfs rootfs from custom rootfs ==&lt;br /&gt;
SquashFS is a great way to do binary distribution of the rootfs. If you have created a rootfs and you want to roll it in to a squashfs like the FEX-Emu provided images then this is information on how to do that.&lt;br /&gt;
&lt;br /&gt;
'''SquashFS is currently only recommended for binary distribution. User should unpack it to not get dangling processes and mounts.'''&lt;br /&gt;
* Offers tooling to mount in userspace&lt;br /&gt;
* Supports ZSTD compression&lt;br /&gt;
* Is a readonly partition that matches FEX's use case&lt;br /&gt;
&lt;br /&gt;
=== Tools that FEX needs to run squashfs ===&lt;br /&gt;
* squashfuse&lt;br /&gt;
* fusermount&lt;br /&gt;
&lt;br /&gt;
=== Making the squashfs image ===&lt;br /&gt;
Making the squashfs image is very straightforward&lt;br /&gt;
* mksquashfs ${ROOTFS}/ Squashfs.sqsh -comp zstd&lt;br /&gt;
&lt;br /&gt;
This creates a file called Squashfs.sqsh that contains the original rootfs that we generated above.&lt;br /&gt;
&lt;br /&gt;
=== Using the squashfs image in FEX ===&lt;br /&gt;
* Copy the resulting sqsh file in to ${XDG_DATA_HOME}/.fex-emu/RootFS/&lt;br /&gt;
** If ${XDG_DATA_HOME} doesn't exist then that will be replaced with ${HOME}&lt;br /&gt;
* Use FEXConfig to select the sqsh file as a named rootfs&lt;br /&gt;
* or pass the name in to the FEX_ROOTFS argument in the various ways FEX supports&lt;br /&gt;
* or the absolute path if you don't want it in the FEX RootFS folder&lt;br /&gt;
&lt;br /&gt;
=== Extracting the squashfs ===&lt;br /&gt;
If you don't want to use squashfs for whatever reason then you can extract it in to the FEX RootFS folder and use the directory directly&lt;br /&gt;
* unsquashfs -f -d NewRootFS/ Squashfs.sqsh&lt;br /&gt;
&lt;br /&gt;
=== If you want to install packages in the squashfs ===&lt;br /&gt;
The squashfs image is immutable and can't be modified.&lt;br /&gt;
* Extract the squashfs first&lt;br /&gt;
* Change the working directory to the rootfs&lt;br /&gt;
* execute `unbreak_chroot.sh`&lt;br /&gt;
* `apt-get update`&lt;br /&gt;
* `apt-get install &amp;lt;Whatever you want&amp;gt;`&lt;br /&gt;
* `exit` to leave the chroot&lt;br /&gt;
* Use the new extracted chroot directly, or follow the previous steps to recompress it to a squashfs format.&lt;br /&gt;
&lt;br /&gt;
=== Known problems with squashfs ===&lt;br /&gt;
'''FEX automatically mounts your squashfs file and can leave dangling squashfs mounts around in some instances.'''&lt;br /&gt;
* '''This is fairly rare but it can occur. Whenever an instance of FEX is run, it registers with the FEXMountDaemon'''&lt;br /&gt;
** FEXMountDaemon then watches these instances of FEX to ensure they have exited before unmounting&lt;br /&gt;
** There is roughly a ten second grace period of no instances of FEX running before unmounting&lt;br /&gt;
** If an instance of FEX starts running then it will reuse the mount partition and reset the timeout&lt;br /&gt;
* To get rid of these dangling mounts if they do manage to manifest, use the following commands&lt;br /&gt;
** fusermount -u /tmp/.FEXMount* ; rmdir /tmp/.FEXMount*&lt;br /&gt;
** These don't require root to unmount&lt;br /&gt;
* In some cases the unmounting can end up returning busy status and not unmount&lt;br /&gt;
** Check the output of `mount` for any /tmp/.FEXMount folders&lt;br /&gt;
** This is due to either FEXMountDaemon or squashfuse still running in the background&lt;br /&gt;
** Can force the application to exit&lt;br /&gt;
** step 1: kill `pidof squashfuse`&lt;br /&gt;
** This will attempt to send SIGTERM to all squashfuse applications, which will unmount the partition on terminate&lt;br /&gt;
** Failing that, you can try to be more abusive&lt;br /&gt;
** kill -9 `pidof FEXMountDaemon`&lt;br /&gt;
** This will forcibly terminate FEXMountDaemon which should also take out the child mounted process&lt;br /&gt;
* If any instances of the mount still exists then you may need to kill more FEX processes.&lt;br /&gt;
** Any ''FEX'' process will end up keeping the folder mounted and keep it busy&lt;br /&gt;
&lt;br /&gt;
'''strace breaks squashfs'''&lt;br /&gt;
* If you run FEX with `strace -f` then the process that mounts your rootfs loses its setuid bit.&lt;br /&gt;
** This means you then can't mount the rootFS&lt;br /&gt;
* The only workaround is to not use a squashfs in this instance.&lt;br /&gt;
* Alternatively you can spin up a FEXBash instance to force squashfs to be mounted. Then strace a different FEX instance which will use the mounted squashfs location.&lt;/div&gt;</summary>
		<author><name>Nottucks</name></author>
	</entry>
	<entry>
		<id>https://wiki.fex-emu.com/index.php?title=Development:Setting_up_RootFS&amp;diff=1495</id>
		<title>Development:Setting up RootFS</title>
		<link rel="alternate" type="text/html" href="https://wiki.fex-emu.com/index.php?title=Development:Setting_up_RootFS&amp;diff=1495"/>
		<updated>2026-01-12T22:51:09Z</updated>

		<summary type="html">&lt;p&gt;Nottucks: /* Chrooting in to rootfs with FEX-Emu Rootfs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Development]]&lt;br /&gt;
= Setting up a RootFS =&lt;br /&gt;
'''For AArch64 hosts you are required to have an x86-64 rootfs'''. With or without 32bit compatibility libraries.&lt;br /&gt;
&lt;br /&gt;
This isn't strictly required for testing on x86-64 host environments but is useful for ensuring correct behaviour there.&lt;br /&gt;
&lt;br /&gt;
= Quick Setup with FEXRootFSFetcher =&lt;br /&gt;
FEX comes with a FEXRootFSFetcher tool that can download an official preconfigured rootfs from the FEX servers.&lt;br /&gt;
This tool operates as either a terminal application or a Zenity application depending on if it is launched from terminal or not.&lt;br /&gt;
&lt;br /&gt;
This tool will walk you through selecting a RootFS for FEX:&lt;br /&gt;
* If your host OS matches one in the download list then it will recommend that one&lt;br /&gt;
* After selecting the RootFS, it will download it&lt;br /&gt;
** This downloads to the default location in '''$HOME/.fex-emu/RootFS/'''&lt;br /&gt;
* After downloading the RootFS the tool will ask if you want to use the SquashFS file directly or extract it&lt;br /&gt;
* It will then ask if you want to set the downloaded RootFS as your default&lt;br /&gt;
** This writes to the default configuration in '''$HOME/.fex-emu/Config.json'''&lt;br /&gt;
&lt;br /&gt;
You can skip the rest of the guide if you used FEXRootFSFetcher to download the rootfs.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
* The squashfs image will fail to extract if you don't have unsquashfs installed&lt;br /&gt;
** Install the squashfs-tools package to get this application&lt;br /&gt;
&lt;br /&gt;
* '''SquashFS RootFS file corrupted?'''&lt;br /&gt;
** Rerun the tool, select the rootfs from the list, and if the rootfs already exists it will ask to verify&lt;br /&gt;
** If verification fails it will ask if you want to redownload&lt;br /&gt;
* '''Want to manually check the hash?'''&lt;br /&gt;
** Run the rootfs file directly through the tool to get a hash&lt;br /&gt;
** '''FEXRootFSFetcher $HOME/.fex-emu/RootFS/Ubuntu_21_10.sqsh'''&lt;br /&gt;
** Ubuntu_21_10.sqsh has hash: bf9507fbdbaec2cf&lt;br /&gt;
* '''Want to use the Zenity UI but still launch through terminal?'''&lt;br /&gt;
** Force Zenity from terminal with '''FEXRootFSFetcher 1&amp;gt; /dev/null'''&lt;br /&gt;
* '''What if my Linux distro isn't listed?'''&lt;br /&gt;
** Don't worry, select one that is most similar to yours or newest&lt;br /&gt;
** This will work in most cases&lt;br /&gt;
* '''How can I trust these images?'''&lt;br /&gt;
** These images are generated by scripts living in our public repo&lt;br /&gt;
** If you want to rebuild them yourself, you are free to do so.&lt;br /&gt;
** https://github.com/FEX-Emu/RootFS&lt;br /&gt;
* '''I want to add a distro'''&lt;br /&gt;
** Follow how our current rootfs is generated and add your own&lt;br /&gt;
** Open a pull request to add the rootfs setup&lt;br /&gt;
** Contact us on the official FEX-Emu Discord to get the RootFS added to the server.&lt;br /&gt;
* '''Where is the raw list of images at?'''&lt;br /&gt;
** The image links live on our website at the following link&lt;br /&gt;
** https://rootfs.fex-emu.gg/RootFS_links.json&lt;br /&gt;
** This file is in a format that our tool understands&lt;br /&gt;
** Generally the format is:&lt;br /&gt;
*** Distro Name&lt;br /&gt;
*** Distro Version&lt;br /&gt;
*** Human readable name&lt;br /&gt;
*** Raw rootfs link&lt;br /&gt;
*** xxhash based file hash&lt;br /&gt;
&lt;br /&gt;
= Making a custom rootfs prerequisites =&lt;br /&gt;
An x86-64 PC or FEX-Emu installed for chrooting&lt;br /&gt;
&lt;br /&gt;
= Getting Started =&lt;br /&gt;
The easiest way to get started is to just download a prebuilt x86-64 rootfs from your favourite distribution and extract it to where you want.&lt;br /&gt;
* Ubuntu - http://cdimage.ubuntu.com/ubuntu-base/releases/&lt;br /&gt;
* Debian Debootstrap guide - https://wiki.debian.org/Debootstrap&lt;br /&gt;
** Debootstrap is more involved and not explained here.&lt;br /&gt;
&lt;br /&gt;
Using chroot you can then enter the rootfs and install applications that you desire for testing purposes.&lt;br /&gt;
It's easiest to set this up on an x86-64 host and then copy it to an AArch64 device.&lt;br /&gt;
&lt;br /&gt;
== Cross architecture chroot ==&lt;br /&gt;
'''You need to have binfmt_misc setup for x86-64 support on your host system.'''&lt;br /&gt;
* ls /proc/sys/fs/binfmt_misc &lt;br /&gt;
** If there are files in this folder then your host supports binfmt_misc&lt;br /&gt;
* Once you have binfmt_misc running and FEX-Emu installed in to it, you can chroot in to an x86-64 rootfs&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Chrooting in to rootfs with FEX-Emu Rootfs ==&lt;br /&gt;
* If you're using a FEX-Emu provided RootFS then we provide a script to handle this.&lt;br /&gt;
** This script can be called uing '''./chroot.py chroot''' inside the root directory of the RootFS.&lt;br /&gt;
** When you finish, make sure to exit the chroot cleanly.&lt;br /&gt;
If the chroot is working, the remaining steps of this guide can safely be skipped.&lt;br /&gt;
&lt;br /&gt;
* Issues&lt;br /&gt;
** As of January 12th, 2026, Fedora packages for FEX-Emu are a few months out of date. &lt;br /&gt;
** This causes the chroot script to fail, saying &amp;quot;Host program 'FEX' isn't available and is required!&amp;quot;.&lt;br /&gt;
** The solution is to copy &amp;quot;/usr/bin/FEXInterpreter&amp;quot; to &amp;quot;/usr/bin/FEX&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Chrooting in to custom rootfs with FEX-Emu ==&lt;br /&gt;
* If you're setting up your own rootfs then you need to follow the binding steps that are following.&lt;br /&gt;
** We have a script that if you know what you're doing you can cherry pick parts from [https://github.com/FEX-Emu/RootFS/blob/main/unbreak_chroot.sh here]&lt;br /&gt;
&lt;br /&gt;
= Additional TmpFS folders =&lt;br /&gt;
Depending on what you're doing in the chroot, you may need or want some tmpfs folders that applications are expecting&lt;br /&gt;
&lt;br /&gt;
* sudo mount -t proc /proc ${ROOTFS}/proc/&lt;br /&gt;
* sudo mount --rbind --make-rslave /sys ${ROOTFS}/sys/&lt;br /&gt;
* sudo mount --rbind --make-rslave /dev ${ROOTFS}/dev/&lt;br /&gt;
* sudo mount --rbind --make-rslave /dev/pts ${ROOTFS}/dev/pts/&lt;br /&gt;
* sudo mount --rbind /lib/ld-linux-aarch64.so.1 ${ROOTFS}/lib/ld-linux-aarch64.so.1&lt;br /&gt;
* sudo mount --rbind /lib/aarch64-linux-gnu ${ROOTFS}/lib/aarch64-linux-gnu&lt;br /&gt;
&lt;br /&gt;
Then of course, make sure to unmount these partitions when you're done&lt;br /&gt;
&lt;br /&gt;
* sudo umount ${ROOTFS}/proc/&lt;br /&gt;
* sudo umount -R ${ROOTFS}/sys/&lt;br /&gt;
* sudo umount -R ${ROOTFS}/dev/pts/&lt;br /&gt;
* sudo umount -R ${ROOTFS}/dev/&lt;br /&gt;
* sudo umount -R ${ROOTFS}/lib/ld-linux-aarch64.so.1&lt;br /&gt;
* sudo umount -R ${ROOTFS}/lib/aarch64-linux-gnu&lt;br /&gt;
&lt;br /&gt;
= Using the RootFS with FEX =&lt;br /&gt;
&lt;br /&gt;
Run the graphical FEXConfig tool to select and change the active RootFS. Any file or folder in $HOME/.fex-emu/RootFS will be detected automatically.&lt;br /&gt;
&lt;br /&gt;
= Additional Steps for building a custom rootfs = &lt;br /&gt;
== Running under WSL1 ==&lt;br /&gt;
/etc/hosts and /etc/resolv.conf change on the host side. You'll need to copy those over to the rootfs if you want network functionality to work.&lt;br /&gt;
&lt;br /&gt;
== Ubuntu packages to install ==&lt;br /&gt;
Sample packages to install in the rootfs&lt;br /&gt;
* apt-get install pulseaudio libgles1 libgles2 libglx-mesa0 libgl1-mesa-dri libgl1-mesa-glx mesa-utils mesa-utils-extra&lt;br /&gt;
Pulseaudio specifically is required so pulseaudio will work when talking to the host pulseaudio&lt;br /&gt;
&lt;br /&gt;
== File deletion ==&lt;br /&gt;
Some files need to be deleted from the rootfs otherwise some applications will fail to work.&lt;br /&gt;
&lt;br /&gt;
Note that deleting these files '''WILL''' break the rootfs and you won't be able to chroot in to it anymore.&lt;br /&gt;
&lt;br /&gt;
A likely better route would be a script that moves these files and folders then brings them back when you want to chroot&lt;br /&gt;
&lt;br /&gt;
=== Files to remove ===&lt;br /&gt;
* ${ROOTFS}/etc/hosts&lt;br /&gt;
* ${ROOTFS}/etc/resolv.conf&lt;br /&gt;
* ${ROOTFS}/etc/timezone&lt;br /&gt;
* ${ROOTFS}/etc/localtime&lt;br /&gt;
* ${ROOTFS}/etc/passwd&lt;br /&gt;
&lt;br /&gt;
=== Folders to remove ===&lt;br /&gt;
* ${ROOTFS}/boot&lt;br /&gt;
* ${ROOTFS}/dev&lt;br /&gt;
* ${ROOTFS}/home&lt;br /&gt;
* ${ROOTFS}/media&lt;br /&gt;
* ${ROOTFS}/mnt&lt;br /&gt;
* ${ROOTFS}/proc&lt;br /&gt;
* ${ROOTFS}/root&lt;br /&gt;
* ${ROOTFS}/srv&lt;br /&gt;
* ${ROOTFS}/tmp&lt;br /&gt;
* ${ROOTFS}/var/cache/apt&lt;br /&gt;
* ${ROOTFS}/var/lib/apt&lt;br /&gt;
* ${ROOTFS}/sys&lt;br /&gt;
* ${ROOTFS}/opt&lt;br /&gt;
&lt;br /&gt;
== Creating a Squashfs rootfs from custom rootfs ==&lt;br /&gt;
SquashFS is a great way to do binary distribution of the rootfs. If you have created a rootfs and you want to roll it in to a squashfs like the FEX-Emu provided images then this is information on how to do that.&lt;br /&gt;
&lt;br /&gt;
'''SquashFS is currently only recommended for binary distribution. User should unpack it to not get dangling processes and mounts.'''&lt;br /&gt;
* Offers tooling to mount in userspace&lt;br /&gt;
* Supports ZSTD compression&lt;br /&gt;
* Is a readonly partition that matches FEX's use case&lt;br /&gt;
&lt;br /&gt;
=== Tools that FEX needs to run squashfs ===&lt;br /&gt;
* squashfuse&lt;br /&gt;
* fusermount&lt;br /&gt;
&lt;br /&gt;
=== Making the squashfs image ===&lt;br /&gt;
Making the squashfs image is very straightforward&lt;br /&gt;
* mksquashfs ${ROOTFS}/ Squashfs.sqsh -comp zstd&lt;br /&gt;
&lt;br /&gt;
This creates a file called Squashfs.sqsh that contains the original rootfs that we generated above.&lt;br /&gt;
&lt;br /&gt;
=== Using the squashfs image in FEX ===&lt;br /&gt;
* Copy the resulting sqsh file in to ${XDG_DATA_HOME}/.fex-emu/RootFS/&lt;br /&gt;
** If ${XDG_DATA_HOME} doesn't exist then that will be replaced with ${HOME}&lt;br /&gt;
* Use FEXConfig to select the sqsh file as a named rootfs&lt;br /&gt;
* or pass the name in to the FEX_ROOTFS argument in the various ways FEX supports&lt;br /&gt;
* or the absolute path if you don't want it in the FEX RootFS folder&lt;br /&gt;
&lt;br /&gt;
=== Extracting the squashfs ===&lt;br /&gt;
If you don't want to use squashfs for whatever reason then you can extract it in to the FEX RootFS folder and use the directory directly&lt;br /&gt;
* unsquashfs -f -d NewRootFS/ Squashfs.sqsh&lt;br /&gt;
&lt;br /&gt;
=== If you want to install packages in the squashfs ===&lt;br /&gt;
The squashfs image is immutable and can't be modified.&lt;br /&gt;
* Extract the squashfs first&lt;br /&gt;
* Change the working directory to the rootfs&lt;br /&gt;
* execute `unbreak_chroot.sh`&lt;br /&gt;
* `apt-get update`&lt;br /&gt;
* `apt-get install &amp;lt;Whatever you want&amp;gt;`&lt;br /&gt;
* `exit` to leave the chroot&lt;br /&gt;
* Use the new extracted chroot directly, or follow the previous steps to recompress it to a squashfs format.&lt;br /&gt;
&lt;br /&gt;
=== Known problems with squashfs ===&lt;br /&gt;
'''FEX automatically mounts your squashfs file and can leave dangling squashfs mounts around in some instances.'''&lt;br /&gt;
* '''This is fairly rare but it can occur. Whenever an instance of FEX is run, it registers with the FEXMountDaemon'''&lt;br /&gt;
** FEXMountDaemon then watches these instances of FEX to ensure they have exited before unmounting&lt;br /&gt;
** There is roughly a ten second grace period of no instances of FEX running before unmounting&lt;br /&gt;
** If an instance of FEX starts running then it will reuse the mount partition and reset the timeout&lt;br /&gt;
* To get rid of these dangling mounts if they do manage to manifest, use the following commands&lt;br /&gt;
** fusermount -u /tmp/.FEXMount* ; rmdir /tmp/.FEXMount*&lt;br /&gt;
** These don't require root to unmount&lt;br /&gt;
* In some cases the unmounting can end up returning busy status and not unmount&lt;br /&gt;
** Check the output of `mount` for any /tmp/.FEXMount folders&lt;br /&gt;
** This is due to either FEXMountDaemon or squashfuse still running in the background&lt;br /&gt;
** Can force the application to exit&lt;br /&gt;
** step 1: kill `pidof squashfuse`&lt;br /&gt;
** This will attempt to send SIGTERM to all squashfuse applications, which will unmount the partition on terminate&lt;br /&gt;
** Failing that, you can try to be more abusive&lt;br /&gt;
** kill -9 `pidof FEXMountDaemon`&lt;br /&gt;
** This will forcibly terminate FEXMountDaemon which should also take out the child mounted process&lt;br /&gt;
* If any instances of the mount still exists then you may need to kill more FEX processes.&lt;br /&gt;
** Any ''FEX'' process will end up keeping the folder mounted and keep it busy&lt;br /&gt;
&lt;br /&gt;
'''strace breaks squashfs'''&lt;br /&gt;
* If you run FEX with `strace -f` then the process that mounts your rootfs loses its setuid bit.&lt;br /&gt;
** This means you then can't mount the rootFS&lt;br /&gt;
* The only workaround is to not use a squashfs in this instance.&lt;br /&gt;
* Alternatively you can spin up a FEXBash instance to force squashfs to be mounted. Then strace a different FEX instance which will use the mounted squashfs location.&lt;/div&gt;</summary>
		<author><name>Nottucks</name></author>
	</entry>
	<entry>
		<id>https://wiki.fex-emu.com/index.php?title=Development:Setting_up_RootFS&amp;diff=1494</id>
		<title>Development:Setting up RootFS</title>
		<link rel="alternate" type="text/html" href="https://wiki.fex-emu.com/index.php?title=Development:Setting_up_RootFS&amp;diff=1494"/>
		<updated>2026-01-12T22:50:50Z</updated>

		<summary type="html">&lt;p&gt;Nottucks: Rewritten to update information, as well as adding information that is relevant to getting&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Development]]&lt;br /&gt;
= Setting up a RootFS =&lt;br /&gt;
'''For AArch64 hosts you are required to have an x86-64 rootfs'''. With or without 32bit compatibility libraries.&lt;br /&gt;
&lt;br /&gt;
This isn't strictly required for testing on x86-64 host environments but is useful for ensuring correct behaviour there.&lt;br /&gt;
&lt;br /&gt;
= Quick Setup with FEXRootFSFetcher =&lt;br /&gt;
FEX comes with a FEXRootFSFetcher tool that can download an official preconfigured rootfs from the FEX servers.&lt;br /&gt;
This tool operates as either a terminal application or a Zenity application depending on if it is launched from terminal or not.&lt;br /&gt;
&lt;br /&gt;
This tool will walk you through selecting a RootFS for FEX:&lt;br /&gt;
* If your host OS matches one in the download list then it will recommend that one&lt;br /&gt;
* After selecting the RootFS, it will download it&lt;br /&gt;
** This downloads to the default location in '''$HOME/.fex-emu/RootFS/'''&lt;br /&gt;
* After downloading the RootFS the tool will ask if you want to use the SquashFS file directly or extract it&lt;br /&gt;
* It will then ask if you want to set the downloaded RootFS as your default&lt;br /&gt;
** This writes to the default configuration in '''$HOME/.fex-emu/Config.json'''&lt;br /&gt;
&lt;br /&gt;
You can skip the rest of the guide if you used FEXRootFSFetcher to download the rootfs.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
* The squashfs image will fail to extract if you don't have unsquashfs installed&lt;br /&gt;
** Install the squashfs-tools package to get this application&lt;br /&gt;
&lt;br /&gt;
* '''SquashFS RootFS file corrupted?'''&lt;br /&gt;
** Rerun the tool, select the rootfs from the list, and if the rootfs already exists it will ask to verify&lt;br /&gt;
** If verification fails it will ask if you want to redownload&lt;br /&gt;
* '''Want to manually check the hash?'''&lt;br /&gt;
** Run the rootfs file directly through the tool to get a hash&lt;br /&gt;
** '''FEXRootFSFetcher $HOME/.fex-emu/RootFS/Ubuntu_21_10.sqsh'''&lt;br /&gt;
** Ubuntu_21_10.sqsh has hash: bf9507fbdbaec2cf&lt;br /&gt;
* '''Want to use the Zenity UI but still launch through terminal?'''&lt;br /&gt;
** Force Zenity from terminal with '''FEXRootFSFetcher 1&amp;gt; /dev/null'''&lt;br /&gt;
* '''What if my Linux distro isn't listed?'''&lt;br /&gt;
** Don't worry, select one that is most similar to yours or newest&lt;br /&gt;
** This will work in most cases&lt;br /&gt;
* '''How can I trust these images?'''&lt;br /&gt;
** These images are generated by scripts living in our public repo&lt;br /&gt;
** If you want to rebuild them yourself, you are free to do so.&lt;br /&gt;
** https://github.com/FEX-Emu/RootFS&lt;br /&gt;
* '''I want to add a distro'''&lt;br /&gt;
** Follow how our current rootfs is generated and add your own&lt;br /&gt;
** Open a pull request to add the rootfs setup&lt;br /&gt;
** Contact us on the official FEX-Emu Discord to get the RootFS added to the server.&lt;br /&gt;
* '''Where is the raw list of images at?'''&lt;br /&gt;
** The image links live on our website at the following link&lt;br /&gt;
** https://rootfs.fex-emu.gg/RootFS_links.json&lt;br /&gt;
** This file is in a format that our tool understands&lt;br /&gt;
** Generally the format is:&lt;br /&gt;
*** Distro Name&lt;br /&gt;
*** Distro Version&lt;br /&gt;
*** Human readable name&lt;br /&gt;
*** Raw rootfs link&lt;br /&gt;
*** xxhash based file hash&lt;br /&gt;
&lt;br /&gt;
= Making a custom rootfs prerequisites =&lt;br /&gt;
An x86-64 PC or FEX-Emu installed for chrooting&lt;br /&gt;
&lt;br /&gt;
= Getting Started =&lt;br /&gt;
The easiest way to get started is to just download a prebuilt x86-64 rootfs from your favourite distribution and extract it to where you want.&lt;br /&gt;
* Ubuntu - http://cdimage.ubuntu.com/ubuntu-base/releases/&lt;br /&gt;
* Debian Debootstrap guide - https://wiki.debian.org/Debootstrap&lt;br /&gt;
** Debootstrap is more involved and not explained here.&lt;br /&gt;
&lt;br /&gt;
Using chroot you can then enter the rootfs and install applications that you desire for testing purposes.&lt;br /&gt;
It's easiest to set this up on an x86-64 host and then copy it to an AArch64 device.&lt;br /&gt;
&lt;br /&gt;
== Cross architecture chroot ==&lt;br /&gt;
'''You need to have binfmt_misc setup for x86-64 support on your host system.'''&lt;br /&gt;
* ls /proc/sys/fs/binfmt_misc &lt;br /&gt;
** If there are files in this folder then your host supports binfmt_misc&lt;br /&gt;
* Once you have binfmt_misc running and FEX-Emu installed in to it, you can chroot in to an x86-64 rootfs&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Chrooting in to rootfs with FEX-Emu Rootfs ==&lt;br /&gt;
* If you're using a FEX-Emu provided RootFS then we provide a script to handle this.&lt;br /&gt;
** This script can be called uing '''./chroot.py chroot''' inside the root directory of the RootFS.&lt;br /&gt;
** Make sure to exit the chroot cleanly.&lt;br /&gt;
If the chroot is working, the remaining steps of this guide can safely be skipped.&lt;br /&gt;
&lt;br /&gt;
* Issues&lt;br /&gt;
** As of January 12th, 2026, Fedora packages for FEX-Emu are a few months out of date. &lt;br /&gt;
** This causes the chroot script to fail, saying &amp;quot;Host program 'FEX' isn't available and is required!&amp;quot;.&lt;br /&gt;
** The solution is to copy &amp;quot;/usr/bin/FEXInterpreter&amp;quot; to &amp;quot;/usr/bin/FEX&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Chrooting in to custom rootfs with FEX-Emu ==&lt;br /&gt;
* If you're setting up your own rootfs then you need to follow the binding steps that are following.&lt;br /&gt;
** We have a script that if you know what you're doing you can cherry pick parts from [https://github.com/FEX-Emu/RootFS/blob/main/unbreak_chroot.sh here]&lt;br /&gt;
&lt;br /&gt;
= Additional TmpFS folders =&lt;br /&gt;
Depending on what you're doing in the chroot, you may need or want some tmpfs folders that applications are expecting&lt;br /&gt;
&lt;br /&gt;
* sudo mount -t proc /proc ${ROOTFS}/proc/&lt;br /&gt;
* sudo mount --rbind --make-rslave /sys ${ROOTFS}/sys/&lt;br /&gt;
* sudo mount --rbind --make-rslave /dev ${ROOTFS}/dev/&lt;br /&gt;
* sudo mount --rbind --make-rslave /dev/pts ${ROOTFS}/dev/pts/&lt;br /&gt;
* sudo mount --rbind /lib/ld-linux-aarch64.so.1 ${ROOTFS}/lib/ld-linux-aarch64.so.1&lt;br /&gt;
* sudo mount --rbind /lib/aarch64-linux-gnu ${ROOTFS}/lib/aarch64-linux-gnu&lt;br /&gt;
&lt;br /&gt;
Then of course, make sure to unmount these partitions when you're done&lt;br /&gt;
&lt;br /&gt;
* sudo umount ${ROOTFS}/proc/&lt;br /&gt;
* sudo umount -R ${ROOTFS}/sys/&lt;br /&gt;
* sudo umount -R ${ROOTFS}/dev/pts/&lt;br /&gt;
* sudo umount -R ${ROOTFS}/dev/&lt;br /&gt;
* sudo umount -R ${ROOTFS}/lib/ld-linux-aarch64.so.1&lt;br /&gt;
* sudo umount -R ${ROOTFS}/lib/aarch64-linux-gnu&lt;br /&gt;
&lt;br /&gt;
= Using the RootFS with FEX =&lt;br /&gt;
&lt;br /&gt;
Run the graphical FEXConfig tool to select and change the active RootFS. Any file or folder in $HOME/.fex-emu/RootFS will be detected automatically.&lt;br /&gt;
&lt;br /&gt;
= Additional Steps for building a custom rootfs = &lt;br /&gt;
== Running under WSL1 ==&lt;br /&gt;
/etc/hosts and /etc/resolv.conf change on the host side. You'll need to copy those over to the rootfs if you want network functionality to work.&lt;br /&gt;
&lt;br /&gt;
== Ubuntu packages to install ==&lt;br /&gt;
Sample packages to install in the rootfs&lt;br /&gt;
* apt-get install pulseaudio libgles1 libgles2 libglx-mesa0 libgl1-mesa-dri libgl1-mesa-glx mesa-utils mesa-utils-extra&lt;br /&gt;
Pulseaudio specifically is required so pulseaudio will work when talking to the host pulseaudio&lt;br /&gt;
&lt;br /&gt;
== File deletion ==&lt;br /&gt;
Some files need to be deleted from the rootfs otherwise some applications will fail to work.&lt;br /&gt;
&lt;br /&gt;
Note that deleting these files '''WILL''' break the rootfs and you won't be able to chroot in to it anymore.&lt;br /&gt;
&lt;br /&gt;
A likely better route would be a script that moves these files and folders then brings them back when you want to chroot&lt;br /&gt;
&lt;br /&gt;
=== Files to remove ===&lt;br /&gt;
* ${ROOTFS}/etc/hosts&lt;br /&gt;
* ${ROOTFS}/etc/resolv.conf&lt;br /&gt;
* ${ROOTFS}/etc/timezone&lt;br /&gt;
* ${ROOTFS}/etc/localtime&lt;br /&gt;
* ${ROOTFS}/etc/passwd&lt;br /&gt;
&lt;br /&gt;
=== Folders to remove ===&lt;br /&gt;
* ${ROOTFS}/boot&lt;br /&gt;
* ${ROOTFS}/dev&lt;br /&gt;
* ${ROOTFS}/home&lt;br /&gt;
* ${ROOTFS}/media&lt;br /&gt;
* ${ROOTFS}/mnt&lt;br /&gt;
* ${ROOTFS}/proc&lt;br /&gt;
* ${ROOTFS}/root&lt;br /&gt;
* ${ROOTFS}/srv&lt;br /&gt;
* ${ROOTFS}/tmp&lt;br /&gt;
* ${ROOTFS}/var/cache/apt&lt;br /&gt;
* ${ROOTFS}/var/lib/apt&lt;br /&gt;
* ${ROOTFS}/sys&lt;br /&gt;
* ${ROOTFS}/opt&lt;br /&gt;
&lt;br /&gt;
== Creating a Squashfs rootfs from custom rootfs ==&lt;br /&gt;
SquashFS is a great way to do binary distribution of the rootfs. If you have created a rootfs and you want to roll it in to a squashfs like the FEX-Emu provided images then this is information on how to do that.&lt;br /&gt;
&lt;br /&gt;
'''SquashFS is currently only recommended for binary distribution. User should unpack it to not get dangling processes and mounts.'''&lt;br /&gt;
* Offers tooling to mount in userspace&lt;br /&gt;
* Supports ZSTD compression&lt;br /&gt;
* Is a readonly partition that matches FEX's use case&lt;br /&gt;
&lt;br /&gt;
=== Tools that FEX needs to run squashfs ===&lt;br /&gt;
* squashfuse&lt;br /&gt;
* fusermount&lt;br /&gt;
&lt;br /&gt;
=== Making the squashfs image ===&lt;br /&gt;
Making the squashfs image is very straightforward&lt;br /&gt;
* mksquashfs ${ROOTFS}/ Squashfs.sqsh -comp zstd&lt;br /&gt;
&lt;br /&gt;
This creates a file called Squashfs.sqsh that contains the original rootfs that we generated above.&lt;br /&gt;
&lt;br /&gt;
=== Using the squashfs image in FEX ===&lt;br /&gt;
* Copy the resulting sqsh file in to ${XDG_DATA_HOME}/.fex-emu/RootFS/&lt;br /&gt;
** If ${XDG_DATA_HOME} doesn't exist then that will be replaced with ${HOME}&lt;br /&gt;
* Use FEXConfig to select the sqsh file as a named rootfs&lt;br /&gt;
* or pass the name in to the FEX_ROOTFS argument in the various ways FEX supports&lt;br /&gt;
* or the absolute path if you don't want it in the FEX RootFS folder&lt;br /&gt;
&lt;br /&gt;
=== Extracting the squashfs ===&lt;br /&gt;
If you don't want to use squashfs for whatever reason then you can extract it in to the FEX RootFS folder and use the directory directly&lt;br /&gt;
* unsquashfs -f -d NewRootFS/ Squashfs.sqsh&lt;br /&gt;
&lt;br /&gt;
=== If you want to install packages in the squashfs ===&lt;br /&gt;
The squashfs image is immutable and can't be modified.&lt;br /&gt;
* Extract the squashfs first&lt;br /&gt;
* Change the working directory to the rootfs&lt;br /&gt;
* execute `unbreak_chroot.sh`&lt;br /&gt;
* `apt-get update`&lt;br /&gt;
* `apt-get install &amp;lt;Whatever you want&amp;gt;`&lt;br /&gt;
* `exit` to leave the chroot&lt;br /&gt;
* Use the new extracted chroot directly, or follow the previous steps to recompress it to a squashfs format.&lt;br /&gt;
&lt;br /&gt;
=== Known problems with squashfs ===&lt;br /&gt;
'''FEX automatically mounts your squashfs file and can leave dangling squashfs mounts around in some instances.'''&lt;br /&gt;
* '''This is fairly rare but it can occur. Whenever an instance of FEX is run, it registers with the FEXMountDaemon'''&lt;br /&gt;
** FEXMountDaemon then watches these instances of FEX to ensure they have exited before unmounting&lt;br /&gt;
** There is roughly a ten second grace period of no instances of FEX running before unmounting&lt;br /&gt;
** If an instance of FEX starts running then it will reuse the mount partition and reset the timeout&lt;br /&gt;
* To get rid of these dangling mounts if they do manage to manifest, use the following commands&lt;br /&gt;
** fusermount -u /tmp/.FEXMount* ; rmdir /tmp/.FEXMount*&lt;br /&gt;
** These don't require root to unmount&lt;br /&gt;
* In some cases the unmounting can end up returning busy status and not unmount&lt;br /&gt;
** Check the output of `mount` for any /tmp/.FEXMount folders&lt;br /&gt;
** This is due to either FEXMountDaemon or squashfuse still running in the background&lt;br /&gt;
** Can force the application to exit&lt;br /&gt;
** step 1: kill `pidof squashfuse`&lt;br /&gt;
** This will attempt to send SIGTERM to all squashfuse applications, which will unmount the partition on terminate&lt;br /&gt;
** Failing that, you can try to be more abusive&lt;br /&gt;
** kill -9 `pidof FEXMountDaemon`&lt;br /&gt;
** This will forcibly terminate FEXMountDaemon which should also take out the child mounted process&lt;br /&gt;
* If any instances of the mount still exists then you may need to kill more FEX processes.&lt;br /&gt;
** Any ''FEX'' process will end up keeping the folder mounted and keep it busy&lt;br /&gt;
&lt;br /&gt;
'''strace breaks squashfs'''&lt;br /&gt;
* If you run FEX with `strace -f` then the process that mounts your rootfs loses its setuid bit.&lt;br /&gt;
** This means you then can't mount the rootFS&lt;br /&gt;
* The only workaround is to not use a squashfs in this instance.&lt;br /&gt;
* Alternatively you can spin up a FEXBash instance to force squashfs to be mounted. Then strace a different FEX instance which will use the mounted squashfs location.&lt;/div&gt;</summary>
		<author><name>Nottucks</name></author>
	</entry>
</feed>