Fedora Bootstrap Guide
By Taha • 7 minutes read •
In this article I have chosen ubuntu for the live boot and fedora for the target. You can use other distributions for live boot and target installation. If you use a different distribution for the target, you need to check the bootstrap commands for that distribution. For example: debootstrap, pacstrap and dnf. The parameters may differ depending on the tool you are using
- In linux distributions, the bootstrap process is used to install the base of a distribution without a GUI installer (e.g. Calamares, Anaconda, etc.) using package managers or other tools. This method can be done in many distributions. For example:
pacstrap
for Arch Linuxdebootstrap
for Ubuntu/Debiandnf
for fedora
- So why choose this method?
- In some cases I have chosen this method for several reasons. For example:
- Old hardware
- Some hardware drivers not included in the distribution
- Gui installer not working due to file system errors from an old installation and etc.
- Today in this article I will try to explain in detail the steps I take when using this method.
Step 1: Update Repositories in Live Environment
The first step is to update the repositories in the live environment.
Step 2: Install DNF Package Manager in Live Environment
In this article, we will install the dnf package manager in the live environment, since we chose fedora for the target installation.
Step 3: Prepare the Disk and Partitions
The next step is to prepare the disk and partitions. First, you need to check the disk you want to install the system on:
In my case, I will use
/dev/vda
disk. You can usecfdisk
to create partitions on the disk. You can do this by running the following command:Select
gpt
cfdisk
will list the partitions on the disk. You can create a new efi partition by selectingNew
and then set the size to512M
and type toEFI System
.Create a new root partition by selecting
New
and pressingEnter
to use the remaining space.Finally, select
Write
and typeyes
to write the changes to the disk.After creating the partitions, check the partitions by running the following command:
Step 4: Format the Partitions
The next step is to format the partitions:
Then check filesystems:
Step 5: Mount the BTRFS Partition and Create Subvolumes
The next step is to mount the btrfs partition and create subvolumes. You can do this by running the following commands:
#~ mount the btrfs partition #~ check the mount |
Then create subvolumes:
#~ change directory and create subvolumes
After creating the subvolumes, unmount the btrfs partition and remount with this flags:
#~ change directory #~ unmount the btrfs partition #~ mount the btrfs partition with subvolumes
Finally, mount the other subvolumes:
#~ create folders for the another subvolumes #~ mount the btrfs partition with subvolumes
Step 6: Generate Fstab File for New Installation
The next step is to generate the fstab file for the new installation. The fstab file is a system configuration file that contains information about disk partitions and their mount points. It is used by the system to mount the partitions automatically at boot time. You can do this by running the following commands:
Then create etc folder and generate fstab file:
#~ create etc folder #~ generate fstab file |
Step 7: Bootstrap Fedora Installation
The next step is to bootstrap the fedora installation by running the following commands:
#~ create /etc/yum.repos.d folder #~ create fedora.repo file
Then add the following lines to the
fedora.repo
file:name=Fedora #baseurl=http://download.example/pub/fedora/linux/releases/$releasever/Everything/$basearch/os/ metalink=https://mirrors.fedoraproject.org/metalink?repo=fedora-&arch= enabled=1 countme=1 metadata_expire=7d repo_gpgcheck=0 type=rpm gpgcheck=0 #gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch skip_if_unavailable=False
Then bootstrap the fedora installation:
Step 8: Chroot into the New Installation
The next step is to chroot into the new installation. The
chroot
command changes the apparent root directory for the current running process and its children. This allows you to work within the new installation as if it were the root filesystem. First, you need to mount the filesystems:#~ change directory #~ remove etc/resolv.conf symlink for bind mount #~ touch resolv.conf file #~ mount the filesystems for; do done
Then chroot into the new installation:
#~ chroot into the new installation #~ update the system
Step 9: Install ‘Standard’ group
The next step is to install the
Standard
group, which includes essential packages for a basic Fedora system. You can do this by running the following command:Then check fedora version from rpm command:
Step 10: Change dnf Configuration
The next step is to change the dnf configuration. You can do this by running the following commands:
Then append the following lines to the
dnf.conf
file:gpgcheck=True installonly_limit=3 #~ keep 3 versions of the kernel packages clean_requirements_on_remove=True best=True skip_if_unavailable=True fastestmirror=True #~ find the fastest mirror max_parallel_downloads=10 #~ download 10 packages at the same time
Step 11: Set the Zones, Locale and Etc
The next step is to set the zones, locale and etc. You can do this by running the following commands:
#~ install the locale packages
Then set the timezone, locale and vconsole:
#~ set the timezone (replace Europe/Istanbul with your timezone) #~ set the locale (replace en_US.UTF-8 with your locale) #~ set the vconsole (replace us with your keymap) #~ set hostname
Step 12: Replace Bootloader to Systemd-boot from Grub
In this step, we will use systemd-boot as the boot loader. systemd-boot is a simple UEFI boot manager that provides an easy and efficient way to manage boot entries. You can do this by running the following commands:
#~ remove grub protection #~ remove grub packages #~ install systemd-boot
Then install systemd-boot to the disk:
Step 13: Install Kernel Packages
The next step is to install the kernel packages. You can do this by running the following commands:
Step 14: Set Passwords and Create Users
The next step is to set passwords and create users. You can do this by running the following commands:
#~ set the root password #~ create a new user #~ set the user password
Step 15: Exit and Reboot
Once you have completed the installation, you can exit the chroot and reboot:
#~ exit the chroot #~ unmount the filesystems
Step 16: Fix Selinux Contexts
We have installed Fedora from live media. Therefore, the selinux contexts are not set correctly. Immediately after rebooting the system, press the up key repeatedly after the BIOS screen. When the boot menu appears, press e to temporarily edit the boot entry. Add selinux=0 to the end of the line:
Then press
Enter
to boot the system. After booting the system, login with the root user and change selinux mode topermissive
by running the following command:Then change the
SELINUX
line topermissive
:Reboot the system and selinux contexts will be fixed automatically.
After rebooting the system, change the selinux mode to
enforcing
back.
Conclusion
- Installing Fedora with DNF using the bootstrap method without a GUI installer is an effective method for those who want a minimal and customized system. This process allows you to build a lightweight, efficient, and fully controllable operating system by adding only the components you need. At the same time, it gives you a deeper understanding of Linux FHS. The results achieved in this way both enrich the learning process and provide an experience aimed at advanced users.