Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Gentoo from RAM
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo on Alternative Architectures
View previous topic :: View next topic  
Author Message
konan
n00b
n00b


Joined: 13 Sep 2006
Posts: 13

PostPosted: Fri Jan 19, 2007 11:42 am    Post subject: Gentoo from RAM Reply with quote

Hi!

Is it possible (and how) to run gentoo fully from RAM?

I have embedded system, for which I made "tinyGentoo" and put it on flash card. I managed to boot Gentoo from flashcard, now I'm trying to load the whole image into ram at boot time and then run OS from there.


I tried to do this based on this how-tos, but whith no luck
https://forums.gentoo.org/viewtopic-t-296892.html
https://forums.gentoo.org/viewtopic-t-244837.html


Cheers!
Back to top
View user's profile Send private message
matja
n00b
n00b


Joined: 19 Jan 2007
Posts: 34

PostPosted: Fri Jan 19, 2007 11:49 am    Post subject: Reply with quote

Yes it is possible, I've done this before.
You'll need a custom initrd/initramfs which :

* copies a filesystem into RAM via a ramdisk, then just chroot/pivot_root into it.
- or -
* creates a tmpfs and copies the files from a filesystem into it, then just chroot/pivot_root into it.

Or, just make it into a large initrd and mount it rw via your bootloader (simplest :) )
Back to top
View user's profile Send private message
konan
n00b
n00b


Joined: 13 Sep 2006
Posts: 13

PostPosted: Fri Jan 19, 2007 12:02 pm    Post subject: Reply with quote

Hmm...

Could you be more specific? Pretty pliz!
Back to top
View user's profile Send private message
matja
n00b
n00b


Joined: 19 Jan 2007
Posts: 34

PostPosted: Fri Jan 19, 2007 1:59 pm    Post subject: Reply with quote

For example, I have a USB flash memory stick which I like to boot from occasionally without modifying whats on there already.

Make a directory which will be your initrd root, then fill it with the files and programs you'll need..
A very simple initrd would look like :

Code:

/bin
 busybox
 ash -> busybox
 mount -> busybox
 cp -> busybox
 pivot_root -> busybox
 chroot -> busybox
/dev
 console
 null
 sda
 sda1
/mnt
 /newroot
/proc
/sys
linuxrc


Busybox is a set of common Linux utilities as a single binary, you make symlinks to it with the names of the utility you want. If you statically compile it 'USE=static emerge busybox' then you will not require any .so dynamic loaded libraries.

linuxrc is a script which gets executed immediately after the kernel has mounted the initrd filesystem, it runs as PID 1 - its job is to mount the real root filesystem and execute /sbin/init on it.

So your linuxrc script would look something like :

Code:

#!/bin/ash
mount -t proc proc /proc
mount -t sysfs sysfs /sys

# do necessary stuff to get CF/USB flash stick working
modprobe usbcore
modprobe ehci-hcd
modprobe ohci-hcd
modprobe uhci-hcd
modprobe usb-storage
modprobe ext3

mount /dev/sda2 /mnt/flash-root -o ro -t ext3
mount -t tmpfs tmpfs /mnt/newroot
cp -a /mnt/flash-root/* /mnt/newroot
umount /mnt/flash-root

cd /mnt/newroot
/bin/pivot_root . initrd
exec /bin/chroot . /bin/sh -c 'exec /sbin/init' <dev/console >dev/console 2>&1


Finally, put all this into a filesystem which is supported by your kernel (compiled-in) :

Code:

dd if=/dev/zero of=initrd bs=1M count=8
mke2fs -F initrd
mkdir initrd.mount
mount -o loop initrd initrd.mount
cp -al initrd.root/* initrd.mount
umount initrd.mount
gzip -9 initrd


Now you have a initrd.gz which you can give to your bootloader :

kernel bzImage rw init=/linuxrc root=/dev/ram0
initrd initrd.gz

For starters, try just putting init=/bin/ash on your kernel command line, then try manually performing the steps, seeing what works and what doesn't, and when you've found the winning recipie, stick it in a linuxrc script.
Back to top
View user's profile Send private message
konan
n00b
n00b


Joined: 13 Sep 2006
Posts: 13

PostPosted: Sun Jan 21, 2007 1:33 am    Post subject: Reply with quote

Code:
cd /mnt/newroot
/bin/pivot_root . initrd
exec /bin/chroot . /bin/sh -c 'exec /sbin/init' <dev/console >dev/console 2>&1


When linuxrc is executed, everything goes well until commands above.

When executing /bin/pivot_root . initrd I get
Code:
pivot_root: pivot_root: No such file or directory


Looked the man page of pivot_root; usage -> "pivot_root new_root put_old"
I don't understand what in my case is put_old. It should be old root, but what exactly is my old root?
Back to top
View user's profile Send private message
konan
n00b
n00b


Joined: 13 Sep 2006
Posts: 13

PostPosted: Mon Jan 22, 2007 7:47 am    Post subject: Reply with quote

Hi, again!

I got my TinyGentoo up and running.
But still have problems.

After successfully booting-up my system, I tried to start a service (dropbear) and I get this:
Code:

/etc/init.d/dropbear start
-ash: /etc/init.d/dropbear: not found


I looked in my /sbin dir of TinyGentoo and there is no binary runscript neither runscript.sh.

Is it even possible to start service?

On my building system which I used to build TinyGentoo I have runscript and runscript.sh in /sbin.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo on Alternative Architectures All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum