How to Install and Update Fedora Linux on Android using Termux

Photo by Marek Levák on Unsplash (edited)

If you’re interested in running Linux on your Android device, you’re in luck! It’s possible to install Fedora Linux on Android using Termux. Termux is a terminal emulator for Android that allows you to run Linux commands and utilities on your phone or tablet. It does not replace Android. In this article, we’ll walk you through the process of installing Fedora Linux on Android using Termux and show you how to keep it up to date with the latest versions.

Step by step process

Step 1: Install Termux

To get started, you need to install Termux from the Google Play Store. Once you have Termux installed, open it up and type the following command to update the package list:

pkg update

Note: Termux requires Android >= 7 to run. Support for Android 5 and 6 was dropped at v0.83 on 2020-01-01, but you can find old builds on archive.org ( https://archive.org/details/termux-repositories-legacy/ ) if needed.

Step 2: Install Proot-Distro

Next, you’ll need to install Proot-Distro. Proot-Distro is a tool that allows you to install and run Linux distributions in a chroot environment. To install Proot-Distro, run the following command:

pkg install proot-distro

Step 3: Install Fedora

With Proot-Distro installed, you can now use it to install Fedora. To install Fedora, run the following command:

proot-distro install fedora

This will download and install the latest version of Fedora.

Step 4: Configure dnf

Now that you have Fedora installed, you’ll need to configure dnf, Fedora’s package manager. By default, dnf may try to install SELinux packages, which won’t work properly in a chroot environment. To prevent this, exclude SELinux packages installation by editing the dnf configuration file. Run the following command to open the dnf configuration file for editing :

cd ../usr/var/lib/proot-distro/installed-rootfs/fedora/etc/dnf
vi dnf.conf

You may substitute the nano editor for vi, if it is more to your liking. Once you’re in the file, find the line that says excludepkgs= and add *selinux* to the end of the line, like so:

excludepkgs=*selinux*

It may be necessary to add the excludepkgs line. Save these changes and exit the editor.

Step 5: Install a Desktop Environment (Optional)

Fedora comes with a number of desktop environments to choose from. If you’d like to install a desktop environment, you can do so with the following commands:

proot-distro login fedora
dnf groupinstall "Fedora Workstation" --skip-broken

This will switch from termux into the chroot Fedora installation and install the GNOME desktop environment, along with a number of other packages. If you prefer a different desktop environment, you can replace Fedora Workstation with the name of the group for your preferred environment.

Step 6: Install VNC Server (Optional)

If you plan on using your Fedora installation with a graphical interface, you’ll need to install a VNC server. This will allow you to connect to the Fedora desktop from another computer or device. To install the TigerVNC server, run the following command:

dnf install tigervnc-server.aarch64 -y

This will install the VNC server, along with any necessary dependencies.

Step 7: Upgrading Fedora

Now that you have Fedora installed, you’ll want to keep it up to date with the latest versions. To upgrade Fedora, run the following commands:

sudo dnf upgrade --refresh
sudo dnf install dnf-plugin-system-upgrade
sudo dnf system-upgrade download –releasever=37
export DNF_SYSTEM_UPGRADE_NO_REBOOT=1
sudo -E dnf system-upgrade reboot
sudo -E dnf system-upgrade upgrade
sudo dnf upgrade --refresh

First command sudo dnf upgrade –refresh refreshes the package cache and updates any installed packages.

The second command sudo dnf install dnf-plugin-system-upgrade installs the dnf-plugin-system-upgrade package, needed for the upgrade process.

The third command sudo dnf system-upgrade download –releasever=37 downloads the necessary packages for the upgrade to version 37 of Fedora. Replace 37 with the desired release version.

The fourth command export DNF_SYSTEM_UPGRADE_NO_REBOOT=1 sets an environment variable to prevent the system from rebooting after the upgrade.

The fifth command sudo -E dnf system-upgrade reboot reboots the system to start the upgrade process. Make sure to save any important work before running this command.

The sixth command sudo -E dnf system-upgrade upgrade performs the upgrade process.

Finally, the seventh command sudo dnf upgrade –refresh updates any remaining packages and ensures that your system is fully up to date.

Errors Encountered

During the installation and upgrade process, you may encounter errors. Two common errors are described below, along with their solutions.

Error 1: sudo: /etc/sudo.conf is owned by uid 1001, should be 0
Solution: This error occurs when the ownership of the sudo.conf file is incorrect. To fix this, run the following command:

chmod +s /usr/bin/sudo

This sets the setuid bit on the sudo command, which allows it to run with root privileges.

Error 2: filesystem package didn’t get upgraded post OS upgrade
Solution: This error occurs when the filesystem package is not upgraded during the upgrade process. To fix this, run the following commands:

sudo rpm -e --nodeps filesystem
dnf download filesystem

The first command removes the filesystem package, and the second command downloads the latest version of the package. If you encounter any errors during the upgrade process, you can use rpmrebuild to rebuild the package with any necessary modifications.

Conclusion

In this article, we’ve shown you how to install Fedora Linux on Android using Termux and how to keep it up to date with the latest versions. While there may be some errors to overcome during the installation and upgrade process, following the steps outlined in this article should help you get Fedora up and running on your Android device in no time.

Fedora Project community Five Things in Fedora This Week For System Administrators

29 Comments

  1. Konstantin

    Installing Termux from the Google Play Store is deprecated and has been for a long time. Please refer to F-Droid or Github instead.

  2. David Jefferson

    The best would still be to get RID OF ANDROID and install FEDORA on smartphones / tablets etc… as NATIVE like a PC. But I really don’t know why in 2023 it’s so hard to install linux on mobile although we are installing on many hardware on PC since 35 years…. makes no sense at all unless it’s done on purpose.

    • Valentino Rebagliati

      It would be as easy as on desktop if phone manufacturers weren’t as protective as they are.
      Right now, the custom Android ROM community (in most phones) relies on reverse engineered device trees, which are unstable at best, missing hardware functions (Cameras, 5g, fingerprint readers) most of the time.

    • Eduard Lcuena

      Nobody is forcing you.

      There are a lot of limitations, mostly all are related with the architecture of chipset on mobile phones, nevertheless there are several projects trying it, e.g.: Postmarket OS

      • buğra

        Nobody is forcing me and nothing works as they should, so i dont care.

  3. Trap

    Can I do this on an old tablet with Android 4.4?

  4. Rhinomick

    I believe this does not wipe out Android…..am i correct?

  5. Brian

    Hi

    you missed

    proot-distro login fedora

    trying it now! 🙂

    • Hey Brian!

      Great catch! You’re absolutely right in the next update, I’ll make sure to include it in the sequence. Your keen eye for detail is much appreciated!

  6. Marc Teale

    A few notes:
    – Vi/Vim does not come in the default v0.118.0 termux image on GitHub. Install it with

    pkg install vim

    to edit dnf.conf.
    – The “excludepkgs=” line is not in dnf.conf. It should be added.
    – There’s a missing command between steps 4 and 5. You must run “proot-distro login fedora” to switch from termux into the chroot Fedora installation.

    • Thank you, Marc!

      But, at this stage we’ve successfully installed Fedora Linux and logged into the system.

      By default, Fedora Linux includes the vim-minimal package that provides the vi command. There is already a note to add the line “excludepkgs=*” to dnf.conf.

      And yes, the command “proot-distro login fedora” will be added in the revised version to ensure a seamless switch from Termux to the chroot Fedora installation.

  7. Jason

    Thanks, now I have a weekend project for the old motorolla lying around.
    Given its running in a chroot environment it would be interesting to see what devices it has access to on the phone.

  8. Rhinomick

    dnf groupinstall “Fedora Workstation” –skip-broken
    I would like to install KDE, what should i write?

    • Mark A. Stevens

      It would seem you can install KDE with the following:

      dnf groupinstall “KDE Plasma Workspaces” –-skip-broken

      The final result may or may not work since SELinux enabled programs are not installed.

      You can find all groups with the command:

      dnf grouplist –all

  9. I really like this article and this topic of installing Linux on Android phones.
    Thanks for the article.

    Now, I guess it would be possible to gradually use our Android phones connected to external large displays as workstations, given the growing power of Android devices, am I right?

    Any advice or planned article on external Android displays used with underlying Linux?

  10. Norbert J.

    That’s indeed amazing! I have installed Termux for years but never imagined that something like this would be possible. However owners of old or low-end smart phones (like me) may be out of luck because Fedora no longer supports 32 bit ARM.

  11. Tae

    ‘cd’ comment written in the description couldn’t find the directory to remove selinux. So I skipped the process and jump to install fedora work station… Will it cause problem?

  12. Peter

    Good article – have installed Fedora with Mate desktop but having trouble with tigervnc – can anyone point me to any article explaining how to get this to work from Fedora on a laptop?

  13. Mahdi

    Great Article !

    Could you please elaborate on :
    – Step 5: Install a Desktop Environment : Does this mean we can access from the Android device’s screen the installed Desktop Environment ?

    With a full fledged Fedora now installed, could it access the Android device’s Wifi with either CLI or with Gnome’s NetworkManager ?
    What about Camera access from Fedora for let’s say videoconferencing through Firefox ?

Comments are Closed

The opinions expressed on this website are those of each author, not of the author's employer or of Red Hat. Fedora Magazine aspires to publish all content under a Creative Commons license but may not be able to do so in all cases. You are responsible for ensuring that you have the necessary permission to reuse any work on this site. The Fedora logo is a trademark of Red Hat, Inc. Terms and Conditions