Note

The Funtoo Linux project has transitioned to "Hobby Mode" and this wiki is now read-only.

Difference between revisions of "User:Pnoecker/Raspberry Pi 4"

From Funtoo
Jump to navigation Jump to search
 
(61 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This guide draws heavily on [[Raspberry_Pi_2]]
This guide draws heavily on [[Raspberry_Pi_2]], [[Undead_USB_Install]], and [[Install]]


== What you need ==
== What you need ==
Line 5: Line 5:
# Raspberry PI 4
# Raspberry PI 4
# 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.
# 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.
# A [https://www.raspberrypi.org/help/faqs/#sdCards suitable SD card] for your PI.
# a 32GB or larger SD card, or [https://www.tomshardware.com/how-to/boot-raspberry-pi-4-usb USB if you have updated the firmware.]
# An HDMI cable
# A USB keyboard
# A cat 5 network cable to connect the PI to your router


==Prepare your SD card==
==Prepare your SD card==
===Formatting===
Target your drive as outlined in the official install. [[Install/Prepare_Disk]]


Insert your SD card into your Linux system. To find out which device it is, issue the following command:
{{console|body=
{{console|body=
###i## lsblk -o name,size,label,partlabel
###i## cgdisk /dev/funtoo}}
}}


You should see some output identify the device. In my case is was /dev/sdc. In your case, it's quite possibly something different (maybe something like /dev/mmcblk0, e.g.), so please take care to identify the correct device.
*delete everything:


Now we need to format the SD card to suit our purposes. The following example uses fdisk. If you're more comfortable with a different utility for formatting your drives/cards, you can use that instead.
{{console|body=
Command: ##i##new ↵
First sector: ##i## ↵
Size: ##i## +1M ↵
Hex Code: ##i##EF02 ↵
Name: ##i##BIOS Boot ↵
}}


First, we run cgdisk against our SD card to create boot, and root partitions.
*scroll down to the large chunk of free space:


{{console|body=
{{console|body=
###i## cgdisk /dev/sdc
Command: ##i##new ↵
Welcome to fdisk (util-linux 2.25.2). Changes will remain in memory only, until you decide to write them.
First sector: ##i##↵
Be careful before using the write command.
Last sector: ##i##+256M ↵
Hex Code: ##i##EF00 ↵
Name: ##i##BOOT ↵
}}


Command (m for help): o
*scroll down to the large chunk of free space:
Created a new DOS disklabel with disk identifier 0x7bc6906d.


Command (m for help): n
{{console|body=
Partition type
Command: ##i##new ↵
    p primary (0 primary, 0 extended, 4 free)
First sector: ##i##↵
    e extended (container for logical partitions)
Last sector: ##i##↵
Select (default p):
Hex Code: ##i## 8305 ↵
Name: ##i##FUNTOO ↵
}}


Using default response p.
{{console|body=
Partition number (1-4, default 1):  
                              Disk Drive: /dev/funtoo
First sector (2048-31326207, default 2048):  
                            Size: 62333952, 29.7 GiB
Last sector, +sectors or +size{K,M,G,T,P} (2048-31326207, default 31326207): +50M


Created a new partition 1 of type 'Linux' and of size 50 MiB.
Part. #    Size        Partition Type            Partition Name
----------------------------------------------------------------
            1007.0 KiB  free space
  1        1024.0 KiB  BIOS boot partition   BIOS Boot
  2        256.0 MiB   EFI System                BOOT
  3        29.5 GiB    Linux ARM64 root (/)      FUNTOO
}}


Command (m for help): t
{{console|body=
Selected partition 1
Command: ##i##write ↵
Hex code (type L to list all codes): c
Do you want to proceed? (Y/N): ##i##yes ↵
If you have created or modified any DOS 6.x partitions, please see the fdisk documentation for additional information.
Command: ##i##quit ↵
Changed type of partition 'Linux' to 'W95 FAT32 (LBA)'.
 
Command (m for help): n
Partition type
      p primary (1 primary, 0 extended, 3 free)
      e extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2):
First sector (104448-31326207, default 104448):
Last sector, +sectors or +size{K,M,G,T,P} (104448-31326207, default 31326207): +256M
 
Created a new partition 2 of type 'Linux' and of size 256 MiB.
 
Command (m for help): t
Partition number (1,2, default 2): 2
Hex code (type L to list all codes): 82
 
Changed type of partition 'Linux' to 'Linux swap / Solaris'.
 
Command (m for help): n
Partition type
      p primary (2 primary, 0 extended, 2 free)
      e extended (container for logical partitions)
Select (default p):
 
Using default response p.
Partition number (3,4, default 3):
First sector (628736-31326207, default 628736):
Last sector, +sectors or +size{K,M,G,T,P} (628736-31326207, default 31326207):
 
Created a new partition 3 of type 'Linux' and of size 14.7 GiB.
 
Command (m for help): w
}}
}}


Line 88: Line 65:


{{console|body=
{{console|body=
###i## mkfs.vfat -F 32 /dev/sdc2
###i## mkfs.vfat -F 32 /dev/funtoo2
###i## fatlabel /dev/sdc2 "BOOT"
###i## fatlabel /dev/funtoo2 "BOOT"
###i## mkfs.ext4 /dev/sdc3
###i## mkfs.ext4 /dev/funtoo3
###i## e2label /dev/sdc3 "FUNTOO"
###i## e2label /dev/funtoo3 "FUNTOO"
}}
}}


Line 102: Line 79:
Mount your SD card:
Mount your SD card:
{{console|body=
{{console|body=
###i## mount /dev/sdc3 /mnt/funtoo  
###i## mount /dev/funtoo3 /mnt/funtoo  
###i## mkdir /mnt/funtoo/boot
###i## mkdir /mnt/funtoo/boot
###i## mount /dev/sdc2 /mnt/funtoo/boot
###i## mount /dev/funtoo2 /mnt/funtoo/boot
}}
}}


===Get the Funtoo Files Onto the SD Card===
===Get the Funtoo Files Onto the SD Card===
===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.
Grab the latest [[Arm64_generic]] stage 3 file:
 
Grab the stage 3 files and latest portage snapshot:
[[Subarches]]
[[Subarches]]
*or use a ffs stage 3 https://area31.host.funtoo.org/ffs/stages/arm-64bit/
{{console|body=
{{console|body=
###i## cd /mnt/funtoo
###i## 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
###i## 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:
{{console|body=
{{console|body=
###i## cd /mnt/funtoo
###i## tar --numeric-owner --xattrs --xattrs-include='*' -xpf stage3*
###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:
===Pre-boot Configuration===
*Edit your make.conf file to enable fchroot to compile:
 
{{console|body=
{{console|body=
###i## tar xf stage3*
###i## nano /mnt/funtoo/etc/portage/make.conf
}}
}}
===Pre-boot Configuration===
Edit your make.conf file to enable fchroot to compile:


{{file|name=/mnt/funtoo/etc/portage/make.conf|desk make.conf file|body=
{{file|name=/mnt/funtoo/etc/portage/make.conf|desk make.conf file|body=
Line 136: Line 110:
}}
}}


Edit your fstab file so everything mounts correctly on boot:
*Edit your fstab file so everything mounts correctly on boot:
*Raspberry pi only supports partuuid and partlabel loading:
{{console|body=
{{console|body=
###i## nano /mnt/funtoo/etc/fstab
###i## nano /mnt/funtoo/etc/fstab
}}
}}


{{file|name=~/piroot/etc/fstab|body=
{{file|name=/mnt/funtoo/etc/fstab|body=
proc /proc proc defaults 0 0
proc /proc proc defaults 0 0
LABEL=BOOT /boot vfat noauto,noatime 1 2
PARTLABEL=BOOT /boot vfat noauto,noatime 1 2
LABEL=FUNTOO / ext4 noatime 0 1
PARTLABEL=FUNTOO / ext4 noatime 0 1
tmpfs /var/tmp/portage tmpfs uid=portage,gid=portage,mode=775,noatime 0 0
}}
}}


Set a password for root on your Rapsberry Pi by generating the password hash and modifying the shadow file on the SD card.
==Chrooting into your new installation==
===for a good time install [[Package:Fchroot]]===
Generate the password hash:
 
*Fchroot in:
{{console|body=
{{console|body=
###i## openssl passwd -1
###i## cd /mnt/funtoo
###i## fchroot .
###i## export PS1="FUNTOO $PS1"
}}
}}


Copy the output hash (e.g.: 1z/p4HaT6$QrIaz/RTpBEIorIkzW4Ac.) and paste it into ~/piroot/etc/shadow
====set your pass====
Remove the asterisk (*) after "root" and replace it with the hash output.
*Set yo password
 
{{console|body=
In ~/piroot/etc/inittab search for s0 and disable the line by commeting it out
###i## useradd -o -u 0 -g 0 funtoo && passwd funtoo && ego sync
{{file|name=~/piroot/etc/inittab|body=
---snip---
#s0:12345:respawn:/sbin/agetty -L 9600 ttyS0 vt100
---snip---
}}
}}


==Chrooting into your new installation==
*compile in ram
for a good time install [[Package:Fchroot]]
 
===Chrooting===
First, copy the newly installed file qemu-arm to the Raspberry Pi's filesystem:
{{console|body=
{{console|body=
###i## cp -v /usr/bin/qemu-arm /mnt/funtoo/usr/bin/
###i## mkdir /var/tmp/portage
###i## cp -v /usr/bin/qemu-aarch64 /mnt/funtoo/usr/bin/
###i## chown portage:portage /var/tmp/portage
###i## mount /var/tmp/portage
}}
}}


Next, '''as root''', start the binfmt service:


{{console|body=
{{console|body=
###i## /etc/init.d/binfmt restart
###i## echo "media-libs/raspberrypi-userland-bin **" >> /etc/portage/package.accept_keywords
###i## echo "sys-boot/raspberrypi-firmware **" >> /etc/portage/package.accept_keywords
###i## echo "sys-kernel/raspberrypi-image **" >> /etc/portage/package.accept_keywords
###i## emerge raspberrypi-userland-bin raspberrypi-firmware raspberrypi-image
}}
}}
Finally perform the usually chroot routine (as described in detail in the Funtoo Linux Installation Guide):


{{console|body=
{{console|body=
###i## cd /mnt/funtoo
###i## nano /boot/config.txt
###i## mount --rbind /run run
###i## fchroot .
}}
}}


At this point, it is advised to perform a world update. This will spare you some headache later on.  
{{file|name=/boot/config.txt|body=
Furthermore, to enable ssh login, don't forget to adjust the sshd_config to your needs.
disable_overscan=1
 
dtparam=audio=on
==Clean unmount==
dtoverlay=vc4-fkms-v3d
max_framebuffers=2
arm_64bit=1
}}


Make sure all buffers have been flushed and unmount the temp directories:
{{console|body=
{{console|body=
###i## exit
###i## nano /boot/cmdline.txt
###i## cd .. && sync
###i## 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.}}
{{file|name=/boot/cmdline.txt|desc=Stifler's Mom|body=
 
console=tty1 root=PARTLABEL=FUNTOO rootfstype=ext4 elevator=noop fsck.repair=yes quiet rootwait
==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
{{console|body=
###i## date MMDDHHMMCCYY
}}
}}


Next, set your timezone:
Set your timezone:
{{console|body=
{{console|body=
###i## ln -sf /usr/share/zoneinfo/YOURTIMEZONE /etc/localtime
###i## ln -sf /usr/share/zoneinfo/America/Detroit /etc/localtime
}}
}}


Now we need make sure we can connect to the internet:
*Set Services:
{{console|body=
{{console|body=
###i## rc-update add dhcpcd default
###i## rc-update add dhcpcd default
###i## rc
###i## rc-update add busybox-ntpd boot
###i## rc-update add swclock boot
###i## rc-update del hwclock boot
###i## rc-update del swap boot
###i## echo "funtoo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
}}
}}


The next step is to initialise our portage tree so we can start installing additional packages to our system (the emerge --sync is optional):
{{note|you should probably test that your pi boots at this point BEFORE emerging everything.}}
 
===Reboot and merge,or just merge===
*Set your profile:
 
{{console|body=
{{console|body=
###i## cd /usr/portage  
###i## epro list
###i## git checkout funtoo.org
###i## epro flavor desktop
###i## emerge --sync
###i## epro mix-in lxde
###i## echo "media-plugins/alsa-plugins pulseaudio" >> /etc/portage/package.use
###i## echo "net-print/cups -zeroconf" >> /etc/portage/package.use
###i## echo "gnome-base/gvfs -http" >> /etc/portage/package.use
###i## emerge xorg-x11 elogind pulseaudio networkmanager lightdm lxde-meta dillo
}}
}}
Set your profile with epro:


Depending on what you'll be using your RPi2 for, use epro to set your profile:
{{console|body=
{{console|body=
###i## epro subarch armv7a_hardfp
###i## emerge -avuND @world
###i## 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:
[[Install/Stage3_Desktop]]
{{console|body=
 
###i## emerge -av chrony
==Clean unmount==
}}
Once this finishes building, use rc-update to add it to the default run-level, and start the service with rc:
{{console|body=
###i## rc-update add chronyd default
###i## rc
###i## rc-update add swclock boot
}}


Since the RPi2 doesn't have a hardware clock, remove the hwclock startup script from bootup:
Make sure all buffers have been flushed and unmount the temp directories:
{{console|body=
{{console|body=
###i## rc-update del hwclock boot
###i## exit
###i## cd .. && sync
###i## umount -lR funtoo
}}
}}


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

Latest revision as of 21:52, January 9, 2023

This guide draws heavily on Raspberry_Pi_2, Undead_USB_Install, and Install

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 32GB or larger SD card, or USB if you have updated the firmware.

Prepare your SD card

Target your drive as outlined in the official install. Install/Prepare_Disk

root # cgdisk /dev/funtoo
  • delete everything:
Command: new ↵
First sector: 
Size:  +1M ↵
Hex Code: EF02 ↵
Name: BIOS Boot ↵
  • scroll down to the large chunk of free space:
Command: new ↵
First sector: 
Last sector: +256M ↵
Hex Code: EF00 ↵
Name: BOOT ↵
  • scroll down to the large chunk of free space:
Command: new ↵
First sector: 
Last sector: 
Hex Code:  8305 ↵
Name: FUNTOO ↵
Disk Drive: /dev/funtoo
                            Size: 62333952, 29.7 GiB

Part. #     Size        Partition Type            Partition Name
----------------------------------------------------------------
            1007.0 KiB  free space
   1        1024.0 KiB  BIOS boot partition	  BIOS Boot
   2        256.0 MiB   EFI System                BOOT
   3        29.5 GiB    Linux ARM64 root (/)      FUNTOO
Command: write ↵
Do you want to proceed? (Y/N): yes ↵
Command: quit ↵

Create File Systems

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

root # mkfs.vfat -F 32 /dev/funtoo2
root # fatlabel /dev/funtoo2 "BOOT"
root # mkfs.ext4 /dev/funtoo3
root # e2label /dev/funtoo3 "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/funtoo3 /mnt/funtoo 
root # mkdir /mnt/funtoo/boot
root # mount /dev/funtoo2 /mnt/funtoo/boot

Get the Funtoo Files Onto the SD Card

Download the Necessary Files

Grab the latest Arm64_generic stage 3 file: Subarches

root # cd /mnt/funtoo
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

Extract the stage 3:

root # tar --numeric-owner --xattrs --xattrs-include='*' -xpf stage3*

Pre-boot Configuration

  • Edit your make.conf file to enable fchroot to compile:
root # nano /mnt/funtoo/etc/portage/make.conf
   /mnt/funtoo/etc/portage/make.conf
FEATURES="-pid-sandbox"
  • Edit your fstab file so everything mounts correctly on boot:
  • Raspberry pi only supports partuuid and partlabel loading:
root # nano /mnt/funtoo/etc/fstab
   /mnt/funtoo/etc/fstab
proc /proc proc defaults 0 0
PARTLABEL=BOOT /boot vfat noauto,noatime 1 2
PARTLABEL=FUNTOO / ext4 noatime 0 1
tmpfs /var/tmp/portage tmpfs uid=portage,gid=portage,mode=775,noatime 0 0

Chrooting into your new installation

for a good time install Package:Fchroot

  • Fchroot in:
root # cd /mnt/funtoo
root # fchroot .
root # export PS1="FUNTOO $PS1"

set your pass

  • Set yo password
root # useradd -o -u 0 -g 0 funtoo && passwd funtoo && ego sync
  • compile in ram
root # mkdir /var/tmp/portage
root # chown portage:portage /var/tmp/portage
root # mount /var/tmp/portage


root # echo "media-libs/raspberrypi-userland-bin **" >> /etc/portage/package.accept_keywords
root # echo "sys-boot/raspberrypi-firmware **" >> /etc/portage/package.accept_keywords
root # echo "sys-kernel/raspberrypi-image **" >> /etc/portage/package.accept_keywords
root # emerge raspberrypi-userland-bin raspberrypi-firmware raspberrypi-image
root # nano /boot/config.txt
   /boot/config.txt
disable_overscan=1
dtparam=audio=on
dtoverlay=vc4-fkms-v3d
max_framebuffers=2
arm_64bit=1
root # nano /boot/cmdline.txt
   /boot/cmdline.txt - Stifler's Mom
console=tty1 root=PARTLABEL=FUNTOO rootfstype=ext4 elevator=noop fsck.repair=yes quiet rootwait

Set your timezone:

root # ln -sf /usr/share/zoneinfo/America/Detroit /etc/localtime
  • Set Services:
root # rc-update add dhcpcd default
root # rc-update add busybox-ntpd boot
root # rc-update add swclock boot
root # rc-update del hwclock boot
root # rc-update del swap boot
root # echo "funtoo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
   Note

you should probably test that your pi boots at this point BEFORE emerging everything.

Reboot and merge,or just merge

  • Set your profile:
root # epro list 
root # epro flavor desktop
root # epro mix-in lxde
root # echo "media-plugins/alsa-plugins pulseaudio" >> /etc/portage/package.use
root # echo "net-print/cups -zeroconf" >> /etc/portage/package.use
root # echo "gnome-base/gvfs -http" >> /etc/portage/package.use
root # emerge xorg-x11 elogind pulseaudio networkmanager lightdm lxde-meta dillo
root # emerge -avuND @world

Install/Stage3_Desktop

Clean unmount

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

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

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