Re: [PATCH] swap= kernel commandline

2000-11-19 Thread Pavel Machek

Hi1

> > Did you try to load an initrd on a low-memory machine?
> > It shouldn't work and it probably won't ;)
> 
> You must be really low on memory ;-)
> 
> # zcat initrd.gz | wc -c
>  409600
> 
> (ash, pwd, chroot, pivot_root, smount, and still about 82 kB free.)

Your solution requires 400K initrd _plus_ memory for ash and swapon. That
might be easily 600K total. Yes I could imagine machine with freemem less
than that. However such machines do not usually have swap available.

Pavel
-- 
Philips Velo 1: 1"x4"x8", 300gram, 60, 12MB, 40bogomips, linux, mutt,
details at http://atrey.karlin.mff.cuni.cz/~pavel/velo/index.html.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
Please read the FAQ at http://www.tux.org/lkml/



Re: [PATCH] swap= kernel commandline

2000-11-19 Thread Werner Almesberger

Eric W. Biederman wrote:
> Hmm. What does it take to mount an NFS partition?

Mainly Sun RPC :-(

> Anyway.  All I did was wrote a tiny libc that is just a bunch of
> wrappers for syscalls, and some string functions.

Certainly a good approach. It's also basically the idea behind newlib,
although newlib has more overhead.

Ultimately, I want to be able to compile regular Unix/Linux programs
out of the box. Right now, this works for a bunch of trivial programs,
and it almost works for ash.

> Now if glibc wouldn't link in 200k of unused crap when you make a
> trivial static binary I'd much prefer to use it...

Precisely why I went to newlib ... It's really a pity that glibc is
such a monster.

> Though I wish it was possible to have a ramfs preloader instead of
> initrd.  An initramfs would allow me to not even compile in the block
> device driver layer, and be more efficient.

Hmm, this would be tricky. You could do it by implementing a simple
tar file reader in the kernel, which reads from /dev/initrd (well, it's
in-kernel representation), but I'm not sure if this buys you that much
in the end. (How much overhead is in block devices anyway ?)

- Werner

-- 
  _
 / Werner Almesberger, ICA, EPFL, CH   [EMAIL PROTECTED] /
/_IN_N_032__Tel_+41_21_693_6621__Fax_+41_21_693_6610_/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
Please read the FAQ at http://www.tux.org/lkml/



RE: [PATCH] swap= kernel commandline

2000-11-19 Thread Anders Eriksson

>= Original Message From [EMAIL PROTECTED] (Eric W. Biederman) =
>Werner Almesberger <[EMAIL PROTECTED]> writes:
>
>> Eric W. Biederman wrote:
>> > I have one that loads a second kernel over the network using dhcp
>> > to configure it's interface and tftp to fetch the image and boots
>> > that is only 20kb uncompressed
>>
>> Neat ;-) My goal is actually not only size, but also to have a relatively
>> normal build environment, e.g. my example is with shared newlib, regular
>> ash, and - unfortunately rather wasteful - glibc's ld.so.
>>
>> But a tftp loader in 20kB is rather good. Now the next challenge is the
>> same thing with NFS. Then we can finally kill nfsroot ;-)
>
>Hmm. What does it take to mount an NFS partition?
>
>Anyway.  All I did was wrote a tiny libc that is just a bunch of
>wrappers for syscalls, and some string functions.  Then I just wrote
>a straight forward C program to do the job.  Except for my added
>kexec call I can compile with glibc :)
>
>Now if glibc wouldn't link in 200k of unused crap when you make a
>trivial static binary I'd much prefer to use it...
>
>Though I wish it was possible to have a ramfs preloader instead of
>initrd.  An initramfs would allow me to not even compile in the block
>device driver layer, and be more efficient.
>
A discussion on l-k two months ago revealed that someone actually had made a 
patch that took a tarball (masquaraded as an initrd image) and unpacked it 
into a ramfs. I've got the mail samewhere if you want it.

/Anders

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
Please read the FAQ at http://www.tux.org/lkml/



Re: [PATCH] swap= kernel commandline

2000-11-19 Thread Eric W. Biederman

Werner Almesberger <[EMAIL PROTECTED]> writes:

> Eric W. Biederman wrote:
> > I have one that loads a second kernel over the network using dhcp 
> > to configure it's interface and tftp to fetch the image and boots
> > that is only 20kb uncompressed
> 
> Neat ;-) My goal is actually not only size, but also to have a relatively
> normal build environment, e.g. my example is with shared newlib, regular
> ash, and - unfortunately rather wasteful - glibc's ld.so.
> 
> But a tftp loader in 20kB is rather good. Now the next challenge is the
> same thing with NFS. Then we can finally kill nfsroot ;-)

Hmm. What does it take to mount an NFS partition?

Anyway.  All I did was wrote a tiny libc that is just a bunch of
wrappers for syscalls, and some string functions.  Then I just wrote
a straight forward C program to do the job.  Except for my added
kexec call I can compile with glibc :)

Now if glibc wouldn't link in 200k of unused crap when you make a
trivial static binary I'd much prefer to use it...

Though I wish it was possible to have a ramfs preloader instead of
initrd.  An initramfs would allow me to not even compile in the block
device driver layer, and be more efficient.

Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
Please read the FAQ at http://www.tux.org/lkml/



Re: [PATCH] swap= kernel commandline

2000-11-18 Thread Werner Almesberger

Eric W. Biederman wrote:
> I have one that loads a second kernel over the network using dhcp 
> to configure it's interface and tftp to fetch the image and boots
> that is only 20kb uncompressed

Neat ;-) My goal is actually not only size, but also to have a relatively
normal build environment, e.g. my example is with shared newlib, regular
ash, and - unfortunately rather wasteful - glibc's ld.so.

But a tftp loader in 20kB is rather good. Now the next challenge is the
same thing with NFS. Then we can finally kill nfsroot ;-)

- Werner

-- 
  _
 / Werner Almesberger, ICA, EPFL, CH   [EMAIL PROTECTED] /
/_IN_N_032__Tel_+41_21_693_6621__Fax_+41_21_693_6610_/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
Please read the FAQ at http://www.tux.org/lkml/



Re: [PATCH] swap= kernel commandline

2000-11-18 Thread Eric W. Biederman

Werner Almesberger <[EMAIL PROTECTED]> writes:

> Rik van Riel wrote:
> > Did you try to load an initrd on a low-memory machine?
> > It shouldn't work and it probably won't ;)
> 
> You must be really low on memory ;-)
> 
> # zcat initrd.gz | wc -c
>  409600
> 
> (ash, pwd, chroot, pivot_root, smount, and still about 82 kB free.)

Hmm And that's without trying to be small.
I have one that loads a second kernel over the network using dhcp 
to configure it's interface and tftp to fetch the image and boots
that is only 20kb uncompressed

Compressed I can fit that and a kernel all in plus a minimal
BIOS all in 512K with some room to spare...

Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
Please read the FAQ at http://www.tux.org/lkml/



Re: [PATCH] swap= kernel commandline

2000-11-18 Thread Werner Almesberger

Rik van Riel wrote:
> Did you try to load an initrd on a low-memory machine?
> It shouldn't work and it probably won't ;)

You must be really low on memory ;-)

# zcat initrd.gz | wc -c
 409600

(ash, pwd, chroot, pivot_root, smount, and still about 82 kB free.)

- Werner

-- 
  _
 / Werner Almesberger, ICA, EPFL, CH   [EMAIL PROTECTED] /
/_IN_N_032__Tel_+41_21_693_6621__Fax_+41_21_693_6610_/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
Please read the FAQ at http://www.tux.org/lkml/



Re: [PATCH] swap= kernel commandline

2000-11-18 Thread Rik van Riel

On Sat, 18 Nov 2000, Francois romieu wrote:
> The Sat, Nov 18, 2000 at 01:46:40PM +0200, Kaj-Michael Lang wrote :
> > This patch adds a swap kernel commandline option, so that you can add a
> > swap partition before init starts running on a low-memory machine. 
   ^^

> Did you try and add swap from an initrd image ? It should work
> and it's already there.

Did you try to load an initrd on a low-memory machine?
It shouldn't work and it probably won't ;)

regards,

Rik
--
"What you're running that piece of shit Gnome?!?!"
   -- Miguel de Icaza, UKUUG 2000

http://www.conectiva.com/   http://www.surriel.com/

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
Please read the FAQ at http://www.tux.org/lkml/



Re: [PATCH] swap= kernel commandline

2000-11-18 Thread Francois romieu

Hi,

The Sat, Nov 18, 2000 at 01:46:40PM +0200, Kaj-Michael Lang wrote :
> This patch adds a swap kernel commandline option, so that you can add a
> swap partition before init starts running on a low-memory machine. 

Did you try and add swap from an initrd image ? It should work and it's
already there.

-- 
Ueimor
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
Please read the FAQ at http://www.tux.org/lkml/



[PATCH] swap= kernel commandline

2000-11-18 Thread Kaj-Michael Lang

This patch adds a swap kernel commandline option, so that you can add a
swap partition before init starts running on a low-memory machine. 

The patch is against 2.4.0-test11-pre7

This is my first try at a kernel patch so... I hope someone finds it
usefull.



--- init/main.c-2.4.0test11-pre7Sat Nov 18 12:30:59 2000
+++ init/main.c Sat Nov 18 12:35:08 2000
@@ -131,6 +131,7 @@
 int root_mountflags = MS_RDONLY;
 char *execute_command;
 char root_device_name[64];
+char swap_device_name[64];
 
 
 static char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
@@ -297,6 +298,25 @@
 
 __setup("root=", root_dev_setup);
 
+static int __init swap_dev_setup(char *line)
+{
+   int i;
+   char ch;
+
+   memset (swap_device_name, 0, sizeof swap_device_name);
+   for (i = 0; i < sizeof swap_device_name - 1; ++i)
+   {
+   ch = line[i];
+   if ( isspace (ch) || (ch == ',') || (ch == '\0') ) break;
+   swap_device_name[i] = ch;
+   }
+   return 1;
+}
+
+
+__setup("swap=", swap_dev_setup);
+
+
 static int __init checksetup(char *line)
 {
struct kernel_param *p;
@@ -725,6 +745,15 @@
 
mount_devfs_fs ();
 
+   if (swap_device_name[0]!=0) {
+ printk("Setting up swap: %s \n",swap_device_name);
+ if ( sys_swapon(swap_device_name,0)==0 ) {
+   printk("Swapon ok\n"); 
+   } else {
+   printk("Swapon failed!\n");
+   }
+   }
+ 
 #ifdef CONFIG_BLK_DEV_INITRD
root_mountflags = real_root_mountflags;
if (mount_initrd && ROOT_DEV != real_root_dev
@@ -780,3 +809,4 @@
execve("/bin/sh",argv_init,envp_init);
panic("No init found.  Try passing init= option to kernel.");
 }
+