# Failed to emerge aufs3 on Raspberry Pi

## paulfxh

A confession: I have essentially no Gentoo experience.

However, I have used various linux distros (mostly Debian-based) over several years.

Now the problem:

I have installed Gentoo from here onto a 8GB SD card and it boots up fine on my Raspberry Pi and everything seems to work.

Next, I followed the Portage Introduction in the wiki to update my install. In particular, I ran this update command:

```
# emerge --update --deep --with-bdeps=y --newuse world
```

followed by the three commands in CodeListing 3.14 to remove orphaned dependencies.

So far, so good.

Now, I tried to install squashfs in order to speed up compilation and install of further software, for which I followed this guide.

While, squashfs-tools built and installed without error, when I tried to emerge aufs3, I ended up with the following messages:

 *Quote:*   

> Failed to emerge sys-fs/aufs3-3_p20121015
> 
> Could not find a usable .config in the kernel source directory 

 

The problem seems to be related to the mismatch between the installed 3.2.27+ kernel and the (only) kernel source in /usr/src/ which is linux-3.4.9-gentoo.

However, I'm puzzled as to why no .config file exists anywhere on my system.

I'd appreciate any comments or pointers to help me move this along.

----------

## Bzub

Did you upgrade your kernel and remove the older one?

 *Quote:*   

> 
> 
> I followed the Portage Introduction in the wiki to update my install. In particular, I ran this update command:
> 
> Code:
> ...

 

If so did you run this afterwards? 

```

# run "eselect kernel list" to get all the available options 

eselect kernel set <kernelnumber >
```

seems like your /usr/src/linux link is wrong or nonexisting?

----------

## paulfxh

Thank you for your reply.

 *Bzub wrote:*   

> Did you upgrade your kernel and remove the older one?

 

I have done very little other than run the 

```
# emerge --update --deep --with-bdeps=y --newuse world
```

command.

The kernel was not upgraded as "uname -a" shows the same kernel as before (3.2.27+)

However, it seems the above command inserted the source code for a new kernel (linux-3.4.9-gentoo) in /usr/src/

Note that the Raspberry Pi runs on an armv6 processor and can only handle kernels and software built for this architecture. 

 *Bzub wrote:*   

>  If so did you run this afterwards? 
> 
> ```
> 
> # run "eselect kernel list" to get all the available options 
> ...

 

No, I did not.

Running it now shows me

```
Available kernel symlink targets:

 [1]  linux-3.4.9-gentoo
```

 *Bzub wrote:*   

>  seems like your /usr/src/linux link is wrong or nonexisting?

 

Yes, I think you are correct.

I believe I need to be a little more circumspect in updating Gentoo as the blanket "all or nothing" approach I adopted with the command

```
# emerge --update --deep --with-bdeps=y --newuse world
```

seems to have been the source of this problem.

However, I have been unable to track down, so far, how to avoid updating the kernel, but going ahead with updates on everything else.

----------

## Bzub

When you update world every package that wasn't emerged with --oneshot or -1 will be updated by default.

You can chose to either emerge packages that don't need updating with the --oneshot flag or mask them in package.mask (man snip below)

```
package.mask

    A list of package atoms to mask. Useful if specific versions of packages do not work well for you. For example, you swear by the Nvidia drivers, but only versions earlier than 1.0.4496. No problem!

    Format:

    - comment lines begin with # (no inline comments)

    - one DEPEND atom per line

    Example:

    # mask out versions 1.0.4496 of the nvidia

    # drivers and later

    >=media-video/nvidia-kernel-1.0.4496

    >=media-video/nvidia-glx-1.0.4496

```

your old kernel sources probably got deleted by running a cleanup after the update.

So either configure, make and use your new kernel http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&chap=7

Or get the sources for the old kernel back (and configure it of course). You'll be needing the header files at some point anyway.

You'll need to mask (above) the newer sources to get the old sources back.

----------

## NeddySeagoon

Bzub,

The Pis 3.2.27 kernel exposes its .config file as /proc/config.gz

Get the sources as the wiki.gentoo.org pi section says and decompress /proc/config.gz into the source tree as .config.

You will need git as you will be doing git clone.  However, you only need the resulting tree on the Pi so you can do the fetch anywahere and move the tree over.

I suspect you only need the .config and the headers - not the entire kernel tree.  You won't want the whole git repository on the Pi - thats about 1.2Gb.

... and now you are only a small step from cross compiling and cross distcc but thats for the future.

You cannot use gentoo-sources on the Pi without extensive patching

----------

## paulfxh

Thanks to all for the comments and suggestions.

In view of these, I'm going to start over (as I hadn't really done anything of significance), reinstall Gentoo and this time upgrade using package.mask to prevent kernel upgrading.

However, I must admit I'm still confused as to why Gentoo went ahead and tried, apparently unsuccessfully, to install a kernel that was not suited to the armv6 architecture.   :Sad: 

----------

## NeddySeagoon

paulfxh,

Gentoo didn't try to install a kernel.

To get the gentoo-sources kernel, you must have emerged it.  gentoo-sources does run on ARM so its available to you.

However, the Raspberry Pi is a System on a Chip (SoC) and needs a patched kernel.

Last time I looked, that was at 3.2.27 and available from Git.

There is no kernel included in the stage3 tarball.

Further, the kernel is a special case - emerge only installs the sources. You must build and install it to your taste after the emerge.

Installing Gentoo on a Pi is painful without some help.

I assume you have a more powerful system than the Pi and it runs Gentoo to?

Set up crossdev there as per the wiki, for building the pi kernel.

The cross compiler toolchain can be used to build many packages for the Pi.

Put the cross compiler toolchain together with distcc and you can run emerge on the Pi and have helper(s) do most of the work.

A cross compiler is a tool thay runs on one architecture but produces code that runs on another.

e.g. I run a armv6j-hardfloat-linux-gnueabi cross compiler on my amd64 system to produce code that runs on my Pi.

----------

## paulfxh

Thanks for these comments.

 *NeddySeagoon wrote:*   

> 
> 
> I assume you have a more powerful system than the Pi and it runs Gentoo to?
> 
> 

 

I do have other more powerful machines (it'd be difficult to have something less powerful   :Very Happy:  ) but I have never installed Gentoo before and, as I said in my first post, I have no real Gentoo experience.

Nevertheless, despite this drawback, about a week ago, I followed this guide, pretty much to the letter, to install Gentoo on my RPi.

I then emerged lxde and xorg-server and, thereafter, was able to startx to a fully-functioning GUI desktop using the very nice LXDE environment, but only as root user.

For some reason, however, I was unable to startx as my own user although I have already done this with several other OSes on the RPi.

However, because it took nearly three days to emerge lxde, I re-installed Gentoo as before with the intention this time of putting the portage tree under squashfs as I understand this will dramatically speed things up.

And, the problems I had in doing this are the reason I opened this thread.

My next step will be to re-install Gentoo using the Quick Install guide, update as before but using package.mask to avoid touching the kernel and rely on Hexxeh's rpi-update script to install new kernels when available.

----------

## NeddySeagoon

paulfxh,

The wiki article you followed is a cut down version of Gentoo Install guide, with changes to suit the Pi.

Hexxeh's rpi-update script will fetch new kernels and firmware to /boot but it will not get you kernel sources.

You do not need throw away all the hard work of your current install.

Make friends with quickpkg and emerge -K.

The former makes tarballs of installed binary packages.  The latter forces emerge to use binary packages or fail.

If you know that binary packages will be useful later, set FEATURES="buildpkg" in make.conf.

I have not tried squashfs myself, its easier for me to use a USB HDD or nfs.

Check the groups that your own user is in.  You may well need to be in the video group.

The gentoo-sources kernel is not installed to /boot on the Pi and is not used at all.

Run 

```
uname -a
```

I get 

```
roy@Pi_Net ~ $ uname -a

Linux Pi_Net 3.2.27 #5 PREEMPT Mon Oct 1 17:55:47 BST 2012 armv6l ARMv6-compatible processor rev 7 (v6l) BCM2708 GNU/Linux
```

on my Pi.  This is a cross compiled kernel using the sources from git, following this page.

----------

## paulfxh

Thanks once again for your comments and suggestions.

 *NeddySeagoon wrote:*   

> 
> 
> You do not need throw away all the hard work of your current install.
> 
> Make friends with quickpkg and emerge -K.
> ...

 

Yes, that looks useful. I'll add that option to the armoury.

 *NeddySeagoon wrote:*   

>  have not tried squashfs myself, its easier for me to use a USB HDD or nfs.

 

Well, I clean installed Gentoo from the RPi/Gentoo wiki, configured, overclocked (arm_freq=900) and tried to install squashfs and aufs3 again.

The results were basically the same as squashfs installed without problem but the emerge of aufs3 stopped as before complaining that a keyword change involving sys-fs/aufs3-3_p2012 ....** was necessary to proceed.

Last time, I had used autounmask-write to overcome this barrier but now realize that this is almost certainly the reason I ended up with gentoo-sources for kernel 3.4.9 installed which I was unable to use.

So, looks like aufs3 just isn't available for for armv6 architecture so I'll just have to do without it.

Perhaps, the overclocking, together with a re-compile of everything using cflag -O3, and including the -pipe cflag will be enough to cut down on those lengthy builds.

 *NeddySeagoon wrote:*   

> Check the groups that your own user is in.  You may well need to be in the video group.

 

OK, that sounds reasonable. I'll try that as soon as my re-compile finishes.

----------

## NeddySeagoon

paulfxh,

Do not use -O3.  It allows optimisations that may make the code run faster but at the expense on making the code bigger.

Making the code bigger to make it faster is a doubled edged sword.  Its OK if it fits into the CPU cache still.  If not, it often gets slower, rather then faster because of the extra memory fetches.

The Pi has tiny data and instruction caches, so its very likely that code built with -O3 will be slower than code built with -O2 or -Os.

Further -O3 takes longer to compile and more RAM/swap to run the optimiser.

Squashfs is availble for the Pi. Many people are using it. Howerver, it needs the option enabled in your kernel. Its present in 3.2.27, as shown by 

```
$ zgrep SQUASH /proc/config.gz 

CONFIG_SQUASHFS=m

CONFIG_SQUASHFS_XATTR=y

CONFIG_SQUASHFS_ZLIB=y

CONFIG_SQUASHFS_LZO=y

CONFIG_SQUASHFS_XZ=y

# CONFIG_SQUASHFS_4K_DEVBLK_SIZE is not set

# CONFIG_SQUASHFS_EMBEDDED is not set

CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE=3
```

aufs3 is harder.  After keywording, 

```
armv6j-hardfloat-linux-gnueabi-emerge -1  sys-fs/aufs3 -av
```

gets me

```
Calculating dependencies... done!

[ebuild  N    *] s[quote]y * aufs3-3_p20120813.tar.xz SHA256 SHA512 WHIRLPOOL size ;-) ...                                  [ ok ]

 * Determining the location of the kernel source code

 * Found kernel source directory:

 *     /usr/armv6j-hardfloat-linux-gnueabi/usr/src/linux

 * Found sources for kernel version:

 *     3.2.27

s-fs/aufs3-3_p20120813-r1 to /usr/armv6j-hardfloat-linux-gnueabi/ USE="-debug -doc (-fuse) -hfs -inotify -kernel-patch -nfs -pax_kernel -ramfs" 1,558 kB 

 * You need to apply a patch to your kernel to compile and run the aufs3 module

 * Either enable the kernel-patch useflag to do it with this ebuild

 * or apply /usr/portage/sys-fs/aufs3/files/aufs3-base-2.patch and

 * /usr/portage/sys-fs/aufs3/files/aufs3-standalone-2.patch by hand

 * ERROR: sys-fs/aufs3-3_p20120813-r1 failed (setup phase):

 *   missing kernel patch, please apply it first
```

From this, I can tell that the Raspberry Pi 3.2.27 kernel is not patched to support aufs3 and that aufs is not well tested (if at all) on the Pi.

That does not mean that it does not work, just that nobody knows.

Doing what the message says, setting the USE flag go me to a

```
ld: unrecognized option '-Wl,-O1'
```

linker error.

Thats probably because I'm using a cross compiler, not building on the Pi itself and I did not configure and build the new kernel.

The good news is that the patch applied cleanly.

If you really want aufs3, you need to get the kernel from the git repository, apply the default config to it, apply the patches, then build and install the patched kernel.

With the patched kernel installed, you will get past the first build error above.

The git repository for the kernel wants over 1G of your SD card, after you build it.

----------

## paulfxh

Thanks once again for your words of wisdom and your guidance.

 *NeddySeagoon wrote:*   

> paulfxh,
> 
> Do not use -O3.  It allows optimisations that may make the code run faster but at the expense on making the code bigger.
> 
> Making the code bigger to make it faster is a doubled edged sword.  Its OK if it fits into the CPU cache still.  If not, it often gets slower, rather then faster because of the extra memory fetches.

 

In fact, I used -O2 as I just blindly followed the make.conf recommendations for the RPi in the wiki.

I mistyped when I wrote -O3

 *NeddySeagoon wrote:*   

>  Squashfs is availble for the Pi. Many people are using it. Howerver, it needs the option enabled in your kernel. 

 

Yes, I was able to emerge squashfs-tools without any problem.

Not sure how useful it is without aufs3, however as the wiki seems to stress that it is essential for squashfs.

 *NeddySeagoon wrote:*   

> If you really want aufs3, you need to get the kernel from the git repository, apply the default config to it, apply the patches, then build and install the patched kernel.

 

Well, I don't know if I "really need aufs3".

I'm just looking for a system that works tolerably well on my little RPi.

Given that it's not going to be easy to install aufs3, I'll just plough ahead and see, first, if it's absence is causing sleepless nights or not.

BTW, my -O2 recompile is still running after 36 hours. Think it'll be finished by morning.  :Very Happy: 

----------

## NeddySeagoon

paulfxh,

For holding the portage tree, squashfs alone will be OK. Its read only but thats ok.

You can get a copy of the latest snapshot and put it into squashfs on another linux system then move the squashfs over to the Pi.

You will need to redefine your distfiles location in make.conf as the default, /usr/portage/distfiles will be read only because its in the squashfs. Likewise ./packages, if you set buildpkg in FEATURES.

aufs3 allows you to fake writing to a read only filesystem but its not needed just for portage.

You should really do an x86 or amd64 Gentoo install on your main system.  A Virtualbox install will be fine.

Then you can use cross distcc to have the Gentoo build things for the Pi. 

Virtualbox is a PC emulator that runs in your PC. Its free from Oracle and mostly open source.

Its fairy fast as it depends on the guest and host both being x86/amd64 so the guest actually runs on the host hardware - well almost.

----------

