{"id":188,"date":"2013-08-16T17:31:48","date_gmt":"2013-08-16T15:31:48","guid":{"rendered":"https:\/\/blog.ramses-pyramidenbau.de\/?p=188"},"modified":"2014-06-03T01:36:12","modified_gmt":"2014-06-02T23:36:12","slug":"installing-gentoo-on-raspberry-pi-2","status":"publish","type":"post","link":"https:\/\/blog.vmexit.de\/?p=188","title":{"rendered":"Installing Gentoo on a Raspberry PI"},"content":{"rendered":"<h3>Install ARM Toolchain<\/h3>\n<p><code>$ emerge -av crossdev<br \/>\n$ crossdev -S -v -t armv6j-hardfloat-linux-gnueabi<br \/>\n<\/code><\/p>\n<h3>Get Raspberry Kernel Sources<\/h3>\n<p><code>$ git clone --depth=1 https:\/\/github.com\/raspberrypi\/linux.git<br \/>\n$ wget http:\/\/xecdesign.com\/downloads\/linux-qemu\/linux-arm.patch<br \/>\n$ patch -p1 -d linux\/ &lt; linux-arm.patch<br \/>\n<\/code><\/p>\n<h3>Configure the Kernel for QEMU<\/h3>\n<p><code>$ cd linux<br \/>\n$ make ARCH=arm menuconfig<br \/>\n$ make ARCH=arm<br \/>\n$ make ARCH=arm INSTALL_MOD_PATH=..\/modules modules_install<br \/>\n$ cp arch\/arm\/boot\/zImage ..\/raspi-kernel<br \/>\n<\/code><br \/>\nThis is my <a href=\"https:\/\/ramses-pyramidenbau.de\/~ralf\/raspberry-gentoo\/qemu-kernel\/kernel_config_raspi_qemu.txt\">.config<\/a><br \/>\nand the corresponding zImage and Modules: <a href=\"https:\/\/ramses-pyramidenbau.de\/~ralf\/raspberry-gentoo\/qemu-kernel\/kernel_raspi_qemu.tar.gz\">kernel_raspi_qemu.tar<\/a><\/p>\n<h3>Prepare &#8220;SD Card&#8221;<\/h3>\n<p>Create a sparse Image (this will be the SD Card)<br \/>\n<code>$ dd if=\/dev\/null of=gentoo-raspi.img bs=1G seek=8 # 8GiB Image Partition Image<br \/>\n$ cfdisk gentoo-raspi.img<br \/>\n#first partition: boot, vfat ~80MiB (Partition Type: 0x0C)<br \/>\n#second: Gentoo Root (Partition Type: 0x83)<br \/>\n<\/code><\/p>\n<h3>Mount Image as NBD<\/h3>\n<p><code>$ modprobe nbd max_part=4<br \/>\n$ qemu-nbd --connect=\/dev\/nbd0 -n \/path\/to\/gentoo-raspi.img<\/p>\n<p>$ emerge -av dosfstools<br \/>\n$ mkfs.vfat -n boot \/dev\/nbd0p1<br \/>\n$ mkfs.ext4 -j -L Gentoo -E lazy_itable_init=0,lazy_journal_init=0 \/dev\/nbd0p2<br \/>\n$ mount \/dev\/nbd0p2 \/mnt\/raspi<br \/>\n$ cd \/mnt\/raspi<br \/>\n$ curl http:\/\/distfiles.gentoo.org\/releases\/arm\/autobuilds\/current-stage3-armv6j_hardfp\/stage3-armv6j_hardfp-20130207.tar.bz2 | tar -xvjp<br \/>\n<\/code><\/p>\n<h3>Prepare Base System<\/h3>\n<p><code><br \/>\n$ dd if=\/dev\/zero of=\/mnt\/raspi\/var\/swap bs=1M count=512<br \/>\n$ chmod 0600 \/mnt\/raspi\/var\/swap<br \/>\n$ mkswap \/mnt\/raspi\/var\/swap<\/p>\n<p>$ cd \/mnt\/raspi\/etc<br \/>\n$ vi fstab<\/code><br \/>\n<\/code><br \/>\nInsert the following lines:<br \/>\n<code>LABEL=Gentoo \/ ext4 noatime 0 1<br \/>\nLABEL=BOOT \/boot vfat noatime,defaults 0 0<br \/>\n\/var\/swap  swap  swap defaults 0 0<\/p>\n<p>Set Root Password<br \/>\n<code>$ openssl passwd -1 raspi<br \/>\n$ vi shadow<br \/>\n<\/code><br \/>\nfirst line: root:$1$pDGeoXQj$0zq3sa5b9o9rJ8CpcIpPR\/:10770:0:::::<\/p>\n<p>Set Hostname & Keymap & timezone<br \/>\n<code>$ vi conf.d\/hostname<br \/>\n$ vi conf.d\/keymaps<br \/>\n$ ln -sf ..\/usr\/share\/zoneinfo\/Europe\/Berlin localtime<br \/>\n<\/code><\/p>\n<p>Configure locale.gen<br \/>\n<code>$ vi \/etc\/locale.gen<\/code><\/p>\n<p>Copy  Kernel Modules<br \/>\n<code>$ cp -av \/path\/to\/modules\/lib \/mnt\/raspi<br \/>\n<\/code><\/p>\n<p>Install Portage<br \/>\n<code>$ curl http:\/\/distfiles.gentoo.org\/snapshots\/portage-latest.tar.bz2 | tar -xvjp -C \/mnt\/raspi\/usr<\/code><\/p>\n<p>Set correct make.profile<br \/>\n<code>$ cd \/mnt\/raspi\/etc\/portage rm make.profile<br \/>\n$ ln -sf ..\/..\/usr\/portage\/profiles\/default\/linux\/arm\/13.0 make.profile<\/code><\/p>\n<p>Disconnect NBD<br \/>\n<code>$ umount \/mnt\/raspi<br \/>\n$ qemu-nbd --disconnect \/dev\/nbd0<\/code><\/p>\n<h3>Boot your Raspberry on QEMU<\/h3>\n<p><code>$ qemu-system-arm -kernel zImage -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append \"root=\/dev\/sda2 panic=1 console=ttyAMA0\" -hda gentoo-raspi.img<\/code><br \/>\nLogin: root:raspi<br \/>\nSet Date (Raspi has no hardware Clock \ud83d\ude41 )<br \/>\n<code>$ date --set=\"20130808 14:00\"<br \/>\n$ rc-update del hwclock default<\/code><br \/>\nConfigure Network<br \/>\n<code>$ ifconfig eth0 10.0.2.15 #USE THIS IP!<br \/>\n$ route add default gw 10.0.2.2<br \/>\n$ echo nameserver 8.8.8.8 &gt; \/etc\/resolv.conf #just use google's dns<br \/>\n<\/code><\/p>\n<p>Get dhcp Client and configure network<br \/>\n<code>$ emerge dhcpcd<br \/>\n$ dhcpcd<\/code><\/p>\n<p>Configure eth0 persistently<br \/>\n<code>$ cd \/etc\/init.d<br \/>\n$ ln -s net.lo net.eth0<br \/>\n$ rc-update add net.eth0 boot<\/p>\n<p>$ cd \/etc\/conf.d\/<br \/>\n$ nano net<br \/>\n<\/code><br \/>\nadd the line: config_eth0=\"dhcp\"<\/p>\n<p>You WANT distcc.<br \/>\n<code>emerge -av distcc #Run on both, host and guest<\/code><\/p>\n<p>Edit make.conf<br \/>\n<code>$ echo FEATURES=\"distcc\" >> \/etc\/portage\/make.conf<br \/>\n$ echo MAKEOPTS=\"-j6\" >> \/etc\/portage\/make.conf<\/code><\/p>\n<p>Set DistCC Hosts<br \/>\n<code>$ cd \/etc\/distcc<br \/>\n$ nano hosts<br \/>\n<\/code><\/p>\n<p>Now compile everything you want<\/p>\n<p>Emerge boot stuff and kernel<br \/>\n<code>$ mkdir \/etc\/portage\/package.keywords<br \/>\n$ cd \/etc\/portage\/package.keywords<br \/>\n$ echo sys-boot\/raspberrypi-firmware ** ~arm >> raspi<br \/>\n$ echo sys-kernel\/raspberrypi-sources ** ~arm >> raspi<br \/>\n$ echo media-libs\/raspberrypi-userland ** ~arm >> raspi<\/p>\n<p>$ mount \/boot<br \/>\n$ emerge -av raspberrypi-firmware raspberrypi-sources raspberrypi-userland<br \/>\n<\/code><\/p>\n<p>Compile the kernel<br \/>\n<code>$ cd \/usr\/src\/linux<br \/>\n$ make menuconfig<\/p>\n<p>$ make CC=\"distcc armv6j-hardfloat-linux-gnueabi-gcc\" modules -j5<br \/>\n$ make modules_install<br \/>\n$ make CC=\"distcc armv6j-hardfloat-linux-gnueabi-gcc\" -j5<br \/>\n$ cp arch\/arm\/boot\/zImage \/boot\/kernel.img<br \/>\n<\/code><\/p>\n<p>This is my precompiled Kernel and Modules \/ Firmware:<br \/>\n<a href=\"https:\/\/ramses-pyramidenbau.de\/~ralf\/raspberry-gentoo\/native-kernel\/kernel_config_raspi_native.txt\">.config<\/a><br \/>\n<a href=\"https:\/\/ramses-pyramidenbau.de\/~ralf\/raspberry-gentoo\/native-kernel\/kernel-3.6.11-raspi.tar.gz\">kernel-3.6.11-raspi.tar.gz<\/a><\/p>\n<p>You also want to use SSH:<br \/>\n<code>$ rc-update add sshd default<\/code><\/p>\n<p>And as we do have no RTC:<br \/>\n<code>$ rc-update add ntp-client default<\/code><\/p>\n<p>And a syslogger:<br \/>\n<code>$ emerge -av syslog-ng<br \/>\n$ rc-update add syslog-ng boot<\/code><\/p>\n<p>Here's my image:<br \/>\nIt needs at least 2.8GiB of space (2.3GiB without \/var\/swap)<\/p>\n<p>As .tar.gz archive:<br \/>\nVFAT Boot Partition: <a href=\"https:\/\/ramses-pyramidenbau.de\/~ralf\/raspberry-gentoo\/Raspberry-Boot-20130816.tar.gz\">Raspberry-Boot-20130816.tar.gz<\/a><br \/>\nGentoo Installation: <a href=\"https:\/\/ramses-pyramidenbau.de\/~ralf\/raspberry-gentoo\/Raspberry-Stage4-20130816.tar.gz\">Raspberry-Stage4-20130816.tar.gz<\/a><\/p>\n<p>As full 6GiB raw image which is bootable out of the box:<br \/>\n<a href=\"https:\/\/ramses-pyramidenbau.de\/~ralf\/raspberry-gentoo\/Raspberry-Gentoo-6GiB-Image-20130816.img.gz\">Raspberry-Gentoo-6GiB-Image-20130816.img.gz<\/a><\/p>\n<p>You can use dd to flash it on a SD Card<br \/>\n<code>$ gunzip Raspberry-Gentoo-6GiB-Image-20130816.img.gz<br \/>\n$ dd if=Raspberry-Gentoo-6GiB-Image-20130816.img of=\/dev\/yourraspisdcard<\/code><\/p>\n<p>Have fun with Gentoo on your Raspi \ud83d\ude42<\/p>\n<p>Update 2014-06-03:<\/p>\n<p><a href=\"http:\/\/tutorials.chymera.eu\/blog\/2014\/05\/21\/gentoo-for-the-raspberry-pi\/\">Here<\/a>'s another nice tutorial without any cross-compilation<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Install ARM Toolchain $ emerge -av crossdev $ crossdev -S -v -t armv6j-hardfloat-linux-gnueabi Get Raspberry Kernel Sources $ git clone &#8211;depth=1 https:\/\/github.com\/raspberrypi\/linux.git $ wget http:\/\/xecdesign.com\/downloads\/linux-qemu\/linux-arm.patch $ patch -p1 -d linux\/ &lt; linux-arm.patch Configure the Kernel for QEMU $ cd linux $ make ARCH=arm menuconfig $ make ARCH=arm $ make ARCH=arm INSTALL_MOD_PATH=..\/modules modules_install $ cp arch\/arm\/boot\/zImage &hellip; <a href=\"https:\/\/blog.vmexit.de\/?p=188\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Installing Gentoo on a Raspberry PI<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,10,7,6],"tags":[],"class_list":["post-188","post","type-post","status-publish","format-standard","hentry","category-embedded","category-gentoo","category-kernel","category-linux"],"_links":{"self":[{"href":"https:\/\/blog.vmexit.de\/index.php?rest_route=\/wp\/v2\/posts\/188","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.vmexit.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.vmexit.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.vmexit.de\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.vmexit.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=188"}],"version-history":[{"count":55,"href":"https:\/\/blog.vmexit.de\/index.php?rest_route=\/wp\/v2\/posts\/188\/revisions"}],"predecessor-version":[{"id":297,"href":"https:\/\/blog.vmexit.de\/index.php?rest_route=\/wp\/v2\/posts\/188\/revisions\/297"}],"wp:attachment":[{"href":"https:\/\/blog.vmexit.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.vmexit.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.vmexit.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}