The Funtoo Linux project has transitioned to "Hobby Mode" and this wiki is now read-only.
Difference between revisions of "Raspberry Pi 2"
(Keeping things consistent with the rest of the RPi pages.) |
(→Formatting: switching from fdisk to cgdisk & arm 32 root partition.) |
||
(11 intermediate revisions by 4 users not shown) | |||
Line 6: | Line 6: | ||
# Raspberry PI 2 | # Raspberry PI 2 | ||
# An existing Linux install | # 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. I used a 16GB class 6 card. | # A [https://www.raspberrypi.org/help/faqs/#sdCards suitable SD card] for your PI. I used a 16GB class 6 card. | ||
# An HDMI cable | # An HDMI cable | ||
Line 27: | Line 27: | ||
First, we run fdisk against our SD card to create boot, root and swap partitions. I gave boot 50MB, swap 256MB and root the rest of the card. I've noticed that the swap space doesn't appear to get used during the time I've spent watching it...perhaps this is un-needed - or perhaps someone who understands how the Pi works a little better can explain it or recommend something better. | First, we run fdisk against our SD card to create boot, root and swap partitions. I gave boot 50MB, swap 256MB and root the rest of the card. I've noticed that the swap space doesn't appear to get used during the time I've spent watching it...perhaps this is un-needed - or perhaps someone who understands how the Pi works a little better can explain it or recommend something better. | ||
==Prepare your SD card== | |||
List the device to be partitioned, mine is on /dev/sdc | |||
{{console|body= | {{console|body= | ||
###i## | ###i## lsblk -o name,size,label,partlabel | ||
}} | |||
{{console|body= | |||
###i## cgdisk /dev/sdc}} | |||
*delete everything: | |||
{{console|body= | |||
Command: ##i##new ↵ | |||
First sector | First sector: ##i## ↵ | ||
Size: ##i## +1M ↵ | |||
Hex Code: ##i##EF02 ↵ | |||
Name: ##i##BIOS Boot ↵ | |||
}} | |||
*scroll down to the large chunk of free space: | |||
Command | {{console|body= | ||
Command: ##i##new ↵ | |||
Hex | First sector: ##i##↵ | ||
Last sector: ##i##+256M ↵ | |||
Hex Code: ##i##EF00 ↵ | |||
Name: ##i##BOOT ↵ | |||
}} | |||
*scroll down to the large chunk of free space: | |||
{{console|body= | |||
Command: ##i##new ↵ | |||
First sector: ##i##↵ | |||
Last sector: ##i##↵ | |||
Hex Code: ##i## 8307 ↵ | |||
Name: ##i##FUNTOO ↵ | |||
}} | |||
{{console|body= | |||
Disk Drive: /dev/sdc | |||
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 ARM32 root (/) FUNTOO | |||
}} | |||
Command | {{console|body= | ||
Command: ##i##write ↵ | |||
Do you want to proceed? (Y/N): ##i##yes ↵ | |||
Command: ##i##quit ↵ | |||
Command | |||
}} | }} | ||
Line 119: | Line 117: | ||
###i## echo "boot/*" >> .git/info/sparse-checkout | ###i## echo "boot/*" >> .git/info/sparse-checkout | ||
###i## git pull --depth=1 origin master | ###i## git pull --depth=1 origin master | ||
}} | |||
Or just pull the tarball from funtoo: | |||
{{console|body= | |||
###i## wget https://code.funtoo.org/bitbucket/users/pnoecker/repos/666/commits/60afaf321f09988fe531d2695627ba9521666b2a#pi-boot.tar.gz | |||
###i## tar -xf pi-boot.tar.gz | |||
}} | }} | ||
Line 125: | Line 129: | ||
{{console|body= | {{console|body= | ||
###i## wget http://build.funtoo.org/funtoo-current/arm-32bit/ | ###i## wget http://build.funtoo.org/funtoo-current/arm-32bit/armv7a_neonvfpv4_hardfp/stage3-latest.tar.xz | ||
###i## wget http://ftp.osuosl.org/pub/funtoo/funtoo-current/snapshots/portage-latest.tar.xz | ###i## wget http://ftp.osuosl.org/pub/funtoo/funtoo-current/snapshots/portage-latest.tar.xz | ||
}} | }} | ||
Line 134: | Line 138: | ||
###i## mkdir ~/piboot ~/piroot | ###i## mkdir ~/piboot ~/piroot | ||
}} | }} | ||
{{note| | {{note|I've chosen to call my mount points piboot and piroot, but most people will want to run /mnt/funtoo & /mnt/funtoo/boot to keep congruent with official install instructions. As always, take care to modify the commands that follow to suit your directory choice.}} | ||
Mount your SD card: | Mount your SD card: | ||
{{console|body= | {{console|body= | ||
Line 166: | Line 170: | ||
}} | }} | ||
===Pre-boot Configuration=== | ===Pre-boot Configuration=== | ||
Edit your make.conf file to | Edit your make.conf file to enable fchroot to compile: | ||
{{file|name=/piroot/etc/portage/make.conf|desk make.conf file|body= | {{file|name=~/piroot/etc/portage/make.conf|desk make.conf file|body= | ||
FEATURES="-pid-sandbox" | |||
}} | }} | ||
Line 200: | Line 202: | ||
---snip--- | ---snip--- | ||
}} | }} | ||
==Chrooting into your new installation== | |||
for a good time install [[Package:Fchroot]] | |||
===Installing qemu=== | |||
Since the Raspberry Pi utilizes the ARM architecture and you reading this (probably) on an x86-compatible device, you can't chroot right away as usual. First, you will have to emerge qemu which will allow you to execute ARM binaries. Before running emerge, you have to add the ARM architecture to qemu's targets in your make.conf: | |||
{{file|name=/etc/portage/make.conf|body= | |||
QEMU_USER_TARGETS="${QEMU_USER_TARGETS} arm" | |||
}} | |||
Furthermore, you will need to enable the "static-user" useflag. This flag is needed to allow us to copy the qemu binary to the Raspberry Pi's filesystem later on: | |||
{{file|name=/etc/portage/package.use|body= | |||
>=media-libs/mesa-11.0.7 gles2 | |||
app-emulation/qemu static-user | |||
}} | |||
Now install qemu: | |||
{{console|body= | |||
emerge -a app-emulation/qemu | |||
}} | |||
===Chrooting=== | |||
First, copy the newly installed file qemu-arm to the Raspberry Pi's filesystem: | |||
{{console|body= | |||
###i## cp -v /usr/bin/qemu-arm ~/piroot/usr/bin/ | |||
}} | |||
Next, '''as root''', start the binfmt service: | |||
{{console|body= | |||
###i## /etc/init.d/binfmt start | |||
}} | |||
Finally perform the usually chroot routine (as described in detail in the Funtoo Linux Installation Guide): | |||
{{console|body= | |||
###i## cd ~/piroot | |||
###i## su | |||
###i## cp -L /etc/resolv.conf etc/resolv.conf | |||
###i## mount --rbind /dev dev | |||
###i## mount --rbind /sys sys | |||
###i## mount -t proc none proc | |||
###i## chroot . /bin/bash | |||
}} | |||
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: | Make sure all buffers have been flushed and unmount the temp directories: | ||
Line 248: | Line 302: | ||
Now is a good time to enable swclock NTP so we can be sure to set the correct time the next time we boot: | Now is a good time to enable swclock NTP so we can be sure to set the correct time the next time we boot: | ||
{{console|body= | {{console|body= | ||
###i## emerge | ###i## emerge -av chrony | ||
}} | }} | ||
Once this finishes building, use rc-update to add it to the default run-level, and start the service with rc: | Once this finishes building, use rc-update to add it to the default run-level, and start the service with rc: | ||
{{console|body= | {{console|body= | ||
###i## rc-update add | ###i## rc-update add chronyd default | ||
###i## rc | ###i## rc | ||
###i## rc-update add swclock boot | ###i## rc-update add swclock boot |
Latest revision as of 08:33, November 18, 2020
This guide draws heavily on Wolfgang Apolinarski's post, Gentoo's Wiki for Raspberry Pi and the Funtoo Raspberry Pi guide.
The guides above are quite probably enough to get most people up and running. I had a few issues along the way, so decided to note them down in case they are of use to others.
What you need
- Raspberry PI 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.
- A suitable SD card for your PI. I used a 16GB class 6 card.
- An HDMI cable
- A USB keyboard
- A cat 5 network cable to connect the PI to your router
Prepare your SD card
Formatting
Insert your SD card into your Linux system. To find out which device it is, issue the following command:
root # dmesg tail
You should see some output identify the device. In my case is was /dev/sdf. 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.
Some of the commands coming up WILL DESTROY DATA on existing devices if you pick the wrong one. Most people reading this guide should be familiar with that, but I know I've certainly found guides on the internet in the past and blindly followed along without a full understanding of what is going on...this warning is for that guy!
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.
First, we run fdisk against our SD card to create boot, root and swap partitions. I gave boot 50MB, swap 256MB and root the rest of the card. I've noticed that the swap space doesn't appear to get used during the time I've spent watching it...perhaps this is un-needed - or perhaps someone who understands how the Pi works a little better can explain it or recommend something better.
Prepare your SD card
List the device to be partitioned, mine is on /dev/sdc
root # lsblk -o name,size,label,partlabel
root # cgdisk /dev/sdc
- 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: 8307 ↵ Name: FUNTOO ↵
Disk Drive: /dev/sdc 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 ARM32 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 16 /dev/sdf1 root # mkswap /dev/sdf2 root # mkfs.ext4 /dev/sdf3
Download the Necessary Files
The next step is to get the kernel and boot firmware for the Raspberry Pi 2 from Github.
Clone the raspberrypi/firmware repository to the system you are using for setting up. It was about 3.5GB when I did it, so depending on your connection speed, it can take quite a while. You only actually need the contents of the boot folder from the repo, so you can save some time just getting that (see below).
root # mkdir ~/tmp_raspberrypi root # cd tmp_raspberrypi root # git clone https://github.com/raspberrypi/firmware.git
If you aren't on a fast internet connection and/or don't have approximately 3.5GB to burn on your hard drive, then you can do a sparse checkout of the boot subdirectory like so (took only around 75MB):
root # git init firmware root # cd firmware/ root # git remote add origin https://github.com/raspberrypi/firmware.git root # git config core.sparsecheckout true root # echo "boot/*" >> .git/info/sparse-checkout root # git pull --depth=1 origin master
Or just pull the tarball from 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:
root # wget http://build.funtoo.org/funtoo-current/arm-32bit/armv7a_neonvfpv4_hardfp/stage3-latest.tar.xz root # wget http://ftp.osuosl.org/pub/funtoo/funtoo-current/snapshots/portage-latest.tar.xz
Prepare Your Boot Partition
Make mount points for your boot and root partitions on the SD card:
root # mkdir ~/piboot ~/piroot
I've chosen to call my mount points piboot and piroot, but most people will want to run /mnt/funtoo & /mnt/funtoo/boot to keep congruent with official install instructions. As always, take care to modify the commands that follow to suit your directory choice.
Mount your SD card:
root # mount /dev/sdf1 ~/piboot root # mount /dev/sdf3 ~/piroot
Copy the boot directory from the git repo onto the boot partition of your SD card:
root # cp -r ~/tmp_raspberrypi/firmware/boot/* ~/piboot
Create a file called cmdline.txt on the boot partition so the rpi can boot into Funtoo:
Paste this into the file:
cmdline.txt
root=/dev/mmcblk0p3 rw rootwait console=ttyAMA0,115200 console=tty1 selinux=0 plymouth.enable=0 smsc95xx.turbo_mode=N dwc_otg.lpm_enable=0 kgdboc=ttyAMA0,115200 elevator=noop
Get the Funtoo Files Onto the SD Card
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-latest.tar.xz -C ~/piroot
Now it's time to unpack the portage tree into the /usr directory of piroot:
root # tar xf portage-latest.tar.xz -C ~/piroot/usr
Pre-boot Configuration
Edit your make.conf file to enable fchroot to compile:
~/piroot/etc/portage/make.conf
FEATURES="-pid-sandbox"
Edit your fstab file so everything mounts correctly on boot:
root # vim ~/piroot/etc/fstab
~/piroot/etc/fstab
/dev/mmcblk0p1 /boot vfat defaults 0 2
/dev/mmcblk0p2 none swap sw 0 0
/dev/mmcblk0p3 / ext4 defaults 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
Installing qemu
Since the Raspberry Pi utilizes the ARM architecture and you reading this (probably) on an x86-compatible device, you can't chroot right away as usual. First, you will have to emerge qemu which will allow you to execute ARM binaries. Before running emerge, you have to add the ARM architecture to qemu's targets in your make.conf:
/etc/portage/make.conf
QEMU_USER_TARGETS="${QEMU_USER_TARGETS} arm"
Furthermore, you will need to enable the "static-user" useflag. This flag is needed to allow us to copy the qemu binary to the Raspberry Pi's filesystem later on:
/etc/portage/package.use
>=media-libs/mesa-11.0.7 gles2
app-emulation/qemu static-user
Now install qemu:
emerge -a app-emulation/qemu
Chrooting
First, copy the newly installed file qemu-arm to the Raspberry Pi's filesystem:
root # cp -v /usr/bin/qemu-arm ~/piroot/usr/bin/
Next, as root, start the binfmt service:
root # /etc/init.d/binfmt start
Finally perform the usually chroot routine (as described in detail in the Funtoo Linux Installation Guide):
root # cd ~/piroot root # su root # cp -L /etc/resolv.conf etc/resolv.conf root # mount --rbind /dev dev root # mount --rbind /sys sys root # mount -t proc none proc root # chroot . /bin/bash
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 # sync root # umount ~/piboot ~/piroot
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 No results if you are going to be adding lots of software to your system.