Difference between revisions of "Raspberry Pi 4"

From Funtoo
Jump to navigation Jump to search
(→‎Formatting: GPT YO)
m (→‎Download the Necessary Files: fix code block order)
Line 90: Line 90:
===Download the Necessary Files===
===Download the Necessary Files===
The next step is to get the kernel, and boot firmware for the Raspberry Pi 4 from funtoo.
The next step is to get the kernel, and boot firmware for the Raspberry Pi 4 from funtoo.
{{console|body=
###i## cd /mnt/funtoo
###i## wget https://code.funtoo.org/bitbucket/users/pnoecker/repos/666/commits/60afaf321f09988fe531d2695627ba9521666b2a#pi-boot.tar.gz
###i## tar -xf pi-boot.tar.gz
}}


Grab the stage 3 files and latest portage snapshot:
Grab the stage 3 files and latest portage snapshot:
Line 97: Line 103:
}}
}}
Next you need to get the Funtoo files onto the root partion of the rpi.
Next you need to get the Funtoo files onto the root partion of the rpi.
{{console|body=
###i## cd /mnt/funtoo
###i## wget https://code.funtoo.org/bitbucket/users/pnoecker/repos/666/commits/60afaf321f09988fe531d2695627ba9521666b2a#pi-boot.tar.gz
###i## tar -xf pi-boot.tar.gz
}}


Extract the stage 3 files to your rpi root partition:
Extract the stage 3 files to your rpi root partition:

Revision as of 20:45, November 8, 2020

This guide draws heavily on Raspberry_Pi_2

What you need

  1. Raspberry PI 4
  2. An existing Linux install Undead_USB_Install built with fchroot is a solid choice if you do not have funtoo installed on a hard drive.
  3. A suitable SD card for your PI.
  4. An HDMI cable
  5. A USB keyboard
  6. A cat 5 network cable to connect the PI to your router

Prepare your SD card

List the device to be partitioned, mine is on /dev/sdc

root # lsblk -o name,size,label,partlabel
root # gdisk /dev/sdc
Command: o ↵
This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N): y ↵
Command: n ↵
Partition Number: 1 ↵
First sector: 
Last sector: +1M ↵
Hex Code: EF02 ↵
Command: c ↵
Partition number: 1
Enter name: BIOS Boot
Command: n ↵
Partition Number: 2 ↵
First sector: 
Last sector: +128M ↵
Hex Code: EF00 ↵
Command: c ↵
Partition number: 2
Enter name: BOOT
Command: n ↵
Partition Number: 3 ↵
First sector: 
Last sector: 
Hex Code: 
Command: c ↵
Partition number: 3
Enter name: FUNTOO
Command: w ↵
Do you want to proceed? (Y/N): Y ↵

Create File Systems

Next, we need to create file systems on the partitions:

root # mkfs.vfat -F 32 /dev/sdc2
root # fatlabel /dev/sdc2 "BOOT"
root # mkfs.ext4 /dev/sdc3
root # e2label /dev/sdc3 "FUNTOO"

Prepare Your Boot Partition

Make mount points for your boot and root partitions on the SD card:

root # mkdir /mnt/funtoo

Mount your SD card:

root # mount /dev/sdc3 /mnt/funtoo 
root # mkdir /mnt/funtoo/boot
root # mount /dev/sdc2 /mnt/funtoo/boot

Get the Funtoo Files Onto the SD Card

Download the Necessary Files

The next step is to get the kernel, and boot firmware for the Raspberry Pi 4 from funtoo.

root # cd /mnt/funtoo
root # wget https://code.funtoo.org/bitbucket/users/pnoecker/repos/666/commits/60afaf321f09988fe531d2695627ba9521666b2a#pi-boot.tar.gz
root # tar -xf pi-boot.tar.gz

Grab the stage 3 files and latest portage snapshot: Subarches

root # wget https://build.funtoo.org/1.4-release-std/arm-64bit/arm64_generic/2020-09-07/stage3-arm64_generic-1.4-release-std-2020-09-07.tar.xz

Next you need to get the Funtoo files onto the root partion of the rpi.

Extract the stage 3 files to your rpi root partition:

root # tar xf stage3*

Pre-boot Configuration

Edit your make.conf file to enable fchroot to compile:

   /mnt/funtoo/etc/portage/make.conf
FEATURES="-pid-sandbox"

Edit your fstab file so everything mounts correctly on boot:

root # nano /mnt/funtoo/etc/fstab
   ~/piroot/etc/fstab
proc /proc proc defaults 0 0
LABEL=BOOT /boot vfat noauto,noatime 1 2
LABEL=FUNTOO / ext4 noatime 0 1

Set a password for root on your Rapsberry Pi by generating the password hash and modifying the shadow file on the SD card.

Generate the password hash:

root # openssl passwd -1

Copy the output hash (e.g.: 1z/p4HaT6$QrIaz/RTpBEIorIkzW4Ac.) and paste it into ~/piroot/etc/shadow Remove the asterisk (*) after "root" and replace it with the hash output.

In ~/piroot/etc/inittab search for s0 and disable the line by commeting it out

   ~/piroot/etc/inittab
---snip---
#s0:12345:respawn:/sbin/agetty -L 9600 ttyS0 vt100
---snip---

Chrooting into your new installation

for a good time install Package:Fchroot

Chrooting

First, copy the newly installed file qemu-arm to the Raspberry Pi's filesystem:

root # cp -v /usr/bin/qemu-arm /mnt/funtoo/usr/bin/
root # cp -v /usr/bin/qemu-aarch64 /mnt/funtoo/usr/bin/

Next, as root, start the binfmt service:

root # /etc/init.d/binfmt restart

Finally perform the usually chroot routine (as described in detail in the Funtoo Linux Installation Guide):

root # cd /mnt/funtoo
root # mount --rbind /run run
root # fchroot .

At this point, it is advised to perform a world update. This will spare you some headache later on. Furthermore, to enable ssh login, don't forget to adjust the sshd_config to your needs.

Clean unmount

Make sure all buffers have been flushed and unmount the temp directories:

root # exit
root # cd .. && sync 
root # umount -lR funtoo
   Tip

You could remove the directories and files you've used during the install if you want, but it's probably a good idea to leave them there just in case something isn't working right and you need to come back and check/reconfigure things on the SD card.

Booting the Raspberry Pi 2

Now for the fun part!

Insert the SD card into Rpi. Connect your keyboard, monitor and network card, then power it on. It should boot into Funtoo very quickly. If it doesn't work, go back through the guide and make sure you've got everything configured correctly - in particular the cmdline.txt file on the boot partition.

Log in using the password you created earlier. The first thing you'll want to do is fix the clock, set your time zone and sync your portage tree.

Because the Raspberry Pi does not have a hardware clock, you'll need to set the date and time right away. Later on we'll make sure we can get the correct time at boot via NTP, but for now we need to do it manually

root # date MMDDHHMMCCYY

Next, set your timezone:

root # ln -sf /usr/share/zoneinfo/YOURTIMEZONE /etc/localtime

Now we need make sure we can connect to the internet:

root # rc-update add dhcpcd default
root # rc

The next step is to initialise our portage tree so we can start installing additional packages to our system (the emerge --sync is optional):

root # cd /usr/portage 
root # git checkout funtoo.org
root # emerge --sync

Set your profile with epro:

Depending on what you'll be using your RPi2 for, use epro to set your profile:

root # epro subarch armv7a_hardfp 
root # epro flavor server

Now is a good time to enable swclock NTP so we can be sure to set the correct time the next time we boot:

root # emerge -av chrony

Once this finishes building, use rc-update to add it to the default run-level, and start the service with rc:

root # rc-update add chronyd default
root # rc
root # rc-update add swclock boot

Since the RPi2 doesn't have a hardware clock, remove the hwclock startup script from bootup:

root # rc-update del hwclock boot

Now you can follow the Funtoo Install documentation to continue configuring your system. You'll definitely want to look into sys-devel/distcc if you are going to be adding lots of software to your system.