larcen
Posts: 6
Joined: Fri Aug 31, 2012 9:21 am

Re: Use initramfs?

Fri Oct 12, 2012 11:35 pm

Hi nixphoeni,

1) Maybe it was a building misconfiguration. I'll review it.

2) Yes, I mean initramfs, not initrd, sorry. Do you think that ncurses problem causes the kernel panic? Well, it's a point to start working...

3) With Buildroot, you can build a initramfs filesystem in a file that is accesible as a block device (loop device), and internally it has an EXT2 filesystem. Anyway, I did this only for testing. I'm sure I'm packaging initramfs file in the right way because I unpack and repack the example initramfs posted in this thread by kadamski, and it works well. Maybe the problem is in the content, but I don't know where. If you see something wrong in the initramfs file, please let me know (I have published the file in the previous post).

What did you mean with "scale down images"?? If I copy the image location and open this URL, I can see the images in large format and read the text. Tell me, and I'll post the next captures in that way...

I think that "loader.bin" isn't needed anymore because if you download the latest firmware files from Github, "loader.bin" doesn't exists right now (git clone git://github.com/raspberrypi/firmware.git). I found this post ( http://www.raspberrypi.org/phpBB3/viewt ... =63&t=6685 ) where "dom" told the possibility to include "loader.bin" functionality into "bootcode.bin".

Greetings, David.

kadamski
Posts: 187
Joined: Fri Jun 08, 2012 10:56 pm

Re: Use initramfs?

Mon Oct 15, 2012 6:11 am

larcen wrote: 1) Maybe it was a building misconfiguration. I'll review it.
It may also be a problem with the location bootloader puts initramfs file at. I didn't test the initramfs support for some time now.
larcen wrote: 2) Yes, I mean initramfs, not initrd, sorry. Do you think that ncurses problem causes the kernel panic? Well, it's a point to start working...
Becasue ncurses was missing, something could not start which caused init process to finish and that caused kernel panic.
larcen wrote: 3) With Buildroot, you can build a initramfs filesystem in a file that is accesible as a block device (loop device), and internally it has an EXT2 filesystem.
So it's basicaly initrd file, not initramfs.
larcen wrote: Anyway, I did this only for testing. I'm sure I'm packaging initramfs file in the right way because I unpack and repack the example initramfs posted in this thread by kadamski, and it works well. Maybe the problem is in the content, but I don't know where. If you see something wrong in the initramfs file, please let me know (I have published the file in the previous post).
But if I understand your problem correctly, using latest firmware files (bootloader) you can't even boot my initramfs image, right?
larcen wrote: I think that "loader.bin" isn't needed anymore because if you download the latest firmware files from Github, "loader.bin" doesn't exists right now (git clone git://github.com/raspberrypi/firmware.git). I found this post ( http://www.raspberrypi.org/phpBB3/viewt ... =63&t=6685 ) where "dom" told the possibility to include "loader.bin" functionality into "bootcode.bin".
Yes, that's true. Couple days ago loader.bin was removed from bootloader chain.

larcen
Posts: 6
Joined: Fri Aug 31, 2012 9:21 am

Re: Use initramfs?

Fri Oct 19, 2012 4:38 pm

Hi again,

Sorry about the delay...hard work days.

1) Including ncurses lib and some other missing libs (a problem with scripts for post processing Buildroot's initramfs), I could startup the system, but only with the old built kernel (and the latest firmware files). I have to test again the latest kernel version.

2) With the latest kernel version (compiled with gzipped initramfs support), I can't load initramfs using the newest or the old firmware files. Meaning the "latest kernel version", the version available when I posted my first message.

Maybe I'll do some new tests this weekend, and I'll tell the results here. If you want me to test something, let me know :)


Greetings, David.

mrvn
Posts: 58
Joined: Wed Jan 09, 2013 6:50 pm

Initramfs overlaps kernel

Thu May 29, 2014 3:45 pm

There still seems to be a problem with loading the initramfs. The loader seems to ignore the BSS section and places the initramfs 8 MiB after the end of the text segment:

Code: Select all

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         00001364  80008000  00008000  00008000  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  1 .rodata       00000108  8000a000  0000a000  0000a000  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  2 .init_array   00000010  8000a108  0000a108  0000a108  2**2
                  CONTENTS, ALLOC, LOAD, DATA
  3 .data         00004000  8000c000  0000c000  0000c000  2**14
                  CONTENTS, ALLOC, LOAD, DATA
  4 .got          00000044  80010000  00010000  00010000  2**2
                  CONTENTS, ALLOC, LOAD, DATA
  5 .bss          04000438  80010048  00010048  00010044  2**3
                  ALLOC
  6 .comment      00000011  00000000  00000000  00010044  2**0
                  CONTENTS, READONLY
  7 .ARM.attributes 0000003a  00000000  00000000  00010055  2**0
                  CONTENTS, READONLY
As you can see the BSS section is intentionally HUGE, slightly over 64 MiB. With that image the initramfs gets loaded at 0x0080A000 (0x00010000 bytes). Unfortunately that overlaps the BSS segment and gets overwritten when the BSS segment is cleared on boot. That probably also accounts for the problems with linux when you didn't add the 8 MiB space before the initramfs, where it would complain about overlaps.

You might say I should move the initramfs out of the way before clearing the BSS segment but the same would happen if the .data segment is over 8 MiB large. In which case the loader would overwrite the data section and corrupt the kernel image.

Would it be possible to load the initramfs after the last (as in highest address) segment, possibly still with that 8MiB margin just to be sure?

Secondly it would be nice to support multiple initramfs. For my own kernel I want to use a Device Tree file as first initramfs, a bootsplash image as second initramfs and an actual initramfs as third. The way this should work would be multiple "initramfs <file> [followkernel|<address>]" lines in config.txt and then multiple Initrd2 ATAGs, one per file.

mrvn
Posts: 58
Joined: Wed Jan 09, 2013 6:50 pm

Re: Use initramfs?

Mon Jun 16, 2014 10:28 pm

Never mind the bss problem. that is at my end.

But multiple ramdisks would still be nice.

User avatar
dasmanul
Posts: 502
Joined: Wed Sep 30, 2015 10:20 am
Location: Frankfurt, Germany

Re: Use initramfs?

Fri Sep 23, 2016 5:23 pm

Could somebody please update me on the current status of this? It's awfully hard to find any documentation on initramfs.

Am I right in assuming that the followkernel option has made it into mainline start.elf by now? So I could just do a

Code: Select all

update-initramfs -c -k 4.4.13-v7+
, put

Code: Select all

initramfs initrd.img-4.4.13-v7+ followkernel
into /boot/config.txt and I'd be good to go? Or do I still need to put something (what?) into /boot/cmdline.txt?

Aydan
Posts: 582
Joined: Fri Apr 13, 2012 11:48 am
Location: Germany, near Lake Constance

Re: Use initramfs?

Fri Sep 23, 2016 5:59 pm

sounds about right.
You might want to make a copy of the kernel and add kernel=<name of kernel file> to the config text, and hold the raspberrypi-kernel package t avoid surprises

Regards
Aydan

unixbigot
Posts: 2
Joined: Wed Jun 08, 2016 9:08 pm

Re: Use initramfs?

Thu Jun 08, 2017 12:38 am

I too found a ton of outdated or wrong information.

Initial ramdisk on raspbian definitely works fine.

Do this (as root where # is shown):

1. # apt-get install initramfs-tools busybox-static
2. # echo "BUSYBOX=y" >>/etc/initramfs-tools/conf.d/local
3. # echo "initramfs initrd.img followkernel" >>/boot/config.txt
4. add your custom boot actions to /etc/initramfs/scripts/local-top/local.sh (or other script directory)
5. # mkinitramfs -v -o /boot/initrd.img
6. # reboot

minghia
Posts: 5
Joined: Fri May 18, 2018 11:31 am

Re: Use initramfs?

Fri Jun 01, 2018 3:12 am

I tried to add mounting /usr via NFS in the initrd.img and it didn't work. I even added a script to add /etc/initramfs-tools/scripts/local-premount to mount rm NFS /usr mount. This did not work. Somehow /usr needs to be mounted in the boot up phase but there is no way to mount it via NFS. The only way I can get my system to boot is by putting all the system under the one NFS mount. The problem with this is that I will have to have 20+ instances of /usr in each of my Raspberry PIs NFS mounted root partition. This seems a waste of disk space. Surely there must be a way to mount /usr via NFS in either an initrd or some other boot time manner?

Return to “General discussion”

Who is online

Users browsing this forum: No registered users and 45 guests