View previous topic :: View next topic |
Author |
Message |
konan n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 13 Sep 2006 Posts: 13
|
Posted: Fri Jan 19, 2007 11:42 am Post subject: Gentoo from RAM |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
matja n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 19 Jan 2007 Posts: 34
|
Posted: Fri Jan 19, 2007 11:49 am Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
konan n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 13 Sep 2006 Posts: 13
|
Posted: Fri Jan 19, 2007 12:02 pm Post subject: |
|
|
Hmm...
Could you be more specific? Pretty pliz! |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
matja n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 19 Jan 2007 Posts: 34
|
Posted: Fri Jan 19, 2007 1:59 pm Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
konan n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 13 Sep 2006 Posts: 13
|
Posted: Sun Jan 21, 2007 1:33 am Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
konan n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 13 Sep 2006 Posts: 13
|
Posted: Mon Jan 22, 2007 7:47 am Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
|