Fedora 23 on Raspberry Pi 2 or 3

Raspberry Pi 2B
Credit: raspberrypi.org

Installing Fedora 23 on the Pi2 or 3 is pretty reasonable with a little effort and worth the trouble.  A real distro may not be exactly snappy on the Pi3 but the advantage of a familiar environment with a real browser makes up for a little slowness. Something to note, activating WiFi is not included here, so have a wired connection please.

If you came in from Redit or StackExchange or similar, please upvote my posting there so that others will see this page too.

pi 2B Terminal I’m going to assume you have the ability to write a Raspberry image to SD card with some confidence, to issue basic commands in a terminal session and that you have root access on a Linux machine to work with. My apologies to those with more skills but I’m targeting as wide an audience as possible. These instructions were tested using copy and paste from each of the code blocks below. If you’re unable to copy and paste, please pay careful attention to word-wrap because some of the lines are rather long.

I started with Jon Archer’s directions along with the steps in the comments plus a missing instruction that was critical to my install; with his directions the USB mouse and keyboard don’t work until you upgrade the Pi’s firmware images. Here I avoid the issue by downloading the firmware .zip file rather than cloning the firmware repository.

Download your interface of choice from http://mirrors.oit.uci.edu/fedora/linux/releases/23/Images/armhfp/

In my case, I used Mate in hopes of a reasonable trade off between resources and capabilities. My choice would be:

wget http://mirrors.oit.uci.edu/fedora/linux/releases/23/Images/armhfp/Fedora-Mate-armhfp-23-10-sda.raw.xz

Download errors happen so before wasting a ton of time on a bad image, compare the checksum in http://mirrors.oit.uci.edu/fedora/linux/releases/23/Images/armhfp/Fedora-Images-armhfp-23-CHECKSUM to the output of:

sha256sum Fedora-Images-armhfp-23-CHECKSUM

The mirrors I used were all throttled and the only torrent I found had only 2 seeders, so I recommend doing the following download in parallel in an additional terminal session:

wget -O ~/Downloads/master.zip https://github.com/raspberrypi/firmware/archive/master.zip

SD Card Before issuing the commands below, make sure you know exactly where your sdcard is and that your device options match the device.  A good way to find it is to insert the card and run:

dmesg | tail

Some likely names include /dev/sda, /dev/sdb, and /dev/mmcblk0.

I didn’t have a desktop with Windows, IOS or Linux, just the Pi2 running Raspbian, so I used a SD to USB adapter which appears as /dev/sda.  Make sure all the partitions on your SD card are not mounted and unmount them if needed.  Mine had one partition auto-mounted so I unmounted that with the following command:

umount /dev/sda1

This command, like just about everything below, requires root.

The next step was to copy the image to SD with the following command (again edit the version number if needed):

xzcat Fedora-Mate-armhfp-23-10-sda.raw.xz |dd of=/dev/sda bs=1M;sync

The image write took 16 minutes for me, so this might be a good time to get a fresh cup of coffee.

Change the partition type of partition 1 from 0x83 to 0x0B and expand the root partition to fill the disk with your preferred tools or with something like:

echo -e "p\nt\n1\nb\nd\n3\nn\np\n3\n`fdisk -l /dev/sda|tail -1|tr -s ' '|cut -d' ' -f2`\n\np\nw\n"|fdisk /dev/sda; sync; partprobe

Replace the ext3 filesystem with a fat32 one using:

mkfs.vfat /dev/sda1

Expand the root partition to fill the disk with:

e2fsck -f /dev/sda3
resize2fs /dev/sda3

Mount the partitions with:

mkdir /mnt/sdcard
mount /dev/sda3 /mnt/sdcard
mount /dev/sda1 /mnt/sdcard/boot

Extract the boot and module files from the raspberry firmware archive downloaded earlier:

unzip ~/Downloads/master.zip firmware-master/boot/* -d /mnt/sdcard/boot/
mv /mnt/sdcard/boot/firmware-master/boot/* /mnt/sdcard/boot/
rm -rf /mnt/sdcard/boot/firmware-master
unzip ~/Downloads/master.zip firmware-master/modules/*-v7+/* -d /mnt/sdcard/lib/
mv /mnt/sdcard/lib/firmware-master/modules/*-v7+/ /mnt/sdcard/lib/modules/
rm -rf /mnt/sdcard/lib/firmware-master/

Edit /mnt/sdcard/etc/fstab, setting the boot partition type to vfat and replacing the UUID of the boot partition with the UUID from:

blkid -s UUID /dev/sda1

Note, vfat UUIDs really are much shorter.  It will be 8 hex digits with a dash in the middle.

Create the cmdline.txt file with:

echo "dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 \
root=/dev/mmcblk0p3 rootfstype=ext4 elevator=deadline rootwait"\
>/mnt/sdcard/boot/cmdline.txt

Create config.txt with something like:

cat </mnt/sdcard/boot/config.txt
disable_overscan=1
hdmi_force_hotplug=1
hdmi_group=1
hdmi_mode=16
HERE

The above settings force full HD over HDMI with no overscan, even if you boot while the monitor is off or disconnected.  Adjust as needed per the Raspberry PI docs, or pull the config.txt from your existing Pi setup.

Install rpi-update with:

wget -O /mnt/sdcard/usr/bin/rpi-update https://raw.githubusercontent.com/Hexxeh/rpi-update/master/rpi-update
chmod +x /mnt/sdcard/usr/bin/rpi-update

Adjust the root password by copying from an existing /etc/shadow file to /mnt/sdcard/etc/shadow.  The password is the long string between the 1st and 2nd : characters, or set it using the following commands:

read -s -p "Enter password: " pass
echo -n root:$pass | chpasswd -c SHA512 -R /mnt/sdcard

Finish up this phase of the install with:

umount /mnt/sdcard/boot
umount /mnt/sdcard
sync

Install the SD card in your Pi2 and boot.

At this point, your Pi2 pi might come up to the Fedora first boot screen but the mouse and keyboard don’t work.  The problem will probably be resolved by running rpi-update.

Get the DHCP address from your router or DHCP server and ssh into the Pi2 as root.  (if you’re doing all this from your Pi2 like I did, you can reasonably guess that the address won’t change.)  In my case, this was the only “desktop” I had so I used ConnectBot from my phone.

Install binutils so that rpi-update can run:

dnf install binutils

Update your Fedora install and Pi2 firmware with:

dnf update
rpi-update

Reboot with the new firmware and the mouse/keyboard should work:

init 6

Complete the Fedora firstboot menus.

At this point, you have a basic functioning Fedora desktop.

If sound is not working in 23, try this:
cat </etc/modules-load.d/snd_bcm2835.conf
#load Raspberry Pi sound module
snd_bcm2835
HERE
modprobe snd_bcm2835

See my next post about what to do after install to make a more complete desktop Fedora system with multimedia.

Advertisements

21 thoughts on “Fedora 23 on Raspberry Pi 2 or 3

  1. Your fdisk command to delete a partition uses defaults, and for my system those defaults were wrong, so you may want to explicitly specify the partition number as 1.

    Like

    1. Interesting, I tried several versions of fdisk and the defaults either didn’t exist or were correct. Partition 1 is only edited for type, 3 should be deleted and recreated to fill the media. I’ve updated the script to work with all variants that I found. Thank you.

      Like

  2. Okay, I’m working on this, and I’ve hit and solved a few problems. Partition 1 can be deleted and reformatted, but Partition 3 needs to be extended, not deleted. As the instructions stand at the moment, all data on sda3 is lost, which shows up as a puzzling lack of a /mnt/sdcard/etc/fstab file – in fact the entire /etc directory is missing, and all the rest except /boot and /lib.
    The etc/fstab file I got with Fedora 23 has an extra newline at the end, making the tail -1 command return a blank line, too. I just fired up gparted (we’re in Linux, after all) and vfat formatted /dev/sdb1 and extended (leaving data intact) /dev/sdb3. (Your device names may vary.)
    Keyboard and mouse support has been flawless so far, including an 802.11 keyboard/touchpad. I didn’t need to do any updating there.
    I couldn’t get a boot to GUI, in fact got a severe error, until I found that the SD card can be so slow to mount that it errors out. The fix was to add the noerror option to the sda3 line in /etc/fstab, allowing boot to proceed while the card gets mounted.
    At least on my monitor, video was terrible: all four edges were off the screen. Jon Archer’s config.txt did the trick; take a look and note the overscan specs, which ensure that while some screen is wasted in black “letterbox,” all the desktop shows up.
    I also followed Tim Bosse’s step of adding the NetworkManager-tui and -wifi.
    Here’s hoping this helps more people get Fedora back on the Pi now that they’ve got a good ARM build going! I’m going to use this with my undergrad security students and my Hacker Highschool classes.

    Like

    1. The fdisk command does resize the partition, to do that you delete and recreate the partition. If you can provide details about the OS distribution and the fdisk version that you used, maybe I can identify why yours deleted but didn’t recreate P3. gparted is not included in many distros, including raspbian, so I stick to fdisk here. Of course you can use your choice of familiar tools to accomplish the same things.
      Monitor specific settings are just something you have to set, the no overscan setting I used is compatible to every monitor and TV I own but there are many varieties out there and you always have to set it for your monitor.
      The keyboard problems I had were using Archer’s steps, I haven’t had the issue when using the steps here.
      Good info on the noerror option, thank you.
      Thank you for the feedback.

      Like

      1. Yes, interesting on the partition resizing. I used Fedora 23 to build and fdisk the image, which is also Fedora 23. And yes: deleting the partition and recreating it with a new ending block should leave the data intact! I am scratching my head why I’m losing all data on partition 3; it should indeed be there. But I just ran the process on another 16GB card … and lost all data.
        Maybe it’s just some fluke of my setup…?

        Like

        1. The fdisk from F23 final beta on arm is one of the ones I tested successfully. If anyone else has the issue of partition 3 disappearing after the fdisk, please report it and include the distro, version, platform, and fdisk version. Glenn’s workaround of using gparted is also quite viable if it’s installed on your system. With all partition editors, be sure to leave the first sector in the exact same place and do not use editors that wipe sector zero of a deleted or created partition unless the editor has a resize function or you backup the wiped sector(s).

          Like

  3. Why isn’t the Raspberry Pi 2 Model B by now supported by Fedora ARM with the fedora-arm-image-installer? Are there any plans to add that by Fedora 24?

    Like

    1. I think the issue is that the Pi firmware isn’t the same as the firmware for other boards, so you need that added component to make it work. We’re probably going to have to get used to it; every board is going to need custom firmware and configuration.

      Like

      1. Glenn’s information is consistent with what I’ve heard. I’ve seen various mentions of getting Pi2 (and other major ARM boards) supported natively in the Fedora installer but so far I’m not aware of anyone actually working on it. I expect that the binary blob for the VideoCore IV GPU is the main problem but with last year’s release of the documentation, it is at least possible now. Of course a NVidia type post-install solution is also possible but still requires some bootstrapping process because a Pi boots off the GPU.

        Like

  4. Do you have any suggestions for a “headless” minimal install with ssh access only?
    I’ve tried following these procedures and used an image of /boot I had from a previous Fedora 21 image I found on the net, but it never seems to get a DHCP lease, so I can’t even attempt to SSH to it.

    Thanks!

    Like

    1. I’ve not tried a minimal install but have done headless a few times without any issues. My first attempts using Archer’s instructions would only work headless. I don’t see why minimal would make a difference in this area, but you could try Mate and see. Another option is to diagnose using serial. The steps above leave serial enabled at 115200 and I would assume it is enabled in minimal too. Make sure you handle the level conversion if you’re using a system that isn’t 3.3V like the Pi.

      Like

  5. Thanks Chisight!

    Sadly I don’t actually have a serial cable handy – I was relying on the system obtaining an address from DHCP and then connecting via SSH.

    I tried preventing ‘initial-setup’ from starting at boot (removing the link from the appropriate systemd directory) and set a root password hash manually, but it looks like these builds require you to interact in some way.

    In the short-term, I’ve ended up using one of Vaughan’s Fedora remix builds: https://vaughan.fedorapeople.org/ but I’d rather be able to build my Pi2 directly from the distribution. I’ve been burned before by somebody making remix for one release, but who lost interest after another release.

    Thanks again!

    Like

  6. (Hmm, I replied but my reply wasn’t posted – do you moderate posts? Perhaps the URL I included looked like spam)

    Thanks for that Chisight
    I actually have no serial cable and have used my RPi2 before with a headless network-only install – just ssh access. I had tried to remove initial-setup-text.service from multi-user.target.wants but even with that gone the Pi still won’t get to the point where it tries to get DHCP lease – so there’s no way I can connect.

    I ended up using vaughan’s Fedora 23 remix (the “mini” one) instead. However I had followed your instructions as I’d like to be able to build one straight from Fedora and not rely on other people to repackage it for a headless RPi build. People seem to lose interest in repackaging and then you get stuck with an ancient version of Fedora.

    Thanks

    Like

  7. Sorry about the auto-moderation, it’s just set to WordPress defaults so maybe the link looked spammy to them.
    Vaughan is pretty awesome, but I get what you’re saying and agree with it. (of course, who knows how much these instructions will have to be updated when F25 comes out.)
    If you have a second Pi then serial is just 2 wires, commenting the getty on your client one, and installing minicom. Barring that, my only thought is maybe inserting a script that runs diagnostics commands and writes the results to disk to read offline. (ending with an init 0 so you get a clean dismount)
    The Fedora first run script didn’t interfere with dhcp or sshd for me, so I doubt that’s your issue.

    Like

  8. Usually a tutorial is laid out simple and understandable for those who do it for the first time.
    And most important is reproducible for others, I know on your machine you have to do this and that. But try to be a bit more universal, so others can reproduce what you are doing (isn’t that what you intended in the first place ?) The part where you extracted and moved the rasperry firmware is awfull.
    move, delete, move again. It was hard to follow.

    You seem to have a lot of knowledge of linux things, but if I wanted to decipher things I would have gone elsewhere.I managed to make it (in the end), you tutorial was useful for the command that were neccessary.

    Anyway,
    Thanks a lot ! 🙂

    Like

  9. Anon, The extract and move of the Raspberry firmware is done with the minimal steps possible using the tools installed by default in Raspbian Jessie. If you have alternatives, that I didn’t consider and only use tools installed by default, please let me know.
    SANYI, A bit of fear may be a healthy thing for you. It is quite possible to trash your hard drive if you don’t do the dd to the correct destination. If you’re not experienced with using SD images for a Pi then you should probably use a windows based GUI tool instead.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s