Note

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

Difference between revisions of "Installing Funtoo on a Raspberry Pi 2"

From Funtoo
Jump to navigation Jump to search
m (Fixed wrong stuff at last steps for ntp.)
(Redirecting to better named page)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
This guide draws heavily on [https://plus.google.com/+WolfgangApolinarski/posts/dNTqe6sVW87 Wolfgang Apolinarski's post], [https://wiki.gentoo.org/wiki/Raspberry_Pi Gentoo's Wiki for Raspberry Pi] and the [http://www.funtoo.org/Raspberry_Pi Funtoo Raspberry Pi guide].
#REDIRECT [[Raspberry Pi 2]]
 
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 to perform pre-install steps on
# A [https://www.raspberrypi.org/help/faqs/#sdCards 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:
{{console|body=
###i## 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.
 
{{warning|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.
 
{{console|body=
###i## fdisk /dev/sdf
Welcome to fdisk (util-linux 2.25.2). Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
 
Command (m for help): o
Created a new DOS disklabel with disk identifier 0x7bc6906d.
 
Command (m for help): n
Partition type
    p primary (0 primary, 0 extended, 4 free)
    e extended (container for logical partitions)
Select (default p):
 
Using default response p.
Partition number (1-4, default 1):
First sector (2048-31326207, default 2048):
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.
 
Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): c
If you have created or modified any DOS 6.x partitions, please see the fdisk documentation for additional information.
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
}}
 
===Create File Systems===
Next, we need to create file systems on the partitions:
 
{{console|body=
###i## mkfs.vfat -F 16 /dev/sdf1
###i## mkswap /dev/sdf2
###i## 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).
 
{{console|body=
###i## mkdir ~/tmp_raspberrypi
###i## cd tmp_raspberrypi
###i## 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):
 
{{console|body=
###i## git init firmware
###i## cd firmware/
###i## git remote add origin https://github.com/raspberrypi/firmware.git
###i## git config core.sparsecheckout true
###i## echo "boot/*" >> .git/info/sparse-checkout
###i## git pull --depth=1 origin master
}}
 
 
Grab the stage 3 files and latest portage snapshot:
 
{{console|body=
###i## wget http://build.funtoo.org/funtoo-current/arm-32bit/armv7a_hardfp/stage3-latest.tar.xz
###i## 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:
{{console|body=
###i## mkdir ~/piboot ~/piroot
}}
{{note|While I've chosen to call my mount points piboot and piroot and locate them in root's home directory on my system, you can call them whatever you like.  As always, take care to modify any commands that follow to suit your environment and choices}}
Mount your SD card:
{{console|body=
###i## mount /dev/sdf1 ~/piboot
###i## mount /dev/sdf3 ~/piroot
}}
 
Copy the boot directory from the git repo onto the boot partition of your SD card:
 
{{console|body=
###i## 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:
{{file|name=cmdline.txt|body=
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:
{{console|body=
###i## tar xf stage3-latest.tar.xz -C ~/piroot
}}
Now it's time to unpack the portage tree into the /usr directory of piroot:
{{console|body=
###i## tar xf portage-latest.tar.xz -C ~/piroot/usr
}}
===Pre-boot Configuration===
Edit your make.conf file to optimise it for the Raspberry PI (taken from http://www.funtoo.org/Arm7va_hardfp). Also add the option to utilize all four cores while compiling:
 
{{file|name=/piroot/etc/portage/make.conf|desk make.conf file|body=
CHOST="armv7a-hardfloat-linux-gnueabi"
CFLAGS="-O2 -pipe -march=armv7-a -mfloat-abi=hard"
MAKEOPTS="-j4"
}}
 
Edit your fstab file so everything mounts correctly on boot:
{{console|body=
###i## vim ~/piroot/etc/fstab
}}
{{file|name=~/piroot/etc/fstab|body=
/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:
{{console|body=
###i## 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
{{file|name=~/piroot/etc/inittab|body=
---snip---
#s0:12345:respawn:/sbin/agetty -L 9600 ttyS0 vt100
---snip---
}}
 
Make sure all buffers have been flushed and unmount the temp directories:
{{console|body=
###i## sync
###i## umount ~/piboot ~/piroot
}}
 
{{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
{{console|body=
###i## date MMDDHHMMCCYY
}}
 
Next, set your timezone:
{{console|body=
###i## ln -sf /usr/share/zoneinfo/YOURTIMEZONE /etc/localtime
}}
 
Now we need make sure we can connect to the internet:
{{console|body=
###i## rc-update add dhcpcd default
###i## 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):
{{console|body=
###i## cd /usr/portage
###i## git checkout funtoo.org
###i## emerge --sync
}}
Set your profile with epro:
 
Depending on what you'll be using your RPi2 for, use epro to set your profile:
{{console|body=
###i## epro subarch armv7a_hardfp
###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:
{{console|body=
###i## emerge ntp -av
}}
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 ntp-client default
###i## rc
###i## rc-update add swclock boot
}}
 
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 02:29, November 1, 2015

Redirect to: