public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] swap=<device> kernel commandline
@ 2000-11-18 11:46 Kaj-Michael Lang
  2000-11-18 14:15 ` Francois romieu
  0 siblings, 1 reply; 10+ messages in thread
From: Kaj-Michael Lang @ 2000-11-18 11:46 UTC (permalink / raw)
  To: Linux kernel list

[-- Attachment #1: Type: TEXT/PLAIN, Size: 260 bytes --]

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.


[-- Attachment #2: Type: TEXT/PLAIN, Size: 1362 bytes --]

--- init/main.c-2.4.0test11-pre7	Sat 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.");
 }
+

^ permalink raw reply	[flat|nested] 10+ messages in thread
* RE: [PATCH] swap=<device> kernel commandline
@ 2000-11-19 12:20 Anders Eriksson
  0 siblings, 0 replies; 10+ messages in thread
From: Anders Eriksson @ 2000-11-19 12:20 UTC (permalink / raw)
  To: Eric W. Biederman, Werner Almesberger; +Cc: Linux kernel list

>===== Original Message From ebiederm@xmission.com (Eric W. Biederman) =====
>Werner Almesberger <Werner.Almesberger@epfl.ch> 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 majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2000-11-19 20:36 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-11-18 11:46 [PATCH] swap=<device> kernel commandline Kaj-Michael Lang
2000-11-18 14:15 ` Francois romieu
2000-11-18 20:05   ` Rik van Riel
2000-11-18 21:34     ` Werner Almesberger
2000-11-18 18:54       ` Pavel Machek
2000-11-19  0:29       ` Eric W. Biederman
2000-11-19  2:03         ` Werner Almesberger
2000-11-19  7:30           ` Eric W. Biederman
2000-11-19 12:27             ` Werner Almesberger
  -- strict thread matches above, loose matches on Subject: below --
2000-11-19 12:20 Anders Eriksson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox