TODO: Documentation
---
BTW: Is it possible to mount a tmpfs on / before extracting the cpio?
While I'm at it:
In init/do_mounts.c, mount_root(void):
ROOT_NFS: Is it desirable to use the floppy as a root device if nfs-root
failed? If I tell my system to d A, i usually dislike it to do B instead.
Is the boot-from-floppy code here still usable, even though booting from
floppy is no longer supported?
diff -X dontdiff -pruN 2.6.21.ori/init/do_mounts.c 2.6.21/init/do_mounts.c
--- 2.6.21.ori/init/do_mounts.c 2007-07-06 03:31:57.000000000 +0200
+++ 2.6.21/init/do_mounts.c 2007-07-06 03:27:33.000000000 +0200
@@ -427,6 +427,9 @@ void __init prepare_namespace(void)
mount_block_root(root_device_name, root_mountflags);
goto out;
}
+ if (!strncmp(root_device_name, "initramfs", 3)) {
+ goto out_nomount;
+ }
ROOT_DEV = name_to_dev_t(root_device_name);
if (strncmp(root_device_name, "/dev/", 5) == 0)
root_device_name += 5;
@@ -444,6 +447,7 @@ void __init prepare_namespace(void)
out:
sys_mount(".", "/", NULL, MS_MOVE, NULL);
sys_chroot(".");
+out_nomount:
security_sb_post_mountroot();
}
--
Top 100 things you don't want the sysadmin to say:
65. What do you mean /home was on that disk? I umounted it!
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majo...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Uhm, the kernel doesn't mount anything if you're using an initramfs.
> BTW: Is it possible to mount a tmpfs on / before extracting the cpio?
Not in the stock kernel. There have been some patches floating around
for that, I think.
-hpa
> Bodo Eggert wrote:
> > This patch adds the option to not mount another root filesystem
> > by specifying root=initramfs.
>
> Uhm, the kernel doesn't mount anything if you're using an initramfs.
Yes, instead it panics trying to mount the non-existing "root=".
I've put the complete system into initrams, and I just want the kernel to
run /sbin/init.
> > BTW: Is it possible to mount a tmpfs on / before extracting the cpio?
>
> Not in the stock kernel. There have been some patches floating around
> for that, I think.
Are they messy, or would it just be a case of calling sys_mount before
unpacking the cpio?
--
The complexity of a weapon is inversely proportional to the IQ of the
weapon's operator.
If I understood you correctly, you're trying to get the kernel
to execute the "/sbin/init" file of your initramfs. However, "/init"
is the sole default initramfs entry point. To fix this, you can pass
rdinit=/sbin/init _or_ modify your initramfs image so that "/init"
is the entrypoint.
Normally, if your initramfs has a /init script your kernel would
skip the entire stage where it panics in the perpare_namespace()
function for trying to mount "root=" by itself (see
init/main.c:init()).
--
Dan Aloni
XIV LTD, http://www.xivstorage.com
da-x (at) monatomic.org, dan (at) xiv.co.il
> I've put the complete system into initrams, and I just want the kernel to
> run /sbin/init.
Did you try to exec /sbin/init as the last thing in the init script
of your initramfs? That worked for me some time ago.
Andre
--
The only person who always got his work done by Friday was Robinson Crusoe
Just add a symlink:
/init -> /sbin/init
-hpa
What would it buy? rootfs is a tmpfs, is not it?
Jan
--
No, rootfs is ramfs.
-hpa
Thanks for clarifying. Well, why is it a ramfs, and not tmpfs?
(I think I know the difference, but the question stands.
A system without any swap somewhat equals a ramfs, or?)
Jan
--
It gets initialized very early, and a lot of the setup needed for tmpfs
to work isn't ready yet.
-hpa
> >> BTW: Is it possible to mount a tmpfs on / before extracting the cpio?
> >
> >Not in the stock kernel. There have been some patches floating around
> >for that, I think.
>
> What would it buy? rootfs is a tmpfs, is not it?
As far as I understand, it is a ramfs aka. non-swappable tmpfs without any
limit and including a chance of DoSing the system.
Since I'm toying with root-on-initcpio, I'm looking for things that might
make the task some easier.
Currently I'm thinking about changing the root=initramfs to root=tmpfs and
additionally mounting a tmpfs on / before unpacking the cpios. OTOH, this
seems to be a little bit messy. OTOH again, in _that_ boot code, nobody
should complain :)
--
"Whoever said the pen is mightier than the sword obviously never
encountered automatic weapons."
-Gen. Douglas MacArthur
Come to speak of it, I think you can have it much easier by having the kernel
exporting the cpio image as a virtual file inside rootfs, so that you could
re-extract it inside a tmpfs. In other words:
mount -t tmpfs tmpfs /mnt;
cd /mnt;
cpio -diuv </initramfs.cpio;
#
# switch_root nukes rootfs, pivot_roots and execs some init
klibc_switch_root .; # or something like that
Of course this needs double the memory than directly mounting tmpfs as
rootfs, but it's an idea too.
Jan
--
Well, we're doing exactly this for non-initramfs initrd, however, it
would definitely be cleaner just to overmount rootfs with a tmpfs before
extraction -- it's an absolutely trivial amount of code; the biggest
complexity would be spotting the kernel command line option to invoke it.
Yet another variant, which works on existing kernels, is to have a
nested cpio, where your rootfs consists of a trivial /init which mounts
tmpfs and extracts another tar- or cpioball.
-hpa
Well, maybe it would be time to assign limits to ramfs. I have a patch for
this in all my own 2.4 kernels that I use on appliances, network boot and
bootable CDs. It was a bit tricky to get the limits to work well in 2.4
because it was not easy to track which pages were used by whom. But I presume
that rmap in 2.6 should help a lot.
If someone is willing to give this a try, here's the 2.4 patch :
http://linux.1wt.eu/kernel/patches-2.4.34-wt1/pool/2.4.32-ramfs-limits-5
Regards,
Willy
Out of curiosity, do you know which setup? I know that it won't actually swap
anything out yet because no swap is mounted, but I thought that mounting
tmpfs and doing a swapon afterwards was ok...
> -hpa
Rob
--
"One of my most productive days was throwing away 1000 lines of code."
- Ken Thompson.
Nope, I just know that the "obvious" way to do it crashes the kernel
horribly. It looks based on the patchsets that have flown about
recently as it's mostly a matter of initializing the icache.
-hpa
--
cu
Roland Kruggel mailto: rk.liste at bbf7.de
System: Intel, Debian etch, 2.6.16.16, xfce4 KDE 3.5
Test vom script...