MattF
Posts: 55
Joined: Tue Feb 12, 2013 10:01 am

Re: aufs root filesystem

Tue Jul 16, 2013 3:34 pm

Glad it worked.

I'm not sure if I have mentioned earlier, but there are challenges unmounting cleanly at reboot time with aufs if you don't use tmpfs as your rw branch.

In the end I've sacrificed xino which allows me to unmount cleanly, and also substantially reduces the writes to the SD card rw partition as well.

in "init" in the inited the aufs mount line now looks like this:

mount -t aufs -o noatime,noxino,dirs=/rw:/rootfs=ro aufs /aufs

Might turn out useful.

User avatar
rikas
Posts: 17
Joined: Sun Jul 31, 2011 1:28 pm
Location: Austria y Argentina

Re: aufs root filesystem

Tue Jul 16, 2013 10:21 pm

MatF,

thanks for your note!
Up to now I did not notice this - mainly because I use a dedicated script to first stop "all" application services (nagios, apache), then do a backup of selected directories to partition 3 (after mounting it rw and afterwards unmounting - its "emebedded" and not supposed to change every now and then).
If power fails, or just doing a shutdown, changes are lost - but that's not an issue in my case.
My scripts still are flakey - but improving ;-)

Additional, I brew my own kernel - switching to a monolithtic layout, throwing out (in my case) unnecesary functions (sound, some USB, ...) giving a kernel of approx. 12 MB.

Another issue, I ran into: it seems initramfs is only working when part of the kernel, not as extra file - it was mentioned somewhere in the forum (clearly a big advantage when one reads - not only scans the messages :roll: )

-- rikas
-- rikas

MattF
Posts: 55
Joined: Tue Feb 12, 2013 10:01 am

Re: aufs root filesystem

Thu Jul 18, 2013 10:45 am

Just to complete the story, I'm now at 3.10.1 with all the latest FIQ patches (apart from the tracing one) applied, and it's looking very sold (unlike fsck.f2fs :( ).

Just for reference for those that struggle to build

https://dl.dropboxusercontent.com/u/151 ... .1.tar.bz2

Contains the kernel, the modules tree and a slightly hacked ath9k_htc firmware.

scratchy
Posts: 1
Joined: Thu Aug 15, 2013 2:35 pm

Re: aufs root filesystem

Thu Aug 15, 2013 6:26 pm

Hehyo

i just dont get it working >_<.

Whatever im trieing i get kernel errors..
I checked out version 3.6.y and aufs 3.6.
If im compiling the kernel without initramfs it working well !
But when i try to include the initramfs it crashes..
I tried severel initramfs (the one above, the one update-initramfs (raspbian) creates), and serveral methods of creating it but whatever im doing its not working (i even changed "init")
[ 2.490541] Indeed it is in host mode hprt0 = 00001101<\r><\n>
[ 2.509550] mmc0: new high speed SDHC card at address 59b4<\r><\n>
[ 2.540215] mmcblk0: mmc0:59b4 SDU1 15.0 GiB <\r><\n>
[ 2.575714] mmcblk0: p1 p2 p3<\r><\n>
[ 2.692028] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)<\r><\n>
[ 2.749097] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000100<\r><\n>
[ 2.749097] <\r><\n>
[ 2.768181] [<c0013b7c>] (unwind_backtrace+0x0/0xf0) from [<c03b9bb8>] (panic+0x94/0x1e4)<\r><\n>
[ 2.781394] [<c03b9bb8>] (panic+0x94/0x1e4) from [<c0023e7c>] (do_exit+0x6d4/0x788)<\r><\n>
[ 2.794078] [<c0023e7c>] (do_exit+0x6d4/0x788) from [<c00241d0>] (do_group_exit+0x3c/0xc4)<\r><\n>
[ 2.807337] [<c00241d0>] (do_group_exit+0x3c/0xc4) from [<c0024268>] (__wake_up_parent+0x0/0x18)<\r><\n>
PANIC: Attempted to kill init! exitcode=0x00000100<\r><\n>
I really tried many combinations, does anyone have a clue?

MattF
Posts: 55
Joined: Tue Feb 12, 2013 10:01 am

Re: aufs root filesystem

Thu Aug 29, 2013 10:46 am

Hi,

The initramfs needs linking into the kernel at kernel compile time.
So you have something like:
CONFIG_INITRAMFS_SOURCE="i-f2fs.cpio"
Set in .config

Place the cpio archive at the root of your kernel build tree.

roedel
Posts: 4
Joined: Tue Sep 24, 2013 11:23 am

Re: aufs root filesystem

Tue Oct 01, 2013 6:30 pm

Just got my aufs-read-only Pi up and working with Kernel 3.6.11+

Two little annotations that may help everyone else trying a little bit:
Thanks a lot piplayer for your comment on read-only. As mentioned by micerinos there's a little typing error in your code line. The first one is quite clear, the second one (tempfs/tmpfs) is a little tricky. If trying to boot using tempfs the system will complain about a non-existent tempfs and re-mount /dev/mmcblk0p2 in read-write mode which contradicts the whole idea of the aufs-read-only-pi. So changing rwfs=tempfs to rwfs=tmpfs is quite essential for the read-only-pi.
piplayer wrote: dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcbl$/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait rwfs=tempfs
Here's the cmdline.txt that works fine for me:

Code: Select all

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1[b] root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait rwfs=tmpfs
MattF:
I had the same problem cross-compiling from Fedora. Using the pre-built bmc2708 compiler from GitHub as described in http://elinux.org/RPi_Kernel_Compilation instead of the Fedora ones solved the problem for me. Maybe checking ownership and permissions of .config and initramfs.cpio file is also a good idea.

g00b
Posts: 2
Joined: Tue Oct 29, 2013 3:25 am

Re: aufs root filesystem

Tue Oct 29, 2013 6:20 am

roedel,

I am trying with 3.6.y, but I am having problem similar to scratchy. I tried your suggestion of pre-built bmc2708 compiler, but I am still having a similar kernel panic.

[ 3.482001] hid-generic 0003:0764:0501.0001: hiddev0,hidraw0: USB HID v1.10 Device [CPS CP825AVRLCD-G] on usb-bcm2708_usb-1.2/input0
[ 7.448573] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000200
[ 7.448573]
[ 7.462302] [<c0013a7c>] (unwind_backtrace+0x0/0xf0) from [<c03b539c>] (panic+0x94/0x1e4)
[ 7.473570] [<c03b539c>] (panic+0x94/0x1e4) from [<c0023d98>] (do_exit+0x6d4/0x788)
[ 7.484430] [<c0023d98>] (do_exit+0x6d4/0x788) from [<c00240ec>] (do_group_exit+0x3c/0xc4)
[ 7.496015] [<c00240ec>] (do_group_exit+0x3c/0xc4) from [<c0024184>] (__wake_up_parent+0x0/0x18)
PANIC: Attempted to kill init! exitcode=0x00000200


I then tried just the kernel "as is" (no patches, no custom initramfs), and it boots fine. I looked at my init file and thought maybe I was going wrong there. I noticed the line

for x in $(/bin/cat /proc/cmdline); do

expanded when it was run on my raspberry pi in the creation of the initramfs.cpio file (pulled the init out of the initramfs.cpio to check). I was thinking this line was intended to pick up the configuration at runtime. I'm sure I'm doing something wrong :).

Can someone post their initramfs.cpio file? And maybe their /proc/config.gz file? Those used in their build.

Thank you,
g00b


I did take a "new" SD of 2013-09-25-wheezy-raspbian.zip, and then copy over /lib/modules and zImage (to kernel.img) from MattF Wed Jul 10, 2013. Made edits to
1. cmdline.txt for rwfs=tmpfs
2. /etc/fstab for tmpfs /tmp, tmpfs /var/log, and removed /dev/mmcblk0p2 /.

I'm a little afraid of mismatched firmware, but it seems to mostly work so far (sudo shutdown -hP now, always restarts though after shutdown).

Linux raspberrypi 3.8.13-APF9-aufs+ #27 Wed Jul 10 10:19:29 BST 2013 armv6l GNU/Linux

roedel
Posts: 4
Joined: Tue Sep 24, 2013 11:23 am

Re: aufs root filesystem

Tue Oct 29, 2013 5:54 pm

g00b wrote: I did take a "new" SD of 2013-09-25-wheezy-raspbian.zip, and then copy over /lib/modules and zImage (to kernel.img) from MattF Wed Jul 10, 2013.

[...]

Linux raspberrypi 3.8.13-APF9-aufs+ #27 Wed Jul 10 10:19:29 BST 2013 armv6l GNU/Linux
g00b,

This looks strongly like you messed something up with different kernel versions.
  • What's the exact kernel version you have patched? (The version MattFhas posted is 3.10.1, I did succesfully patch the actual stable kernel which is 3.6.11)
  • Did you patch the kernel yourself or did you copy MattF's build? If you patched, was there any error or warning when patching? Which kernel version did you patch? (Take care of matching kernel- and aufs-version) --> http://aufs.sourceforge.net/
  • If you patched a kernel version which is equal to raspbians out-of-the-box-kernel of your build, did you remove or rename the old modules as mentioned in http://elinux.org/RPi_Kernel_Compilation?
  • Have you upgraded to the actual stable firmware using rpi-update before copying the new kernel?

MattF
Posts: 55
Joined: Tue Feb 12, 2013 10:01 am

Re: aufs root filesystem

Thu Nov 28, 2013 11:16 pm

Been away for a while on other things. I've recently updated to 3.11.9 with aufs and the current firmware with the SD corruption fixes in the firmware.

I'll post an updated tar-ball tomorrow as it's a little late now, complete with an updated /boot

The initramfs is of course embedded in the kernel.

It's also F2FS ready, but given the development nature of fsck.f2fs I haven't seriously experimented with how well it works, other than knowing that it will support an F2FS /ro and /rw

Watch this space.

MattF
Posts: 55
Joined: Tue Feb 12, 2013 10:01 am

Re: aufs root filesystem

Fri Nov 29, 2013 10:16 am

OK,

I've uploaded https://dl.dropboxusercontent.com/u/151 ... .9.tar.bz2

This is a tar-ball with everything you need, but it will quite invasively trample all over /boot.
So download this file to /tmp
cd /
mount -o remount,rw /boot
tar jxvf /tmp/3.11.9.tar.bz2

It assumes that you have
/boot on p1
/ro on p2
/rw on p3

I've also uploaded my initramfs at https://dl.dropboxusercontent.com/u/151 ... -f2fs.cpio
For those that want to roll their own kernel but are struggling to make the initramfs.
You need to drop this file (don't extract it unless you want to change it) in the build root of your kernel tree, and have CONFIG_INITRAMFS_SOURCE="i-f2fs.cpio" set in .config

The f2fs tool chain included in the initramfs is not bang up to date, so for the moment I really would stick with ext4(/3/2), but it does work with f2fs, but with no useful fsck capability.

Hope that helps

g00b
Posts: 2
Joined: Tue Oct 29, 2013 3:25 am

Re: aufs root filesystem

Tue Dec 10, 2013 6:22 am

Thank you, MattF.

I was able to extract your tarball on a clean Raspbian SD image. The resulting image is working well. My only personal changes are I use tmpfs for /rw, and I have serial console during bootloader.

On the previous build I was having a problem with the SD card becoming corrupted. And this was just with remounting a partition as rw (from ro), modifying, and setting it back ro. As soon as I rebooted, the SD card would have an error on the partition. What is confusing is I could fsck the partition on a standalone machine to fix, but it would then be corrupted again if I tried to boot it on raspberry. And this partition was not AUFS. Just a ro partition for data which I wanted to update occasionally from remote.

With this drop, everything seems smooth for me. And I able able to halt the machine properly with 'shutdown -hP now'.

I still think my inability to build a proper image is from the 'init' file I generated on the raspberry. I appreciate you posting the cpio file. I will look at its contents.

Thank you!!!
g00b

MattF
Posts: 55
Joined: Tue Feb 12, 2013 10:01 am

Re: aufs root filesystem

Tue Dec 17, 2013 12:16 pm

You are welcome :)

Updated initramfs with the current version of F2FS tools can be found at:
https://dl.dropboxusercontent.com/u/151 ... Dec17.cpio

No other changes from the previous version other than if you use f2fs you may find that fsck actually does something ....

roedel
Posts: 4
Joined: Tue Sep 24, 2013 11:23 am

Re: aufs root filesystem

Wed Feb 05, 2014 1:58 pm

Hey guys,

Thanks to this guide, I'm running my standard aufs-enabled pi-boxes fine and up to date. I haven't had any RAM issues by now, however when doing the swapon, dphys-swapfile is complaining about being unable to read the header of the swapfile.

Code: Select all

$service dphys-swapfile start
Starting dphys-swapfile swapfile setup ...
want /var/swap=100MByte, checking existing: deleting wrong size file (0), generating swapfile ...swapon: /var/swap: read swap header failed: Invalid Argument
done
Have you experienced any problems like this, maybe found a solution or disabled dphys-swapfile?

Stephan

MattF
Posts: 55
Joined: Tue Feb 12, 2013 10:01 am

Re: aufs root filesystem

Fri Feb 07, 2014 9:52 am

I've disabled dphys-swapfile for a long time now.
As the aim of the game (well this particular game) is to minimise SD card writes it made no sense to have this enabled.

I've updated my kernel to 3.13.1 you can get it from:
https://dl.dropboxusercontent.com/u/151 ... .1.tar.bz2

Download it to /tmp, then
cd / && mount -o remount,rw /boot && tar jxvf /tmp/3.13.1.tar.bz2 && sync && sleep 2 && sync && mount -o remount,ro /boot

Or similar...

User avatar
Joel_Mckay
Posts: 289
Joined: Mon Nov 12, 2012 10:22 pm
Contact: Website

Re: aufs root filesystem

Mon Jul 09, 2018 11:23 am

Bit of a stale thread, but I was wondering if anyone has confirmed this method works on the 2018 Raspbian Stretch, aufs4 and kernel 4.14.y ...

I did see the overlay version:
viewtopic.php?f=63&t=161416&start=150

And while my kernel builds fine, the CONFIG_INITRAMFS_SOURCE="initramfs.cpio" kernel version just gives a black-screen with no console messages.
The same kernel does load fine without this, but kinda at a loss how to troubleshoot the issue. Is the "cpio: premature end of archive" normal to see here?

>lsinitramfs /boot/initramfs.cpio
.
bin
bin/sh
bin/busybox
lib
etc
etc/mdev.conf
aufs
rw
sbin
sbin/init
sbin/e2fsck.static
rootfs
proc
dev
dev/console
dev/tty0
sys
usr
usr/bin
usr/sbin
cpio: premature end of archive

Return to “Advanced users”